From 3890db90776f1bd69f4ab6ab040e2964311f54f2 Mon Sep 17 00:00:00 2001 From: Nova Kwok Date: Wed, 5 Jan 2022 11:02:28 +0800 Subject: [PATCH] Optimize release procedure (#94) * Optimize docker release action * Added ignored-path on CI --- .github/workflows/CI.yaml | 6 +++- .../{release.yaml => release_binary.yaml} | 8 +++-- ...builder.yaml => release_docker_image.yaml} | 30 +++++++++++++++++-- 3 files changed, 39 insertions(+), 5 deletions(-) rename .github/workflows/{release.yaml => release_binary.yaml} (91%) rename .github/workflows/{builder.yaml => release_docker_image.yaml} (65%) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index bd8a2db..cc0e7a3 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -1,6 +1,10 @@ -name: CI +name: CI check on every push on: push: + paths-ignore: + - '**.md' + - 'Makefile' + - 'config.json' jobs: ci: diff --git a/.github/workflows/release.yaml b/.github/workflows/release_binary.yaml similarity index 91% rename from .github/workflows/release.yaml rename to .github/workflows/release_binary.yaml index 4334e78..e7c3ee2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release_binary.yaml @@ -1,10 +1,14 @@ +name: Release Binaries + on: push: + paths-ignore: + - '**.md' + - 'Makefile' + - 'config.json' tags: - '*' -name: Release Binaries - jobs: build: name: Create Release diff --git a/.github/workflows/builder.yaml b/.github/workflows/release_docker_image.yaml similarity index 65% rename from .github/workflows/builder.yaml rename to .github/workflows/release_docker_image.yaml index 7835631..9cf1dba 100644 --- a/.github/workflows/builder.yaml +++ b/.github/workflows/release_docker_image.yaml @@ -1,8 +1,14 @@ -name: build docker image +name: Build and release docker images on: push: + paths-ignore: + - '**.md' + - 'Makefile' + - 'config.json' branches: - 'master' + tags: + - '*' jobs: docker: @@ -13,6 +19,9 @@ jobs: with: submodules: true + - name: Get the tag name + run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -46,7 +55,8 @@ jobs: with: string: ${{ github.event.repository.full_name }} - - name: Build and push + - name: Build and push latest images + if: ${{ github.ref == 'refs/heads/master' }} uses: docker/build-push-action@v2 with: context: . @@ -61,6 +71,22 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + - name: Build and push tagged images + if: ${{ github.ref != 'refs/heads/master' }} + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/arm,linux/amd64,linux/arm64 + push: true + tags: | + webpsh/webp_server_go:${{ env.TAG }} + webpsh/webp-server-go:${{ env.TAG }} + webpsh/webps:${{ env.TAG }} + ghcr.io/${{ steps.ghcr_string.outputs.lowercase }}:${{ env.TAG }} + + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + - name: Move cache run: | rm -rf /tmp/.buildx-cache