name: Release Docker Image on: release: types: [published] workflow_dispatch: inputs: release_tag: description: "Release tag to build" required: true permissions: contents: read packages: write jobs: build-and-push: name: Build and push image to GHCR runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Prepare image name (lowercase) id: prep run: | REPO_LC="${GITHUB_REPOSITORY,,}" echo "IMAGE=ghcr.io/${REPO_LC}" >> $GITHUB_ENV if [ "${{ github.event_name }}" = "release" ]; then echo "RELEASE_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV else echo "RELEASE_VERSION=${{ github.event.inputs.release_tag }}" >> $GITHUB_ENV fi - name: Extract Docker metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ env.IMAGE }} tags: | type=raw,value=${{ env.RELEASE_VERSION }} - name: Add "latest" tag for any non-prerelease release run: echo "EXTRA_TAGS=${{ env.IMAGE }}:latest" >> $GITHUB_ENV - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push uses: docker/build-push-action@v6 with: context: . file: Dockerfile push: true platforms: linux/amd64,linux/arm64 tags: | ${{ steps.meta.outputs.tags }} ${{ env.EXTRA_TAGS }} labels: ${{ steps.meta.outputs.labels }} build-args: | RELEASE_VERSION=${{ env.RELEASE_VERSION }}