135377bd3SAlex Crichton# The purpose of this workflow is to orchestrate Wasmtime's release process as 235377bd3SAlex Crichton# much as possible. This specific workflow is responsible for a few timed parts 335377bd3SAlex Crichton# of the process: 4c89dc551SAlex Crichton# 535377bd3SAlex Crichton# * On the 5th of every month a new release branch is automatically created and 635377bd3SAlex Crichton# the version number of the `main` branch is increased 735377bd3SAlex Crichton# * On the 20th of every month the previous release branch is published. 835377bd3SAlex Crichton# 935377bd3SAlex Crichton# This automation is all done through PRs except for the creation of the release 1035377bd3SAlex Crichton# branch itself which is an write-action performed by this script. Otherwise 1135377bd3SAlex Crichton# humans are ideally reviewing and rubber-stamping the output of the script all 1235377bd3SAlex Crichton# other steps of the way. 1335377bd3SAlex Crichton# 1435377bd3SAlex Crichton# Note that this script also helps manage patch releases by sending a PR to the 1535377bd3SAlex Crichton# release branch with a bumped version number for all crates with a patch-bump. 16c89dc551SAlex Crichton 17c89dc551SAlex Crichtonname: "Automated Release Process" 18c89dc551SAlex Crichtonon: 19c89dc551SAlex Crichton schedule: 20c89dc551SAlex Crichton # “At 00:00 on day-of-month 5.” 21c89dc551SAlex Crichton # 22c89dc551SAlex Crichton # https://crontab.guru/#0_0_5_*_* 23c89dc551SAlex Crichton - cron: '0 0 5 * *' 24c89dc551SAlex Crichton - cron: '0 0 20 * *' 25c89dc551SAlex Crichton 26c89dc551SAlex Crichton # Allow manually triggering this request via the button at 2735377bd3SAlex Crichton # https://github.com/bytecodealliance/wasmtime/actions/workflows/release-process.yml 28c89dc551SAlex Crichton workflow_dispatch: 29c89dc551SAlex Crichton inputs: 30c89dc551SAlex Crichton action: 31c89dc551SAlex Crichton description: 'Publish script argument: "cut", "release-latest", or "release-patch"' 32c89dc551SAlex Crichton required: false 33c89dc551SAlex Crichton default: 'cut' 34c89dc551SAlex Crichton 35df89aa5bSAlex Crichtonpermissions: 36df89aa5bSAlex Crichton contents: write 37df89aa5bSAlex Crichton 38c89dc551SAlex Crichtonjobs: 39c89dc551SAlex Crichton release_process: 401efee4abSAlex Crichton if: "github.repository == 'bytecodealliance/wasmtime' || !github.event.schedule" 41c89dc551SAlex Crichton name: Run the release process 42c89dc551SAlex Crichton runs-on: ubuntu-latest 43c89dc551SAlex Crichton steps: 44*7cca98e5SAlex Crichton - uses: actions/checkout@v6 45c89dc551SAlex Crichton with: 46c89dc551SAlex Crichton submodules: true 47c89dc551SAlex Crichton - name: Setup 48c89dc551SAlex Crichton run: | 49c89dc551SAlex Crichton rustc scripts/publish.rs 50c89dc551SAlex Crichton git config user.name 'Wasmtime Publish' 51c89dc551SAlex Crichton git config user.email '[email protected]' 52c89dc551SAlex Crichton git remote set-url origin https://git:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/${{ github.repository }} 53c89dc551SAlex Crichton 54860d46b4SAlex Crichton - uses: ./.github/actions/install-rust 55860d46b4SAlex Crichton - uses: ./.github/actions/install-cargo-vet 56860d46b4SAlex Crichton 57c89dc551SAlex Crichton - name: Bump major version number 58c89dc551SAlex Crichton run: | 59bea0433bSAlex Crichton set -ex 60c89dc551SAlex Crichton # Push the current contents of `main` to a new release branch 61c89dc551SAlex Crichton cur=$(./ci/print-current-version.sh) 62c89dc551SAlex Crichton git push origin HEAD:release-$cur 63c89dc551SAlex Crichton 64c89dc551SAlex Crichton # Update version numbers and make a commit indicating that. Note that 65c89dc551SAlex Crichton # on merge this will not trigger a publish. 66c89dc551SAlex Crichton ./publish bump 67c89dc551SAlex Crichton num=$(./ci/print-current-version.sh) 68c89dc551SAlex Crichton 6914226457SAlex Crichton # Remove all release notes for the current version now that the 7014226457SAlex Crichton # release branch has been created. Additionally add an entry in the 7114226457SAlex Crichton # list of all versions pointing to the release notes on the newly 7214226457SAlex Crichton # created branch. 7314226457SAlex Crichton sed -i '0,/-----------/d' RELEASES.md 7414226457SAlex Crichton version_with_trailing_x=$(echo $cur | sed 's/.$/x/') 7514226457SAlex Crichton sed -i "/ARCHIVE_START/a * [$version_with_trailing_x](https://github.com/${{ github.repository }}/blob/release-$cur/RELEASES.md)" RELEASES.md 7614226457SAlex Crichton 7714226457SAlex Crichton # Use `RELEASES-template.md` as the new release notes and then append 7814226457SAlex Crichton # the archive of all historical releases to the end of it. 79c89dc551SAlex Crichton cp RELEASES.md backup-releases 80c89dc551SAlex Crichton sed "s/VERSION/$num/" ci/RELEASES-template.md > RELEASES.md 81c89dc551SAlex Crichton cat backup-releases >> RELEASES.md 82c89dc551SAlex Crichton rm backup-releases 83c89dc551SAlex Crichton 84860d46b4SAlex Crichton # Update `cargo vet` entries for all the new crate versions 85860d46b4SAlex Crichton cargo vet 86860d46b4SAlex Crichton 87c89dc551SAlex Crichton # Commit all of the above changes. 88c89dc551SAlex Crichton git commit -am "Bump Wasmtime to $num" 89c89dc551SAlex Crichton 90c89dc551SAlex Crichton # Push the result to a branch and setup metadata for the step below 91c89dc551SAlex Crichton # that creates a PR 92c89dc551SAlex Crichton git push origin HEAD:ci/bump-to-$num 93c89dc551SAlex Crichton echo "PR_HEAD=ci/bump-to-$num" >> $GITHUB_ENV 94c89dc551SAlex Crichton echo "PR_TITLE=Bump Wasmtime to $num" >> $GITHUB_ENV 95c89dc551SAlex Crichton echo "PR_BASE=main" >> $GITHUB_ENV 96c89dc551SAlex Crichton cat > pr-body <<-EOF 97f3d31342SSebastiaan Speck This is an [automated pull request][process] from CI which indicates that the next [\`release-$cur\` branch][branch] has been created and the \`main\` branch is getting its version number bumped from $cur to $num. 98c89dc551SAlex Crichton 9914226457SAlex Crichton Maintainers should take a moment to review the [release notes][RELEASES.md] for $cur and any updates should be made directly to the [release branch][branch]. 10076f7cde6SBailey Hayes 101f3d31342SSebastiaan Speck Another automated PR will be made in roughly 2 weeks time when for the actual release itself. 102c89dc551SAlex Crichton 103f3d31342SSebastiaan Speck If any issues arise on the \`main\` branch before the release is made then the issue should first be fixed on \`main\` and then backport to the \`release-$cur\` branch. 104c89dc551SAlex Crichton 10514226457SAlex Crichton [RELEASES.md]: https://github.com/${{ github.repository }}/blob/release-$cur/RELEASES.md 106c89dc551SAlex Crichton [branch]: https://github.com/${{ github.repository }}/tree/release-$cur 107c89dc551SAlex Crichton [process]: https://docs.wasmtime.dev/contributing-release-process.html 108c89dc551SAlex Crichton EOF 109c89dc551SAlex Crichton if: >- 110c89dc551SAlex Crichton github.event.schedule == '0 0 5 * *' || 111c89dc551SAlex Crichton github.event.inputs.action == 'cut' 112c89dc551SAlex Crichton 113c89dc551SAlex Crichton - name: Perform latest release 114c89dc551SAlex Crichton run: | 115bea0433bSAlex Crichton set -ex 116c89dc551SAlex Crichton git fetch origin 117c89dc551SAlex Crichton 118bea0433bSAlex Crichton # Determine the latest release branch 119bea0433bSAlex Crichton rustc ci/find-latest-release.rs -o /tmp/find-latest-release 120bea0433bSAlex Crichton cur=`/tmp/find-latest-release` 121bea0433bSAlex Crichton 122c89dc551SAlex Crichton # Move to the most recent release branch, update the release date and 123c89dc551SAlex Crichton # commit it, indicating that the commit is what will get tagged and 124c89dc551SAlex Crichton # released 125c89dc551SAlex Crichton git reset --hard origin/release-$cur 12615b2c90bSAlex Crichton git submodule update --init --recursive 127c89dc551SAlex Crichton sed -i "s/^Unreleased/Released $(date +'%Y-%m-%d')/" RELEASES.md 12863c9e5d4SAlex Crichton git commit --allow-empty -a -F-<<EOF 129c89dc551SAlex Crichton Release Wasmtime $cur 130c89dc551SAlex Crichton 131c89dc551SAlex Crichton [automatically-tag-and-release-this-commit] 132c89dc551SAlex Crichton EOF 133c89dc551SAlex Crichton 134c89dc551SAlex Crichton # Push the result to a branch and setup metadata for the step below 135c89dc551SAlex Crichton # that creates a PR 136c89dc551SAlex Crichton git push origin HEAD:ci/release-$cur 137c89dc551SAlex Crichton echo "PR_HEAD=ci/release-$cur" >> $GITHUB_ENV 138c89dc551SAlex Crichton echo "PR_TITLE=Release Wasmtime $cur" >> $GITHUB_ENV 139c89dc551SAlex Crichton echo "PR_BASE=release-$cur" >> $GITHUB_ENV 140c89dc551SAlex Crichton cat > pr-body <<-EOF 141f3d31342SSebastiaan Speck This is an [automated pull request][process] from CI which is intended to notify maintainers that it's time to release Wasmtime $cur. The [release branch][branch] was created roughly two weeks ago and it's now time for it to be published and released. 142c89dc551SAlex Crichton 143f3d31342SSebastiaan Speck It's recommended that maintainers double-check that [RELEASES.md] is up-to-date and that there are no known issues before merging this PR. When this PR is merged a release tag will automatically created, crates will be published, and CI artifacts will be produced. 144c89dc551SAlex Crichton 14514226457SAlex Crichton [RELEASES.md]: https://github.com/${{ github.repository }}/blob/release-$cur/RELEASES.md 146c89dc551SAlex Crichton [process]: https://docs.wasmtime.dev/contributing-release-process.html 147c89dc551SAlex Crichton [branch]: https://github.com/${{ github.repository }}/tree/release-$cur 148c89dc551SAlex Crichton EOF 149c89dc551SAlex Crichton if: >- 150c89dc551SAlex Crichton github.event.schedule == '0 0 20 * *' || 151c89dc551SAlex Crichton github.event.inputs.action == 'release-latest' 152c89dc551SAlex Crichton 153c89dc551SAlex Crichton - name: Bump and release patch version number 154c89dc551SAlex Crichton run: | 155bea0433bSAlex Crichton set -ex 156c89dc551SAlex Crichton # Update version numbers on a patch basis and update RELEASES.md if a 157c89dc551SAlex Crichton # patch release marker is already in there. Note that this commit 158c89dc551SAlex Crichton # message indicates that on-merge a release will be made. 159c89dc551SAlex Crichton ./publish bump-patch 160c6201624SAlex Crichton # Update `cargo vet` entries for all the new crate versions 161c6201624SAlex Crichton cargo vet 162c89dc551SAlex Crichton sed -i "s/^Unreleased/Released $(date +'%Y-%m-%d')/" RELEASES.md 163c89dc551SAlex Crichton num=$(./ci/print-current-version.sh) 164c89dc551SAlex Crichton git commit -a -F-<<EOF 165c89dc551SAlex Crichton Release Wasmtime $num 166c89dc551SAlex Crichton 167c89dc551SAlex Crichton [automatically-tag-and-release-this-commit] 168c89dc551SAlex Crichton EOF 169c89dc551SAlex Crichton 170c89dc551SAlex Crichton # Push the result to a branch and setup metadata for the step below 171c89dc551SAlex Crichton # that creates a PR 172c89dc551SAlex Crichton git push origin HEAD:ci/bump-to-$num 173c89dc551SAlex Crichton echo "PR_HEAD=ci/bump-to-$num" >> $GITHUB_ENV 174c89dc551SAlex Crichton echo "PR_TITLE=Release Wasmtime $num" >> $GITHUB_ENV 175c89dc551SAlex Crichton echo "PR_BASE=${{ github.ref_name }}" >> $GITHUB_ENV 176c89dc551SAlex Crichton cat > pr-body <<-EOF 177f3d31342SSebastiaan Speck This is an [automated pull request][process] from CI to create a patch release for Wasmtime $num, requested by @${{ github.actor }}. 178c89dc551SAlex Crichton 179f3d31342SSebastiaan Speck It's recommended that maintainers double-check that [RELEASES.md] is up-to-date and that there are no known issues before merging this PR. When this PR is merged a release tag will automatically be created, crates will be published, and CI artifacts will be produced. 180c89dc551SAlex Crichton 18114226457SAlex Crichton [RELEASES.md]: https://github.com/${{ github.repository }}/blob/release-$num/RELEASES.md 182c89dc551SAlex Crichton [process]: https://docs.wasmtime.dev/contributing-release-process.html 183c89dc551SAlex Crichton EOF 184c89dc551SAlex Crichton 185c89dc551SAlex Crichton if: github.event.inputs.action == 'release-patch' 186c89dc551SAlex Crichton 187c89dc551SAlex Crichton - name: Make a PR 188c89dc551SAlex Crichton # Note that the syntax here is kinda funky, and the general gist is that 189c89dc551SAlex Crichton # I couldn't figure out a good way to have a multiline string-literal 190c89dc551SAlex Crichton # become a json-encoded string literal to send to GitHub. This 191c89dc551SAlex Crichton # represents my best attempt. 192c89dc551SAlex Crichton run: | 193bea0433bSAlex Crichton set -ex 194c89dc551SAlex Crichton body=$(jq -sR < ./pr-body) 195c89dc551SAlex Crichton 196c89dc551SAlex Crichton curl --include --request POST \ 197c89dc551SAlex Crichton https://api.github.com/repos/${{ github.repository }}/pulls \ 198c89dc551SAlex Crichton --header "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \ 199c89dc551SAlex Crichton --data @- << EOF 200c89dc551SAlex Crichton { 201c89dc551SAlex Crichton "head": "$PR_HEAD", 202c89dc551SAlex Crichton "base": "$PR_BASE", 203c89dc551SAlex Crichton "title": "$PR_TITLE", 204c89dc551SAlex Crichton "body": $body, 205c89dc551SAlex Crichton "maintainer_can_modify": true 206c89dc551SAlex Crichton 207c89dc551SAlex Crichton } 208c89dc551SAlex Crichton EOF 209