diff --git a/.github/upload-binaries.sh b/.github/upload-binaries.sh new file mode 100755 index 000000000..25e2d7b7f --- /dev/null +++ b/.github/upload-binaries.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +set -euo pipefail + +usage() { + echo "Usage: $0 [--publish] " + 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." diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a2ca42a7b..cd50ed265 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 }}