Skip to content

Commit 578ae04

Browse files
authored
Merge pull request #1529 from informalsystems/rano/precompiled-binaries
feat: include compiled binaries in releases
2 parents a3a5977 + 42b81e3 commit 578ae04

File tree

2 files changed

+140
-0
lines changed

2 files changed

+140
-0
lines changed

.github/upload-binaries.sh

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
usage() {
6+
echo "Usage: $0 [--publish] <repository> <version>"
7+
echo "Examples:"
8+
echo " $0 informalsystems/quint v0.22.2"
9+
echo " $0 --publish informalsystems/quint v0.22.2"
10+
exit 1
11+
}
12+
13+
DRY_RUN=true
14+
REPO=""
15+
VERSION=""
16+
17+
while [[ $# -gt 0 ]]; do
18+
case "$1" in
19+
--publish)
20+
DRY_RUN=false
21+
shift
22+
;;
23+
-h|--help)
24+
usage
25+
;;
26+
*)
27+
if [[ -z "$REPO" ]]; then
28+
REPO="$1"
29+
elif [[ -z "$VERSION" ]]; then
30+
VERSION="$1"
31+
else
32+
usage
33+
fi
34+
shift
35+
;;
36+
esac
37+
done
38+
39+
if [[ -z "$REPO" || -z "$VERSION" ]]; then
40+
usage
41+
fi
42+
43+
VERSION="${VERSION#v}"
44+
RELEASE_TAG="v$VERSION"
45+
46+
if [ "$DRY_RUN" == false ]; then
47+
if [ "${GH_TOKEN:-}" = "" ]; then
48+
GH_TOKEN=$(gh auth token 2>/dev/null || true)
49+
if [ "$GH_TOKEN" = "" ]; then
50+
echo "GitHub authentication token not found. Run 'gh auth login' to authenticate."
51+
exit 1
52+
fi
53+
fi
54+
fi
55+
56+
TARGETS=(
57+
"x86_64-unknown-linux-gnu:linux-amd64"
58+
"aarch64-unknown-linux-gnu:linux-arm64"
59+
"aarch64-apple-darwin:macos-arm64"
60+
"x86_64-apple-darwin:macos-amd64"
61+
"x86_64-pc-windows-msvc:pc-amd64.exe"
62+
)
63+
64+
for target_config in "${TARGETS[@]}"; do
65+
IFS=":" read -r TARGET SUFFIX <<< "$target_config"
66+
67+
echo "Compiling for target: $TARGET"
68+
deno compile \
69+
--allow-all \
70+
--node-modules-dir=auto \
71+
--allow-scripts \
72+
--target "$TARGET" \
73+
--output "quint-$SUFFIX" \
74+
"npm:@informalsystems/quint@$VERSION"
75+
76+
echo "Generating SHA256 hash for quint-$SUFFIX"
77+
sha256sum "quint-$SUFFIX" > "quint-$SUFFIX.sha256"
78+
79+
if [ "$DRY_RUN" == true ]; then
80+
echo "[dry run] gh release upload \"$RELEASE_TAG\" \"quint-$SUFFIX\" \"quint-$SUFFIX.sha256\" --repo \"$REPO\" --clobber"
81+
else
82+
gh release upload "$RELEASE_TAG" \
83+
"quint-$SUFFIX" \
84+
"quint-$SUFFIX.sha256" \
85+
--repo "$REPO" \
86+
--clobber
87+
fi
88+
done
89+
90+
echo "Release process complete."

.github/workflows/release.yml

+50
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,58 @@ jobs:
3535
uses: softprops/action-gh-release@v1
3636
with:
3737
body_path: ${{ github.workspace }}/release-notes.txt
38+
token: ${{ secrets.GITHUB_TOKEN }}
3839
- name: Publish
3940
# See https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-to-the-npm-registry
4041
run: npm publish
4142
env:
4243
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
arches:
45+
strategy:
46+
matrix:
47+
os:
48+
# linux-amd64
49+
- ubuntu-22.04
50+
# linux-arm64
51+
- ubuntu-22.04-arm
52+
# macos-arm64
53+
- macos-14
54+
# macos-intel
55+
- macos-13
56+
# pc-amd64
57+
- windows-2022
58+
needs: release
59+
runs-on: ${{ matrix.os }}
60+
steps:
61+
- name: Install Deno
62+
uses: denoland/setup-deno@v2
63+
with:
64+
deno-version: v2.x
65+
66+
- name: Wait for NPM
67+
timeout-minutes: 30
68+
env:
69+
REF_NAME: ${{ github.ref_name }}
70+
run: |
71+
while ! curl -s https://registry.npmjs.org/@informalsystems/quint | jq -er ".versions.\"${REF_NAME#v}\""; do
72+
echo "Waiting for NPM to publish version ${REF_NAME#v}..."
73+
sleep 30
74+
done
75+
76+
deno run --allow-all --node-modules-dir=auto --allow-scripts "npm:@informalsystems/quint@${REF_NAME#v}" --version
77+
binaries:
78+
needs: arches
79+
runs-on: ubuntu-latest
80+
steps:
81+
- name: Install Deno
82+
uses: denoland/setup-deno@v2
83+
with:
84+
deno-version: v2.x
85+
86+
- name: Upload assets
87+
env:
88+
GH_REPO: ${{ github.repository }}
89+
REF_NAME: ${{ github.ref_name }}
90+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
run: |
92+
./.github/upload-binaries.sh "$GH_REPO" "$REF_NAME" --publish

0 commit comments

Comments
 (0)