Nightly #148
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Nightly | |
on: | |
workflow_dispatch: | |
inputs: | |
dry_run: | |
description: "Dry run" | |
type: boolean | |
default: true | |
schedule: | |
- cron: '0 0 * * 3,6' | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
permissions: | |
contents: write | |
jobs: | |
prepare: | |
runs-on: ubuntu-latest | |
outputs: | |
nightly_tag: ${{ steps.version.outputs.nightly_tag }} | |
nightly_version: ${{ steps.version.outputs.nightly_version }} | |
nightly_branch: ${{ steps.version.outputs.nightly_branch }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Configure Git for committing | |
run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
- name: Build xtasks | |
run: cargo build -p xtask | |
- name: Upgrade Cairo to latest main commit | |
run: cargo xtask set-cairo-version --rev $(git ls-remote --refs "https://github.com/starkware-libs/cairo" main | awk '{print $1}') | |
- name: Rebuild xtasks after Cargo.toml changes | |
run: cargo build -p xtask | |
- name: Determine nightly version | |
id: version | |
shell: bash | |
run: | | |
NIGHTLY_TAG=$(cargo xtask get-nightly-version --tag) | |
NIGHTLY_VERSION=$(cargo xtask get-nightly-version) | |
NIGHTLY_BRANCH="nightly/tmp/$NIGHTLY_TAG" | |
echo "NIGHTLY_TAG=$NIGHTLY_TAG" >> $GITHUB_ENV | |
echo "NIGHTLY_VERSION=$NIGHTLY_VERSION" >> $GITHUB_ENV | |
echo "NIGHTLY_BRANCH=$NIGHTLY_BRANCH" >> $GITHUB_ENV | |
echo "nightly_tag=$NIGHTLY_TAG" >> $GITHUB_OUTPUT | |
echo "nightly_version=$NIGHTLY_VERSION" >> $GITHUB_OUTPUT | |
echo "nightly_branch=$NIGHTLY_BRANCH" >> $GITHUB_OUTPUT | |
- name: Set Scarb version build metadata | |
run: cargo xtask set-scarb-version --build ${{ env.NIGHTLY_TAG }} --no-pre-release | |
- name: Rebuild xtasks after Cargo.toml changes | |
run: cargo build -p xtask | |
- name: Compose release notes | |
run: cargo xtask nightly-release-notes > NIGHTLY_RELEASE_NOTES.md | |
- name: Commit patches | |
run: | | |
git checkout -b ${{ env.NIGHTLY_BRANCH }} | |
git add . | |
git commit -m ${{ env.NIGHTLY_TAG }} | |
# NOTE: This must be the last operation done in this job in order for cleanup job to work properly. | |
- name: Push patches to the repository | |
run: git push origin ${{ env.NIGHTLY_BRANCH }} | |
check: | |
uses: ./.github/workflows/_check-release.yml | |
needs: prepare | |
with: | |
ref: ${{ needs.prepare.outputs.nightly_branch }} | |
fail-fast: false | |
release: | |
uses: ./.github/workflows/_build-release.yml | |
needs: prepare | |
with: | |
scarb-tag: v${{ needs.prepare.outputs.nightly_version }} | |
ref: ${{ needs.prepare.outputs.nightly_branch }} | |
upload: | |
runs-on: ubuntu-latest | |
needs: [ prepare, release ] | |
# Do not run on dry_run | |
if: ${{ !(inputs.dry_run) }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.prepare.outputs.nightly_branch }} | |
- name: Create source code archives | |
run: | | |
git archive "--prefix=scarb-${{ needs.prepare.outputs.nightly_tag }}/" -o "scarb-${{ needs.prepare.outputs.nightly_tag }}.zip" HEAD | |
git archive "--prefix=scarb-${{ needs.prepare.outputs.nightly_tag }}/" -o "scarb-${{ needs.prepare.outputs.nightly_tag }}.tar.gz" HEAD | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts-dl | |
- name: Unpack artifacts to staging directory | |
run: | | |
mkdir -p artifacts | |
mv artifacts-dl/build-*/scarb-* artifacts/ | |
mv artifacts-dl/checksums/* artifacts/ | |
ls -lh artifacts/ | |
- name: Create GitHub release | |
run: | | |
gh release create \ | |
"${{ needs.prepare.outputs.nightly_tag }}" \ | |
--repo software-mansion/scarb-nightlies \ | |
--latest \ | |
--title "${{ needs.prepare.outputs.nightly_tag }}" \ | |
--notes-file NIGHTLY_RELEASE_NOTES.md | |
env: | |
GH_TOKEN: ${{ secrets.SCARB_NIGHTLIES_CONTENTS_WRITE }} | |
- name: Upload release assets | |
run: | | |
for file in \ | |
./artifacts/* \ | |
"scarb-${{ needs.prepare.outputs.nightly_tag }}.zip#Scarb source code (zip)" \ | |
"scarb-${{ needs.prepare.outputs.nightly_tag }}.tar.gz#Scarb source code (tar.gz)" | |
do | |
# If there isn't # in name, it means that it is a build artifact | |
# and we need to remove version tag from the name, so it can be | |
# easily accessed in asdf and Scarb installation scripts | |
# | |
# for example: | |
# scarb-v0.6.0+nightly-2023-08-09-aarch64-apple-darwin.tar.gz | |
# becomes | |
# scarb-nightly-2023-08-09-aarch64-apple-darwin.tar.gz | |
if ! [[ $(grep "#" <<< $file) ]]; then | |
label=$(echo $file | sed -E "s/v[^+]*\+//" | sed -E "s/.\/artifacts\///") | |
cp "$file" "$label" | |
file="$label" | |
fi | |
gh release upload \ | |
"${{ needs.prepare.outputs.nightly_tag }}" \ | |
"$file" \ | |
--repo software-mansion/scarb-nightlies | |
done | |
env: | |
GH_TOKEN: ${{ secrets.SCARB_NIGHTLIES_CONTENTS_WRITE }} | |
cleanup: | |
runs-on: ubuntu-latest | |
if: always() && needs.prepare.result == 'success' | |
needs: [ prepare, upload ] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Delete nightly branch | |
run: | | |
git push origin -d ${{ needs.prepare.outputs.nightly_branch }} | |
notify_failed: | |
runs-on: ubuntu-latest | |
# Do not run on dry_run or success | |
if: always() && !(inputs.dry_run) && contains(needs.*.result, 'failure') | |
needs: [ cleanup, upload, release, prepare ] | |
steps: | |
- name: Notifying about Nightly fail! | |
uses: slackapi/slack-github-action@v1.24.0 | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NIGHTLY_FAILURE_WEBHOOK_URL }} | |
with: | |
payload: | | |
{ | |
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
} | |
notify_failed_check: | |
runs-on: ubuntu-latest | |
# Do not run on dry_run, check success or if we have already notified | |
if: always() && !(inputs.dry_run) && needs.check.result == 'failure' && needs.notify_failed.result == 'skipped' | |
needs: [ check, notify_failed ] | |
steps: | |
- name: Notifying about check fail! | |
uses: slackapi/slack-github-action@v1.24.0 | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NIGHTLY_CHECK_FAILURE_WEBHOOK_URL }} | |
with: | |
payload: | | |
{ | |
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
} |