Nightly #52
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: | |
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@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Configure Git for committing | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
- name: Build xtasks | |
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: 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: Set Scarb version | |
run: cargo xtask set-scarb-version ${{ env.NIGHTLY_VERSION }} | |
- 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 ] | |
steps: | |
- uses: actions/checkout@v3 | |
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@v3 | |
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@v3 | |
- name: Delete nightly branch | |
run: | | |
git push origin -d ${{ needs.prepare.outputs.nightly_branch }} |