Skip to content

Commit

Permalink
ci: 🎡 build using native system
Browse files Browse the repository at this point in the history
  • Loading branch information
monlor committed Feb 12, 2025
1 parent 2c81520 commit a87c49c
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ env:

jobs:
build:
strategy:
matrix:
arch: [amd64, arm64]
include:
- arch: amd64
runs-on: ubuntu-latest
- arch: arm64
runs-on: ['ubuntu-latest', 'ARM64']

runs-on: ubuntu-latest
runs-on: ${{ matrix.runs-on }}
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
Expand Down Expand Up @@ -66,6 +72,15 @@ jobs:
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
flavor: |
suffix=-${{ matrix.arch }}
latest=false
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
Expand All @@ -77,7 +92,6 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max

Expand All @@ -95,3 +109,25 @@ jobs:
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

create-manifest:
needs: build
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and push manifest
run: |
# 为每个标签创建多架构清单
for tag in $(echo "${{ steps.meta.outputs.tags }}" | sed 's/-amd64//g' | sort -u); do
docker manifest create $tag \
$tag-amd64 \
$tag-arm64
docker manifest push $tag
done

0 comments on commit a87c49c

Please sign in to comment.