Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: include compiled binaries in releases #1529

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
86 changes: 86 additions & 0 deletions .github/upload-binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/bash

set -euo pipefail

usage() {
echo "Usage: $0 [--publish] <repository> <version>"
echo "Examples:"
echo " $0 informalsystems/quint v0.22.2"
echo " $0 --publish informalsystems/quint v0.22.2"
exit 1
}

DRY_RUN=true
REPO=""
VERSION=""

while [[ $# -gt 0 ]]; do
case "$1" in
--publish)
DRY_RUN=false
shift
;;
-h|--help)
usage
;;
*)
if [[ -z "$REPO" ]]; then
REPO="$1"
elif [[ -z "$VERSION" ]]; then
VERSION="$1"
else
usage
fi
shift
;;
esac
done

if [[ -z "$REPO" || -z "$VERSION" ]]; then
usage
fi

VERSION="${VERSION#v}"
RELEASE_TAG="v$VERSION"

if [ "$DRY_RUN" == false ]; then
if [ "${GH_TOKEN:-}" = "" ]; then
GH_TOKEN=$(gh auth token 2>/dev/null || true)
if [ "$GH_TOKEN" = "" ]; then
echo "GitHub authentication token not found. Run 'gh auth login' to authenticate."
exit 1
fi
fi
fi

TARGETS=(
"x86_64-unknown-linux-gnu:linux-amd64"
"aarch64-apple-darwin:macos-arm64"
"x86_64-pc-windows-msvc:pc-amd64.exe"
)

for target_config in "${TARGETS[@]}"; do
IFS=":" read -r TARGET SUFFIX <<< "$target_config"

echo "Compiling for target: $TARGET"
deno compile \
--allow-all \
--target "$TARGET" \
--output "quint-$SUFFIX" \
"npm:@informalsystems/quint@$VERSION"

echo "Generating SHA256 hash for quint-$SUFFIX"
sha256sum "quint-$SUFFIX" > "quint-$SUFFIX.sha256"

if [ "$DRY_RUN" == true ]; then
echo "[dry run] gh release upload \"$RELEASE_TAG\" \"quint-$SUFFIX\" \"quint-$SUFFIX.sha256\" --repo \"$REPO\" --clobber"
else
gh release upload "$RELEASE_TAG" \
"quint-$SUFFIX" \
"quint-$SUFFIX.sha256" \
--repo "$REPO" \
--clobber
fi
done

echo "Release process complete."
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,31 @@ jobs:
uses: softprops/action-gh-release@v1
with:
body_path: ${{ github.workspace }}/release-notes.txt
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish
# See https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-to-the-npm-registry
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
binaries:
needs: release
runs-on: ubuntu-latest
steps:
- name: Install Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Wait for NPM
timeout-minutes: 30
run: |
REF_NAME=${{ github.ref_name }}
while ! deno run -A "npm:@informalsystems/quint@${REF_NAME#v}" --version; do
sleep 30
done

- name: Upload assets
run: |
./.github/upload-binaries.sh ${{ github.repository }} ${{ github.ref_name }} --publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading