Skip to content

Commit 6768919

Browse files
committed
fix: actions
1 parent 4c1a416 commit 6768919

1 file changed

Lines changed: 110 additions & 14 deletions

File tree

.github/workflows/release.yml

Lines changed: 110 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,16 @@ env:
99
REGISTRY: ghcr.io
1010

1111
jobs:
12-
build-and-push:
13-
name: Build and Push Docker Image
14-
runs-on: ubuntu-latest
12+
test:
13+
name: Test
14+
runs-on: ubuntu-24.04
1515
permissions:
1616
contents: read
17-
packages: write
1817

1918
steps:
2019
- name: Checkout code
2120
uses: actions/checkout@v4
2221

23-
- name: Set image name to lowercase
24-
id: image
25-
run: echo "name=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
26-
2722
- name: Setup Go
2823
uses: actions/setup-go@v5
2924
with:
@@ -32,6 +27,32 @@ jobs:
3227
- name: Run tests
3328
run: make test
3429

30+
build-and-push:
31+
name: Build ${{ matrix.platform }}
32+
needs: test
33+
runs-on: ${{ matrix.runner }}
34+
permissions:
35+
contents: read
36+
packages: write
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
include:
41+
- platform: linux/amd64
42+
runner: ubuntu-24.04
43+
arch: amd64
44+
- platform: linux/arm64
45+
runner: ubuntu-24.04-arm
46+
arch: arm64
47+
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@v4
51+
52+
- name: Set image name to lowercase
53+
id: image
54+
run: echo "name=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
55+
3556
- name: Set up Docker Buildx
3657
uses: docker/setup-buildx-action@v3
3758

@@ -54,20 +75,95 @@ jobs:
5475
type=sha
5576
5677
- name: Build and push Docker image
78+
id: build
5779
uses: docker/build-push-action@v5
5880
with:
5981
context: .
60-
push: true
61-
tags: ${{ steps.meta.outputs.tags }}
82+
platforms: ${{ matrix.platform }}
6283
labels: ${{ steps.meta.outputs.labels }}
63-
platforms: linux/amd64,linux/arm64
84+
outputs: type=image,name=${{ env.REGISTRY }}/${{ steps.image.outputs.name }},push-by-digest=true,name-canonical=true,push=true
6485
cache-from: type=gha
65-
cache-to: type=gha,mode=max
86+
cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
87+
88+
- name: Export image digest
89+
run: |
90+
mkdir -p /tmp/digests
91+
digest="${{ steps.build.outputs.digest }}"
92+
touch "/tmp/digests/${digest#sha256:}"
93+
94+
- name: Upload image digest
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: digests-${{ matrix.arch }}
98+
path: /tmp/digests/*
99+
if-no-files-found: error
100+
retention-days: 1
101+
102+
merge-image:
103+
name: Merge Multi-Platform Image
104+
runs-on: ubuntu-24.04
105+
needs: build-and-push
106+
permissions:
107+
contents: read
108+
packages: write
109+
110+
steps:
111+
- name: Set image name to lowercase
112+
id: image
113+
run: echo "name=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
114+
115+
- name: Download image digests
116+
uses: actions/download-artifact@v4
117+
with:
118+
path: /tmp/digests
119+
pattern: digests-*
120+
merge-multiple: true
121+
122+
- name: Set up Docker Buildx
123+
uses: docker/setup-buildx-action@v3
124+
125+
- name: Log in to Container Registry
126+
uses: docker/login-action@v3
127+
with:
128+
registry: ${{ env.REGISTRY }}
129+
username: ${{ github.actor }}
130+
password: ${{ secrets.GITHUB_TOKEN }}
131+
132+
- name: Extract metadata
133+
id: meta
134+
uses: docker/metadata-action@v5
135+
with:
136+
images: ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}
137+
tags: |
138+
type=semver,pattern=v{{version}}
139+
type=semver,pattern={{version}}
140+
type=semver,pattern={{major}}.{{minor}}
141+
type=sha
142+
143+
- name: Create multi-platform manifest
144+
env:
145+
IMAGE_NAME: ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}
146+
IMAGE_TAGS: ${{ steps.meta.outputs.tags }}
147+
run: |
148+
tag_args=()
149+
while IFS= read -r tag; do
150+
tag_args+=(--tag "$tag")
151+
done <<< "$IMAGE_TAGS"
152+
source_args=()
153+
for digest in /tmp/digests/*; do
154+
source_args+=("$IMAGE_NAME@sha256:$(basename "$digest")")
155+
done
156+
docker buildx imagetools create "${tag_args[@]}" "${source_args[@]}"
157+
158+
- name: Inspect multi-platform image
159+
env:
160+
VERSION_TAG: ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}:${{ github.ref_name }}
161+
run: docker buildx imagetools inspect "$VERSION_TAG"
66162

67163
release-manifests:
68164
name: Generate Release Manifests
69165
runs-on: ubuntu-latest
70-
needs: build-and-push
166+
needs: merge-image
71167
permissions:
72168
contents: write
73169

@@ -94,7 +190,7 @@ jobs:
94190
helm package dist/chart --destination dist --version "$VERSION" --app-version "$VERSION"
95191
96192
- name: Upload Release Assets
97-
uses: softprops/action-gh-release@v1
193+
uses: softprops/action-gh-release@v2
98194
with:
99195
files: |
100196
dist/install.yaml

0 commit comments

Comments
 (0)