1515
1616permissions :
1717 contents : write
18+ packages : write
1819
1920concurrency :
2021 group : release-artifacts-${{ inputs.release_tag || github.ref_name }}
2122 cancel-in-progress : false
2223
2324jobs :
2425 build :
25- runs-on : depot-ubuntu-24.04-8
26+ name : Build ${{ matrix.arch }}
27+ runs-on : ${{ matrix.runner }}
2628 timeout-minutes : 360
29+ strategy :
30+ fail-fast : false
31+ matrix :
32+ include :
33+ - arch : x86_64
34+ docker_arch : amd64
35+ runner : depot-ubuntu-24.04-8
36+ - arch : aarch64
37+ docker_arch : arm64
38+ runner : depot-ubuntu-24.04-arm-8
2739 env :
2840 CCACHE_MAXSIZE : 8G
2941 CCACHE_BASEDIR : ${{ github.workspace }}
4355 date_stamp="$(printf '%s\n' "${RELEASE_TAG}" | sed -E 's/^v([0-9]{4})-([0-9]{2})-([0-9]{2})\.[0-9]{2}$/\1\2\3/')"
4456 echo "tag=${RELEASE_TAG}" >> "$GITHUB_OUTPUT"
4557 echo "date_stamp=${date_stamp}" >> "$GITHUB_OUTPUT"
58+ image_name="$(printf 'ghcr.io/%s\n' "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')"
59+ echo "image_name=${image_name}" >> "$GITHUB_OUTPUT"
4660
4761 - name : Checkout
4862 uses : actions/checkout@v4
@@ -59,10 +73,10 @@ jobs:
5973 uses : actions/cache@v4
6074 with :
6175 path : ${{ github.workspace }}/.ccache
62- key : ccache-${{ runner.os }}-release-${{ steps.tag.outputs.tag }}-${{ hashFiles('flake.nix', 'flake.lock', 'configure.py', 'CMakeLists.txt', 'cmake/**', '.gitmodules') }}
76+ key : ccache-${{ runner.os }}-${{ matrix.arch }}- release-${{ steps.tag.outputs.tag }}-${{ hashFiles('flake.nix', 'flake.lock', 'configure.py', 'CMakeLists.txt', 'cmake/**', '.gitmodules') }}
6377 restore-keys : |
64- ccache-${{ runner.os }}-release-${{ hashFiles('flake.nix', 'flake.lock', 'configure.py', 'CMakeLists.txt', 'cmake/**', '.gitmodules') }}-
65- ccache-${{ runner.os }}-release-
78+ ccache-${{ runner.os }}-${{ matrix.arch }}- release-${{ hashFiles('flake.nix', 'flake.lock', 'configure.py', 'CMakeLists.txt', 'cmake/**', '.gitmodules') }}-
79+ ccache-${{ runner.os }}-${{ matrix.arch }}- release-
6680
6781 - name : Configure ccache
6882 run : |
@@ -93,11 +107,85 @@ jobs:
93107 -name '*.changes' -o \
94108 -name '*.buildinfo' \
95109 \) -print -exec cp {} release-artifacts/ \;
96- shasum -a 256 release-artifacts/* > release-artifacts/checksums.txt
110+
111+ - name : Log in to GHCR
112+ uses : docker/login-action@v3
113+ with :
114+ registry : ghcr.io
115+ username : ${{ github.actor }}
116+ password : ${{ github.token }}
117+
118+ - name : Set up Docker Buildx
119+ uses : docker/setup-buildx-action@v3
120+
121+ - name : Build and push ${{ matrix.arch }} image
122+ uses : docker/build-push-action@v5
123+ with :
124+ context : .
125+ file : dist/docker/debian/Dockerfile.release
126+ platforms : linux/${{ matrix.docker_arch }}
127+ push : true
128+ build-args : |
129+ RELEASE=${{ steps.tag.outputs.tag }}
130+ tags : |
131+ ${{ steps.tag.outputs.image_name }}:${{ steps.tag.outputs.tag }}-${{ matrix.docker_arch }}
132+ labels : |
133+ org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
134+ org.opencontainers.image.revision=${{ github.sha }}
135+ org.opencontainers.image.version=${{ steps.tag.outputs.tag }}
136+
137+ - uses : actions/upload-artifact@v4
138+ with :
139+ name : ssdb-${{ steps.tag.outputs.tag }}-${{ matrix.arch }}-release-artifacts
140+ path : release-artifacts/
141+ if-no-files-found : error
142+
143+ - name : Show ccache stats
144+ if : always()
145+ run : nix develop .#cpp -c ccache --show-stats
146+
147+ publish :
148+ name : Publish release
149+ runs-on : ubuntu-latest
150+ needs : [build]
151+ steps :
152+ - name : Validate release tag
153+ id : tag
154+ env :
155+ RELEASE_TAG : ${{ inputs.release_tag || github.ref_name }}
156+ run : |
157+ if ! printf '%s\n' "${RELEASE_TAG}" | grep -Eq '^v[0-9]{4}-[0-9]{2}-[0-9]{2}\.[0-9]{2}$'; then
158+ echo "Release tag is not valid: ${RELEASE_TAG}"
159+ exit 1
160+ fi
161+
162+ image_name="$(printf 'ghcr.io/%s\n' "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')"
163+ echo "tag=${RELEASE_TAG}" >> "$GITHUB_OUTPUT"
164+ echo "image_name=${image_name}" >> "$GITHUB_OUTPUT"
165+
166+ - name : Checkout
167+ uses : actions/checkout@v4
168+ with :
169+ fetch-depth : 0
170+ ref : ${{ steps.tag.outputs.tag }}
171+
172+ - name : Download release artifacts
173+ uses : actions/download-artifact@v4
174+ with :
175+ pattern : ssdb-${{ steps.tag.outputs.tag }}-*-release-artifacts
176+ path : release-artifacts
177+ merge-multiple : true
178+
179+ - name : Write checksums
180+ run : |
181+ find release-artifacts -type f -print0 \
182+ | sort -z \
183+ | xargs -0 shasum -a 256 > release-artifacts/checksums.txt
97184
98185 - name : Write release notes
99186 env :
100187 RELEASE_TAG : ${{ steps.tag.outputs.tag }}
188+ IMAGE_NAME : ${{ steps.tag.outputs.image_name }}
101189 run : |
102190 changelog_version="${RELEASE_TAG#v}"
103191 awk -v version="## [${changelog_version}]" '
@@ -114,11 +202,35 @@ jobs:
114202 } > RELEASE_NOTES.md
115203 fi
116204
117- - uses : actions/upload-artifact@v4
205+ {
206+ echo
207+ echo "## Container Image"
208+ echo
209+ echo "- \`${IMAGE_NAME}:${RELEASE_TAG}\`"
210+ echo "- \`${IMAGE_NAME}:${RELEASE_TAG}-amd64\`"
211+ echo "- \`${IMAGE_NAME}:${RELEASE_TAG}-arm64\`"
212+ } >> RELEASE_NOTES.md
213+
214+ - name : Log in to GHCR
215+ uses : docker/login-action@v3
118216 with :
119- name : ssdb-${{ steps.tag.outputs.tag }}-release-artifacts
120- path : release-artifacts/
121- if-no-files-found : error
217+ registry : ghcr.io
218+ username : ${{ github.actor }}
219+ password : ${{ github.token }}
220+
221+ - name : Set up Docker Buildx
222+ uses : docker/setup-buildx-action@v3
223+
224+ - name : Publish multi-arch image tags
225+ env :
226+ IMAGE_NAME : ${{ steps.tag.outputs.image_name }}
227+ RELEASE_TAG : ${{ steps.tag.outputs.tag }}
228+ run : |
229+ docker buildx imagetools create \
230+ --tag "${IMAGE_NAME}:${RELEASE_TAG}" \
231+ --tag "${IMAGE_NAME}:latest" \
232+ "${IMAGE_NAME}:${RELEASE_TAG}-amd64" \
233+ "${IMAGE_NAME}:${RELEASE_TAG}-arm64"
122234
123235 - name : Publish GitHub release
124236 uses : softprops/action-gh-release@v2
@@ -127,7 +239,3 @@ jobs:
127239 body_path : RELEASE_NOTES.md
128240 files : release-artifacts/*
129241 fail_on_unmatched_files : true
130-
131- - name : Show ccache stats
132- if : always()
133- run : nix develop .#cpp -c ccache --show-stats
0 commit comments