Add release version tagging to Docker workflow #202
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Publish Multi-Arch Docker Image | |
| on: | |
| push: | |
| branches: [ development ] | |
| pull_request: | |
| branches: [ main, development ] | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| platforms: | |
| description: 'Platforms to build (comma-separated)' | |
| default: 'linux/amd64,linux/arm64,linux/arm/v7' | |
| required: false | |
| type: string | |
| release_tag: | |
| description: 'Release version tag (e.g., 1.2.3). If provided, also tags as latest.' | |
| required: false | |
| type: string | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GHCR | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ secrets.GHCR_USERNAME }} | |
| password: ${{ secrets.GHCR_TOKEN }} | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/autonomy-logic/openplc-runtime | |
| tags: | | |
| # latest tag for releases or manual runs with release_tag | |
| type=raw,value=latest,enable=${{ github.event_name == 'release' || inputs.release_tag != '' }} | |
| # SHA tag for branch pushes | |
| type=sha,enable=${{ github.event_name == 'push' }} | |
| # Version tag for releases (e.g., v1.2.3 -> 1.2.3) | |
| type=semver,pattern={{version}} | |
| # Version tag for manual runs with release_tag | |
| type=raw,value=${{ inputs.release_tag }},enable=${{ inputs.release_tag != '' }} | |
| # development tag for development branch | |
| type=raw,value=development,enable=${{ github.ref == 'refs/heads/development' }} | |
| - name: Build and Push Multi-Arch Image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: ${{ github.event_name != 'pull_request' }} | |
| platforms: ${{ inputs.platforms || 'linux/amd64,linux/arm64,linux/arm/v7' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} |