Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 69 additions & 52 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
tags:
- "v*"
pull_request:
workflow_dispatch:

permissions:
contents: read
Expand All @@ -16,7 +15,7 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
build-amd64:
build:
name: Build (linux/amd64)
runs-on: blacksmith-2vcpu-ubuntu-2404

Expand All @@ -25,78 +24,103 @@ jobs:
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
uses: useblacksmith/setup-docker-builder@722e97d12b1d06a961800dd6c05d79d951ad3c80 # v1.8.0

- name: Build
uses: useblacksmith/build-push-action@fb9e3e6a9299c78462bfadd0d93352c316adc9b8 # v2.2.0
with:
platforms: linux/amd64
push: false
Comment thread
pan93412 marked this conversation as resolved.

build-release-dockerhub:
name: Build (dockerhub, linux/${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
needs: [build]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
Comment thread
pan93412 marked this conversation as resolved.
Outdated
strategy:
matrix:
include:
- arch: amd64
platform: linux/amd64
runner: blacksmith-2vcpu-ubuntu-2404
- arch: arm64
platform: linux/arm64
runner: blacksmith-2vcpu-ubuntu-2404-arm

steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up Docker Buildx
uses: useblacksmith/setup-docker-builder@722e97d12b1d06a961800dd6c05d79d951ad3c80 # v1.8.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
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"

- name: Build and push
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
uses: useblacksmith/build-push-action@fb9e3e6a9299c78462bfadd0d93352c316adc9b8 # v2.2.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
platforms: ${{ matrix.platform }}
provenance: "true"
push: true
tags: docker.io/zeabur/stratus:${{ steps.meta.outputs.version }}-linux-${{ matrix.arch }}

build-release-swr:
name: Build (swr, linux/${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
needs: [build]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
include:
- arch: amd64
platform: linux/amd64
runner: blacksmith-2vcpu-ubuntu-2404
- arch: arm64
platform: linux/arm64
runner: 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
uses: useblacksmith/setup-docker-builder@722e97d12b1d06a961800dd6c05d79d951ad3c80 # v1.8.0

- name: Login to Docker Hub
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
- name: Login to Huawei SWR
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: swr.cn-east-3.myhuaweicloud.com
username: ${{ secrets.HUAWEI_SWR_USERNAME }}
password: ${{ secrets.HUAWEI_SWR_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
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"

- name: Build and push
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
uses: useblacksmith/build-push-action@fb9e3e6a9299c78462bfadd0d93352c316adc9b8 # v2.2.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
platforms: ${{ matrix.platform }}
provenance: "false"
push: true
tags: swr.cn-east-3.myhuaweicloud.com/zeabur/stratus:${{ steps.meta.outputs.version }}-linux-${{ matrix.arch }}

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/')
needs: [build-release-dockerhub]

steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
uses: useblacksmith/setup-docker-builder@722e97d12b1d06a961800dd6c05d79d951ad3c80 # v1.8.0

- name: Login to Docker Hub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
Expand All @@ -118,18 +142,11 @@ jobs:
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/')
needs: [build-release-swr]

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 }}
uses: useblacksmith/setup-docker-builder@722e97d12b1d06a961800dd6c05d79d951ad3c80 # v1.8.0

- name: Login to Huawei SWR
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
Expand All @@ -138,7 +155,7 @@ jobs:
username: ${{ secrets.HUAWEI_SWR_USERNAME }}
password: ${{ secrets.HUAWEI_SWR_TOKEN }}

- name: Retag to SWR
- name: Create multi-arch manifest
run: |
VERSION=${GITHUB_REF_NAME#v}
REGISTRY=swr.cn-east-3.myhuaweicloud.com
Expand All @@ -147,5 +164,5 @@ jobs:
-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
${REGISTRY}/zeabur/stratus:${VERSION}-linux-amd64 \
${REGISTRY}/zeabur/stratus:${VERSION}-linux-arm64
Loading