Merge pull request #2 from zeabur/improve-release #15
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: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| actions: write | |
| concurrency: | |
| group: release-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| build-amd64: | |
| name: Build (linux/amd64) | |
| runs-on: blacksmith-2vcpu-ubuntu-2404 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 | |
| - name: Login to Docker Hub | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract version | |
| id: meta | |
| run: | | |
| if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then | |
| echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "version=0.0.0" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Build and push | |
| uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 | |
| with: | |
| platforms: linux/amd64 | |
| push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} | |
| tags: docker.io/zeabur/stratus:${{ steps.meta.outputs.version }}-linux-amd64 | |
| cache-from: type=gha,scope=buildkit-linux-amd64 | |
| cache-to: type=gha,mode=max,scope=buildkit-linux-amd64 | |
| build-arm64: | |
| name: Build (linux/arm64) | |
| runs-on: blacksmith-2vcpu-ubuntu-2404-arm | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 | |
| - name: Login to Docker Hub | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract version | |
| id: meta | |
| run: | | |
| if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then | |
| echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "version=0.0.0" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Build and push | |
| uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 | |
| with: | |
| platforms: linux/arm64 | |
| push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} | |
| tags: docker.io/zeabur/stratus:${{ steps.meta.outputs.version }}-linux-arm64 | |
| cache-from: type=gha,scope=buildkit-linux-arm64 | |
| cache-to: type=gha,mode=max,scope=buildkit-linux-arm64 | |
| push-dockerhub: | |
| name: Push to Docker Hub | |
| runs-on: blacksmith-2vcpu-ubuntu-2404-arm | |
| needs: [build-amd64, build-arm64] | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Create multi-arch manifest | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| docker buildx imagetools create \ | |
| -t docker.io/zeabur/stratus:${VERSION} \ | |
| -t docker.io/zeabur/stratus:${VERSION%.*} \ | |
| -t docker.io/zeabur/stratus:${VERSION%%.*} \ | |
| -t docker.io/zeabur/stratus:latest \ | |
| docker.io/zeabur/stratus:${VERSION}-linux-amd64 \ | |
| docker.io/zeabur/stratus:${VERSION}-linux-arm64 | |
| push-swr: | |
| name: Push to Huawei SWR | |
| runs-on: blacksmith-2vcpu-ubuntu-2404-arm | |
| needs: [build-amd64, build-arm64] | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Login to Huawei SWR | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| registry: swr.cn-east-3.myhuaweicloud.com | |
| username: ${{ secrets.HUAWEI_SWR_USERNAME }} | |
| password: ${{ secrets.HUAWEI_SWR_TOKEN }} | |
| - name: Retag to SWR | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| REGISTRY=swr.cn-east-3.myhuaweicloud.com | |
| docker buildx imagetools create \ | |
| -t ${REGISTRY}/zeabur/stratus:${VERSION} \ | |
| -t ${REGISTRY}/zeabur/stratus:${VERSION%.*} \ | |
| -t ${REGISTRY}/zeabur/stratus:${VERSION%%.*} \ | |
| -t ${REGISTRY}/zeabur/stratus:latest \ | |
| docker.io/zeabur/stratus:${VERSION}-linux-amd64 \ | |
| docker.io/zeabur/stratus:${VERSION}-linux-arm64 |