Skip to content

Commit

Permalink
upload release binaries via script
Browse files Browse the repository at this point in the history
  • Loading branch information
rnbguy committed Oct 16, 2024
1 parent 688c30b commit 13ceae4
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 37 deletions.
77 changes: 77 additions & 0 deletions .github/upload-binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

set -euo pipefail

usage() {
echo "Usage: $0 [--final] <repository> <version>"
exit 1
}

DRY_RUN=true
REPO=""
VERSION=""

while [[ $# -gt 0 ]]; do
case "$1" in
--final)
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 [ "${GH_TOKEN:-}" = "" ]; then
GH_TOKEN=$(gh auth token)
fi

TARGETS=(
"x86_64-unknown-linux-gnu:linux-amd64"
"aarch64-apple-darwin:darwin-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."
45 changes: 8 additions & 37 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,51 +44,22 @@ jobs:
binaries:
needs: release
runs-on: ubuntu-latest
strategy:
matrix:
config:
[
{ target: "x86_64-unknown-linux-gnu", suffix: "linux-amd64" },
{ target: "aarch64-apple-darwin", suffix: "darwin-arm64" },
{ target: "x86_64-pc-windows-msvc", suffix: "pc-amd64.exe" },
]
defaults:
run:
working-directory: ./quint
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

# Deno can't compile local npm projects. Use the npm release from last step.
- name: Compile with Deno from NPM Release
- name: Wait for NPM
timeout-minutes: 30
run: |
VERSION="$(echo ${{ github.ref_name }} | sed 's/^v//')"
deno compile \
--allow-all \
--target "${{ matrix.config.target }}" \
--output "quint-${{ matrix.config.suffix }}" \
"npm:@informalsystems/quint@${VERSION}"
REF_NAME=${{ github.ref_name }}
while ! deno run -A "npm:@informalsystems/quint@${REF_NAME#v}" --version; do
sleep 30
done
- name: Test binary
- name: Upload assets
run: |
./quint-${{ matrix.config.suffix }} --version
- name: Generate SHA256 hash
run: |
sha256sum "quint-${{ matrix.config.suffix }}" > "quint-${{ matrix.config.suffix }}.sha256"
- name: Upload assets to Release
./workflows/upload-binaries.sh ${{ github.repository }} ${{ github.ref_name }} --final
env:
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/using-github-cli-in-workflows
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "${{ github.ref_name }}" \
"quint-${{ matrix.config.suffix }}" \
"quint-${{ matrix.config.suffix }}.sha256" \
--repo "${{ github.repository }}" \
--clobber

0 comments on commit 13ceae4

Please sign in to comment.