Skip to content

Commit

Permalink
nightly.yml: Nightly build and upload releases to separate repo
Browse files Browse the repository at this point in the history
  • Loading branch information
mtzguido committed Jan 8, 2025
1 parent f1f0a2c commit 628065a
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 10 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: F* nightly build

# For this to work, there must a repo called FStar-nightly
# in the same org as FStar, and a DZOMO_GITHUB_TOKEN secret configured
# in the FStar repo that has write access to FStar-nightly (i.e. 'Contents'
# permission), *AND* also workflow access (or you'll get "Refusing to
# allow a Personal Access Token to create or update workflow").
#
# The default GITHUB_TOKEN only allows access to the current repo, so it's
# not useful.

on:
push:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:

jobs:
build-all:
uses: ./.github/workflows/build-all.yml

publish:
runs-on: ubuntu-latest
needs: build-all
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0 # full clone, so we can push objects

- name: Set up git
run: |
git config --global user.name "Dzomo, the Everest Yak"
git config --global user.email "[email protected]"
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
# ^ Download all artifacts into the same dir.
# Each of them is a single file, so no clashes happen.

- name: Publish artifacts in nightly tag
run: |
git config --unset-all http.https://github.com/.extraheader
# ^ https://stackoverflow.com/questions/64374179/how-to-push-to-another-repository-in-github-actions
# We push nightly builds to a different repo (same org)
REPO="${{github.repository}}-nightly"
TAG=nightly-$(date -I)
# Create tag
git tag $TAG ${{github.sha}}
# Add new remote and push tag
git remote add nightly-repo https://${{secrets.DZOMO_GITHUB_TOKEN}}@github.com/$REPO
git push nightly-repo $TAG
# Create release
gh release create -R "$REPO" \
--generate-notes \
--target ${{ github.sha }} \
$TAG artifacts/*
env:
GH_TOKEN: ${{ secrets.DZOMO_GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ jobs:
--generate-notes \
--target ${{ github.sha }} \
-t "F* v$V" \
"v$V" ../artifacts/fstar-*
"v$V" ../artifacts/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/_srcpak*
_build
# ^ build output
/nightly
/bin/fstar.exe
/bin/get_fstar_z3.sh

Expand Down
24 changes: 15 additions & 9 deletions .scripts/setup_nightly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@

set -euo pipefail

NIGHTLY_REPO=FStarLang/FStar-nightly
NIGHTLY_REPO_URL=https://api.github.com/repos/$NIGHTLY_REPO/releases/latest

kernel="$(uname -s)"
case "$kernel" in
CYGWIN*) kernel=Windows ;;
esac

arch="$(uname -m)"
case "$arch" in
arm64) arch=aarch64 ;;
esac

URL="https://github.com/FStarLang/FStar/releases/download/nightly/fstar-$kernel-$arch.tar.gz"
FILE="$(basename "$URL")"
# Get info about latest release
LATEST_CURL=$(curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" $NIGHTLY_REPO_URL)

# Find the asset that seems to match our architecture and OS
ASSET=$(echo "$LATEST_CURL" | jq -r '.assets[] | select(.name | contains("'$kernel'-'$arch'")) | .browser_download_url')

FILE="$(basename "$ASSET")"

# Get artifact
wget "$URL" -O "$FILE"
wget "$ASSET" -O "$FILE"

# Warn if too old (over 48 hours)
S_NOW=$(date +%s)
Expand All @@ -27,9 +32,10 @@ if [[ $((S_NOW - S_FILE)) -gt $((48 * 60 * 60)) ]]; then
fi

# Untar
rm -rf out
mkdir out
tar xzf "$FILE" -C out
rm -rf nightly
mkdir nightly
tar xzf "$FILE" -C nightly
ln -Trsf nightly/fstar out
rm "$FILE"

echo Done.

0 comments on commit 628065a

Please sign in to comment.