Skip to content

Commit

Permalink
Check that macOS universal binaries are for the same features
Browse files Browse the repository at this point in the history
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.)
  • Loading branch information
EliahKagan committed Aug 1, 2024
1 parent 082b5ae commit cf99eaa
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ jobs:
- x86_64-pc-windows-gnu
- i686-pc-windows-msvc
- aarch64-pc-windows-msvc
# When changing these features, make the same change in build-macos-universal2-release.
feature: [ small, lean, max, max-pure ]
include:
- target: x86_64-unknown-linux-musl
Expand Down Expand Up @@ -231,6 +232,7 @@ jobs:

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

env:
Expand All @@ -247,7 +249,7 @@ jobs:
- name: Obtain single-architecture releases
run: |
gh release --repo "$REPOSITORY" download "$VERSION" --pattern="$(name aarch64).tar.gz" --pattern="$(name x86_64).tar.gz"
gh release --repo="$REPOSITORY" download "$VERSION" --pattern="$(name aarch64).tar.gz" --pattern="$(name x86_64).tar.gz"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -274,6 +276,49 @@ jobs:
echo "ASSET=$(name universal).tar.gz" >> "$GITHUB_ENV"
- name: Upload release archive
run: gh release --repo "$REPOSITORY" upload "$VERSION" "$ASSET"
run: gh release --repo="$REPOSITORY" upload "$VERSION" "$ASSET"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# This checks and publishes the release on GitHub. It does not upload to crates.io.
publish-release:
name: publish-release

runs-on: ubuntu-latest

needs: [ create-release, build-release, build-macos-universal2-release ]

env:
REPOSITORY: ${{ github.repository }}
VERSION: ${{ needs.create-release.outputs.version }}

steps:
- name: Discover assets
run: |
gh release --repo="$REPOSITORY" view "$VERSION" --json assets --jq '.assets.[].name' > assets.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Show all asset names
run: cat assets.txt

# The `features` array is repeated because GHA doen't support YAML anchors.
# We will check that the macOS `universal` features match the others exactly.
# In the future this and the next step may be removed, or expanded to do more validation.
- name: Extract macOS asset names by architecture
run: |
for arch in aarch64 x86_64 universal; do
grep -Fw "$arch-apple-darwin" assets.txt | sort | tee -- "$arch.txt"
done
- name: Check macOS archive features
run: |
mask() { sed -r 's/\w+-apple-darwin/<arch>-apple-darwin/' -- "$1.txt"; }
diff -- <(mask aarch64) <(mask universal)
diff -- <(mask x86_64) <(mask universal)
- name: Publish the release
if: false
run: gh release --repo="$REPOSITORY" edit "$VERSION" --draft=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit cf99eaa

Please sign in to comment.