Skip to content

Commit 36d11f6

Browse files
feat: aarch64 build test 1
1 parent 9ee872d commit 36d11f6

File tree

1 file changed

+133
-10
lines changed

1 file changed

+133
-10
lines changed

.github/workflows/release.yml

Lines changed: 133 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ on:
66
jobs:
77
stage1:
88
name: Stage 1
9-
runs-on: ubuntu-latest
9+
runs-on: ${{ startsWith(matrix.platform, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
10+
strategy:
11+
matrix:
12+
platform:
13+
- linux/amd64
14+
- linux/arm64
1015
steps:
1116
- name: Checkout the Git repository
1217
uses: actions/checkout@v3
@@ -19,23 +24,84 @@ jobs:
1924
- name: Set up version
2025
run: |
2126
VERSION="$(echo "${{ github.ref }}" | cut -d / -f 3)"
22-
echo "tag=ghcr.io/noahimesaka1873/toolchain:$VERSION" >> "$GITHUB_ENV"
27+
platform=${{ matrix.platform }}
28+
echo "VERSION=$VERSION" >> $GITHUB_ENV
29+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
30+
echo "tag=ghcr.io/noahimesaka1873/toolchain:$VERSION" >> $GITHUB_ENV
2331
- name: Set up Docker Buildx
2432
uses: docker/setup-buildx-action@v3
2533
- name: Build and push toolchain
26-
uses: docker/build-push-action@v5
34+
uses: docker/build-push-action@v6
2735
with:
2836
context: toolchain/
2937
push: true
3038
tags: ${{ env.tag }}
3139
cache-from: type=gha
3240
cache-to: type=gha,mode=max
41+
outputs: type=image,"name=ghcr.io/noahimesaka1873/toolchain",push-by-digest=true,name-canonical=true,push=true
3342
build-args: |
3443
BUILDKIT_INLINE_CACHE=1
44+
- name: Export digest
45+
if: ${{ inputs.push_to_images != '' }}
46+
run: |
47+
mkdir -p "${{ runner.temp }}/digests"
48+
digest="${{ steps.build.outputs.digest }}"
49+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
50+
- name: Upload digest
51+
if: ${{ inputs.push_to_images != '' }}
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: digests-toolchain-${{ env.PLATFORM_PAIR }}-${{ env.VERSION }}
55+
path: ${{ runner.temp }}/digests/*
56+
if-no-files-found: error
57+
retention-days: 1
58+
stage1-upload:
59+
name: Stage 1 merge and push image
60+
needs: stage1
61+
runs-on: ubuntu-24.04
62+
env:
63+
PUSH_TO_IMAGES: ghcr.io/noahimesaka1873/toolchain
64+
steps:
65+
- uses: actions/checkout@v4
66+
- name: Set up version
67+
run: |
68+
VERSION="$(echo "${{ github.ref }}" | cut -d / -f 3)"
69+
echo "VERSION=$VERSION" >> $GITHUB_ENV
70+
- name: Download digests
71+
uses: actions/download-artifact@v4
72+
with:
73+
path: ${{ runner.temp }}/digests
74+
pattern: digests-toolchain-*-${{ env.VERSION }}
75+
merge-multiple: true
76+
- name: Log in to the GitHub Container registry
77+
uses: docker/login-action@v3
78+
with:
79+
registry: ghcr.io
80+
username: ${{ github.actor }}
81+
password: ${{ secrets.GITHUB_TOKEN }}
82+
- name: Set up Docker Buildx
83+
uses: docker/setup-buildx-action@v3
84+
- name: Docker meta
85+
id: meta
86+
uses: docker/metadata-action@v5
87+
with:
88+
images: ${{ env.PUSH_TO_IMAGES }}
89+
tags: ${{ env.VERSION }}
90+
- name: Create manifest list and push
91+
working-directory: ${{ runner.temp }}/digests
92+
run: |
93+
echo "$PUSH_TO_IMAGES" | xargs -I{} \
94+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
95+
$(printf '{}@sha256:%s ' *)
3596
stage2:
3697
name: Stage 2
37-
runs-on: ubuntu-latest
38-
needs: stage1
98+
needs: stage1-upload
99+
runs-on: ${{ startsWith(matrix.platform, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
100+
strategy:
101+
matrix:
102+
platform:
103+
- linux/amd64
104+
- linux/arm64
39105
steps:
40106
- name: Checkout the Git repository
41107
uses: actions/checkout@v3
@@ -48,24 +114,80 @@ jobs:
48114
- name: Set up version
49115
run: |
50116
VERSION="$(echo "${{ github.ref }}" | cut -d / -f 3)"
51-
echo "tag=ghcr.io/noahimesaka1873/base:$VERSION" >> "$GITHUB_ENV"
117+
platform=${{ matrix.platform }}
118+
echo "VERSION=$VERSION" >> $GITHUB_ENV
119+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
120+
echo "tag=ghcr.io/noahimesaka1873/base:$VERSION" >> $GITHUB_ENV
52121
- name: Set up Docker Buildx
53122
uses: docker/setup-buildx-action@v3
54123
- name: Build and push toolchain
55-
uses: docker/build-push-action@v5
124+
uses: docker/build-push-action@v6
56125
with:
57126
context: toolchain/
58127
push: true
59128
tags: ${{ env.tag }}
60129
cache-from: type=gha
61130
cache-to: type=gha,mode=max
131+
outputs: type=image,"name=ghcr.io/noahimesaka1873/base",push-by-digest=true,name-canonical=true,push=true
62132
build-args: |
63133
BUILDKIT_INLINE_CACHE=1
64134
FROM=ghcr.io/noahimesaka1873/toolchain
135+
- name: Export digest
136+
if: ${{ inputs.push_to_images != '' }}
137+
run: |
138+
mkdir -p "${{ runner.temp }}/digests"
139+
digest="${{ steps.build.outputs.digest }}"
140+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
141+
- name: Upload digest
142+
if: ${{ inputs.push_to_images != '' }}
143+
uses: actions/upload-artifact@v4
144+
with:
145+
name: digests-base-${{ env.PLATFORM_PAIR }}-${{ env.VERSION }}
146+
path: ${{ runner.temp }}/digests/*
147+
if-no-files-found: error
148+
retention-days: 1
149+
stage2-upload:
150+
name: Stage 2 merge and push image
151+
needs: stage2
152+
runs-on: ubuntu-24.04
153+
env:
154+
PUSH_TO_IMAGES: ghcr.io/noahimesaka1873/base
155+
steps:
156+
- uses: actions/checkout@v4
157+
- name: Set up version
158+
run: |
159+
VERSION="$(echo "${{ github.ref }}" | cut -d / -f 3)"
160+
echo "VERSION=$VERSION" >> $GITHUB_ENV
161+
- name: Download digests
162+
uses: actions/download-artifact@v4
163+
with:
164+
path: ${{ runner.temp }}/digests
165+
pattern: digests-base-*-${{ env.VERSION }}
166+
merge-multiple: true
167+
- name: Log in to the GitHub Container registry
168+
uses: docker/login-action@v3
169+
with:
170+
registry: ghcr.io
171+
username: ${{ github.actor }}
172+
password: ${{ secrets.GITHUB_TOKEN }}
173+
- name: Set up Docker Buildx
174+
uses: docker/setup-buildx-action@v3
175+
- name: Docker meta
176+
id: meta
177+
uses: docker/metadata-action@v5
178+
with:
179+
images: ${{ env.PUSH_TO_IMAGES }}
180+
tags: ${{ env.VERSION }}
181+
- name: Create manifest list and push
182+
working-directory: ${{ runner.temp }}/digests
183+
run: |
184+
echo "$PUSH_TO_IMAGES" | xargs -I{} \
185+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
186+
$(printf '{}@sha256:%s ' *)
65187
stage3:
66188
name: Stage 3
67189
runs-on: ubuntu-latest
68-
needs: stage2
190+
needs: stage2-upload
69191
strategy:
70192
matrix:
71193
from: [ghcr.io/noahimesaka1873/base]
@@ -85,7 +207,8 @@ jobs:
85207
- name: Set up version
86208
run: |
87209
VERSION="$(echo "${{ github.ref }}" | cut -d / -f 3)"
88-
echo "tag=ghcr.io/noahimesaka1873/${{ matrix.target }}:$VERSION" >> "$GITHUB_ENV"
210+
echo "version=$VERSION" >> $GITHUB_ENV
211+
echo "tag=ghcr.io/noahimesaka1873/${{ matrix.target }}:$VERSION" >> $GITHUB_ENV
89212
- name: Set up Docker Buildx
90213
uses: docker/setup-buildx-action@v3
91214
- name: Build and push toolchain
@@ -98,4 +221,4 @@ jobs:
98221
cache-to: type=gha,mode=max
99222
build-args: |
100223
BUILDKIT_INLINE_CACHE=1
101-
FROM=${{ matrix.from }}:${{ env.tag }}
224+
FROM=${{ matrix.from }}:${{ env.version }}

0 commit comments

Comments
 (0)