From 9014c212e8e1f6cf536820646d848208db2f8174 Mon Sep 17 00:00:00 2001 From: itchyny Date: Wed, 5 Jul 2023 04:33:57 +0900 Subject: [PATCH] Release Docker image to GitHub Container Registry (#2652) --- .github/workflows/ci.yml | 46 +++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5974e1776c..d532109ec8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -188,6 +188,7 @@ jobs: dist: runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/jq-') steps: - name: Clone repository uses: actions/checkout@v3 @@ -217,12 +218,48 @@ jobs: jq-*.tar.gz jq-*.zip + docker: + runs-on: ubuntu-latest + permissions: + packages: write + if: startsWith(github.ref, 'refs/tags/jq-') + steps: + - name: Clone repository + uses: actions/checkout@v3 + with: + submodules: true + - name: Docker metadata + uses: docker/metadata-action@v4 + id: metadata + with: + images: ghcr.io/${{ github.repository }} + tags: type=match,pattern=jq-(.*),group=1,value=${{ github.ref_name }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and release Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + provenance: false + platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x + tags: ${{ steps.metadata.outputs.tags }} + labels: ${{ steps.metadata.outputs.labels }} + release: runs-on: ubuntu-latest permissions: contents: write - needs: [linux, macos, windows, dist] - if: startsWith(github.event.ref, 'refs/tags/jq-') + needs: [linux, macos, windows, dist, docker] + if: startsWith(github.ref, 'refs/tags/jq-') steps: - name: Clone repository uses: actions/checkout@v3 @@ -240,6 +277,5 @@ jobs: cp artifacts/jq-macos-macos-13-gcc/jq release/jq-macos-amd64 cp artifacts/jq-windows-windows-2022-gcc/jq.exe release/jq-windows-amd64.exe cp artifacts/jq-dist/jq-* release/ - - gh release create $TAG_NAME --draft --title "jq ${TAG_NAME#jq-}" --generate-notes - gh release upload $TAG_NAME --clobber release/jq-* + gh release create "$TAG_NAME" --draft --title "jq ${TAG_NAME#jq-}" --generate-notes + gh release upload "$TAG_NAME" --clobber release/jq-*