Skip to content

Commit 314de7a

Browse files
committed
Check that macOS universal binaries are for the same features
As commented, this should catch if the features lists get out of sync. (It may catch other problems too, but without this issue, the check is likely not justified. Printing the list of artifacts at the time publishing is about to occur may still be justified in that case, though.)
1 parent 0d8f1c4 commit 314de7a

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

.github/workflows/release.yml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ jobs:
8888
- x86_64-pc-windows-gnu
8989
- i686-pc-windows-msvc
9090
- aarch64-pc-windows-msvc
91+
# When changing these features, make the same change in build-macos-universal2-release.
9192
feature: [ small, lean, max, max-pure ]
9293
include:
9394
- target: x86_64-unknown-linux-musl
@@ -231,6 +232,7 @@ jobs:
231232

232233
strategy:
233234
matrix:
235+
# These features need to be exactly the same as the features in build-release.
234236
feature: [ small, lean, max, max-pure ]
235237

236238
env:
@@ -247,7 +249,7 @@ jobs:
247249
248250
- name: Obtain single-architecture releases
249251
run: |
250-
gh release --repo "$REPOSITORY" download "$VERSION" --pattern="$(name aarch64).tar.gz" --pattern="$(name x86_64).tar.gz"
252+
gh release --repo="$REPOSITORY" download "$VERSION" --pattern="$(name aarch64).tar.gz" --pattern="$(name x86_64).tar.gz"
251253
env:
252254
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
253255

@@ -274,6 +276,49 @@ jobs:
274276
echo "ASSET=$(name universal).tar.gz" >> "$GITHUB_ENV"
275277
276278
- name: Upload release archive
277-
run: gh release --repo "$REPOSITORY" upload "$VERSION" "$ASSET"
279+
run: gh release --repo="$REPOSITORY" upload "$VERSION" "$ASSET"
280+
env:
281+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
282+
283+
# This checks and publishes the release on GitHub. It does not upload to crates.io.
284+
publish-release:
285+
name: publish-release
286+
287+
runs-on: ubuntu-latest
288+
289+
needs: [ create-release, build-release, build-macos-universal2-release ]
290+
291+
env:
292+
REPOSITORY: ${{ github.repository }}
293+
VERSION: ${{ needs.create-release.outputs.version }}
294+
295+
steps:
296+
- name: Discover assets
297+
run: |
298+
gh release --repo="$REPOSITORY" view "$VERSION" --json assets --jq '.assets.[].name' > assets.txt
299+
env:
300+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
301+
302+
- name: Show all asset names
303+
run: cat assets.txt
304+
305+
# The `features` array is repeated because GHA doen't support YAML anchors.
306+
# We will check that the macOS `universal` features match the others exactly.
307+
# In the future this and the next step may be removed, or expanded to do more validation.
308+
- name: Extract macOS asset names by architecture
309+
run: |
310+
for arch in aarch64 x86_64 universal; do
311+
grep -Fw "$arch-apple-darwin" assets.txt | sort | tee -- "$arch.txt"
312+
done
313+
314+
- name: Check macOS archive features
315+
run: |
316+
mask() { sed -r 's/\w+-apple-darwin/<arch>-apple-darwin/' -- "$1.txt"; }
317+
diff -- <(mask aarch64) <(mask universal)
318+
diff -- <(mask x86_64) <(mask universal)
319+
320+
- name: Publish the release
321+
if: false
322+
run: gh release --repo="$REPOSITORY" edit "$VERSION" --draft=false
278323
env:
279324
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)