-
Notifications
You must be signed in to change notification settings - Fork 1.3k
208 lines (176 loc) · 9.3 KB
/
release-process.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# The purpose of this workflow is to orchestrate Wasmtime's release process as
# much as possible. This specific workflow is responsible for a few timed parts
# of the process:
#
# * On the 5th of every month a new release branch is automatically created and
# the version number of the `main` branch is increased
# * On the 20th of every month the previous release branch is published.
#
# This automation is all done through PRs except for the creation of the release
# branch itself which is an write-action performed by this script. Otherwise
# humans are ideally reviewing and rubber-stamping the output of the script all
# other steps of the way.
#
# Note that this script also helps manage patch releases by sending a PR to the
# release branch with a bumped version number for all crates with a patch-bump.
name: "Automated Release Process"
on:
schedule:
# “At 00:00 on day-of-month 5.”
#
# https://crontab.guru/#0_0_5_*_*
- cron: '0 0 5 * *'
- cron: '0 0 20 * *'
# Allow manually triggering this request via the button at
# https://github.com/bytecodealliance/wasmtime/actions/workflows/release-process.yml
workflow_dispatch:
inputs:
action:
description: 'Publish script argument: "cut", "release-latest", or "release-patch"'
required: false
default: 'cut'
permissions:
contents: write
jobs:
release_process:
if: "github.repository == 'bytecodealliance/wasmtime' || !github.event.schedule"
name: Run the release process
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Setup
run: |
rustc scripts/publish.rs
git config user.name 'Wasmtime Publish'
git config user.email '[email protected]'
git remote set-url origin https://git:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/${{ github.repository }}
- uses: ./.github/actions/install-rust
- uses: ./.github/actions/install-cargo-vet
- name: Bump major version number
run: |
set -ex
# Push the current contents of `main` to a new release branch
cur=$(./ci/print-current-version.sh)
git push origin HEAD:release-$cur
# Update version numbers and make a commit indicating that. Note that
# on merge this will not trigger a publish.
./publish bump
num=$(./ci/print-current-version.sh)
# Remove all release notes for the current version now that the
# release branch has been created. Additionally add an entry in the
# list of all versions pointing to the release notes on the newly
# created branch.
sed -i '0,/-----------/d' RELEASES.md
version_with_trailing_x=$(echo $cur | sed 's/.$/x/')
sed -i "/ARCHIVE_START/a * [$version_with_trailing_x](https://github.com/${{ github.repository }}/blob/release-$cur/RELEASES.md)" RELEASES.md
# Use `RELEASES-template.md` as the new release notes and then append
# the archive of all historical releases to the end of it.
cp RELEASES.md backup-releases
sed "s/VERSION/$num/" ci/RELEASES-template.md > RELEASES.md
cat backup-releases >> RELEASES.md
rm backup-releases
# Update `cargo vet` entries for all the new crate versions
cargo vet
# Commit all of the above changes.
git commit -am "Bump Wasmtime to $num"
# Push the result to a branch and setup metadata for the step below
# that creates a PR
git push origin HEAD:ci/bump-to-$num
echo "PR_HEAD=ci/bump-to-$num" >> $GITHUB_ENV
echo "PR_TITLE=Bump Wasmtime to $num" >> $GITHUB_ENV
echo "PR_BASE=main" >> $GITHUB_ENV
cat > pr-body <<-EOF
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.
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].
Another automated PR will be made in roughly 2 weeks time when for the actual release itself.
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.
[RELEASES.md]: https://github.com/${{ github.repository }}/blob/release-$cur/RELEASES.md
[branch]: https://github.com/${{ github.repository }}/tree/release-$cur
[process]: https://docs.wasmtime.dev/contributing-release-process.html
EOF
if: >-
github.event.schedule == '0 0 5 * *' ||
github.event.inputs.action == 'cut'
- name: Perform latest release
run: |
set -ex
git fetch origin
# Determine the latest release branch
rustc ci/find-latest-release.rs -o /tmp/find-latest-release
cur=`/tmp/find-latest-release`
# Move to the most recent release branch, update the release date and
# commit it, indicating that the commit is what will get tagged and
# released
git reset --hard origin/release-$cur
git submodule update --init --recursive
sed -i "s/^Unreleased/Released $(date +'%Y-%m-%d')/" RELEASES.md
git commit --allow-empty -a -F-<<EOF
Release Wasmtime $cur
[automatically-tag-and-release-this-commit]
EOF
# Push the result to a branch and setup metadata for the step below
# that creates a PR
git push origin HEAD:ci/release-$cur
echo "PR_HEAD=ci/release-$cur" >> $GITHUB_ENV
echo "PR_TITLE=Release Wasmtime $cur" >> $GITHUB_ENV
echo "PR_BASE=release-$cur" >> $GITHUB_ENV
cat > pr-body <<-EOF
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.
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.
[RELEASES.md]: https://github.com/${{ github.repository }}/blob/release-$cur/RELEASES.md
[process]: https://docs.wasmtime.dev/contributing-release-process.html
[branch]: https://github.com/${{ github.repository }}/tree/release-$cur
EOF
if: >-
github.event.schedule == '0 0 20 * *' ||
github.event.inputs.action == 'release-latest'
- name: Bump and release patch version number
run: |
set -ex
# Update version numbers on a patch basis and update RELEASES.md if a
# patch release marker is already in there. Note that this commit
# message indicates that on-merge a release will be made.
./publish bump-patch
# Update `cargo vet` entries for all the new crate versions
cargo vet
sed -i "s/^Unreleased/Released $(date +'%Y-%m-%d')/" RELEASES.md
num=$(./ci/print-current-version.sh)
git commit -a -F-<<EOF
Release Wasmtime $num
[automatically-tag-and-release-this-commit]
EOF
# Push the result to a branch and setup metadata for the step below
# that creates a PR
git push origin HEAD:ci/bump-to-$num
echo "PR_HEAD=ci/bump-to-$num" >> $GITHUB_ENV
echo "PR_TITLE=Release Wasmtime $num" >> $GITHUB_ENV
echo "PR_BASE=${{ github.ref_name }}" >> $GITHUB_ENV
cat > pr-body <<-EOF
This is an [automated pull request][process] from CI to create a patch release for Wasmtime $num, requested by @${{ github.actor }}.
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.
[RELEASES.md]: https://github.com/${{ github.repository }}/blob/release-$num/RELEASES.md
[process]: https://docs.wasmtime.dev/contributing-release-process.html
EOF
if: github.event.inputs.action == 'release-patch'
- name: Make a PR
# Note that the syntax here is kinda funky, and the general gist is that
# I couldn't figure out a good way to have a multiline string-literal
# become a json-encoded string literal to send to GitHub. This
# represents my best attempt.
run: |
set -ex
body=$(jq -sR < ./pr-body)
curl --include --request POST \
https://api.github.com/repos/${{ github.repository }}/pulls \
--header "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
--data @- << EOF
{
"head": "$PR_HEAD",
"base": "$PR_BASE",
"title": "$PR_TITLE",
"body": $body,
"maintainer_can_modify": true
}
EOF