Skip to content

Commit 62ab8a5

Browse files
committed
ci: export unique arch list generated
1 parent f8a096a commit 62ab8a5

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

.github/workflows/release.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
runs-on: ubuntu-latest
5959
outputs:
6060
matrix: ${{ steps.generate-matrix.outputs.matrix }}
61+
arch_list: ${{ steps.generate-arch-list.outputs.arch_list }}
6162
steps:
6263
- uses: actions/checkout@v4
6364

@@ -77,7 +78,12 @@ jobs:
7778
echo "$MATRIX"
7879
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
7980
80-
ARCH_LIST=$(echo "$MATRIX" | jq -r '.[].arch' | jq -R -s -c 'split("\n") | map(select(. != ""))')
81+
- name: Generate Arch List
82+
id: generate-arch-list
83+
run: |
84+
ARCH_LIST=$(nix run .#archs --quiet)
85+
echo "Generated Archs:"
86+
echo "$ARCH_LIST"
8187
echo "arch_list=$ARCH_LIST" >> $GITHUB_OUTPUT
8288
8389
build:
@@ -173,7 +179,7 @@ jobs:
173179
strategy:
174180
fail-fast: false
175181
matrix:
176-
include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
182+
include: ${{ fromJson(needs.generate-matrix.outputs.arch_list) }}
177183
steps:
178184
- uses: actions/checkout@v4
179185
- name: Set Repository Lowercase
@@ -193,16 +199,12 @@ jobs:
193199
docker load < ./result
194200
docker tag grhooks:${{ env.VERSION }} ghcr.io/${{ env.REPOSITORY }}/grhooks:${{ matrix.arch }}
195201
196-
- name: Create and push unified manifest
197-
run: |
198-
docker manifest create ghcr.io/${{ env.REPOSITORY }}/grhooks:${{ env.VERSION }} \
199-
--amend ghcr.io/${{ env.REPOSITORY }}/grhooks:${{ matrix.arch }}
200-
201202
docker-publish:
202203
runs-on: ubuntu-latest
203204
needs: [setup, generate-matrix, docker-build]
204205
env:
205206
VERSION: ${{ needs.setup.outputs.version }}
207+
ARCHS: ${{ needs.generate-matrix.outputs.arch_list }}
206208
steps:
207209
- name: Log in to GHCR
208210
uses: docker/login-action@v3
@@ -216,12 +218,11 @@ jobs:
216218
- name: Create and push manifest
217219
run: |
218220
IMAGE=ghcr.io/${{ env.REPOSITORY }}/grhooks:${{ env.VERSION }}
219-
ARCHS='${{ needs.generate-matrix.outputs.arch_list }}'
220221
221222
echo "Creating manifest for architectures: $ARCHS"
222223
223224
manifest_args=""
224-
for arch in $(echo "$ARCHS" | jq -r '.[]'); do
225+
for arch in $(echo "$ARCHS" | jq -r '.[].arch'); do
225226
manifest_args="$manifest_args --amend ghcr.io/${{ env.REPOSITORY }}/grhooks:$arch"
226227
done
227228

flake.nix

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@
108108
else ".#toTarball";
109109
}) formats
110110
) architectures));
111+
112+
archList = uniqueBy (i: i.arch) architectures;
113+
generatedArchJson = builtins.toJSON archList;
111114
in
112115
{
113116
devShells = lib.listToAttrs (map ({ arch, os, target, ... }: {
@@ -128,9 +131,7 @@
128131
}) architectures)) // (pkgs.lib.listToAttrs (map ({arch, ...} @ args: {
129132
name = "image-${arch}";
130133
value = containerPkg args;
131-
})
132-
(uniqueBy (i: i.arch) architectures)
133-
));
134+
}) archList));
134135

135136
apps = {
136137
help = {
@@ -163,6 +164,14 @@
163164
echo '${generatedMatrixJson}'
164165
'');
165166
};
167+
168+
archs = {
169+
type = "app";
170+
program = toString (pkgs.writeScript "generate-arch-list" ''
171+
#!/bin/sh
172+
echo '${generatedArchJson}'
173+
'');
174+
};
166175
};
167176

168177
bundlers = let

0 commit comments

Comments
 (0)