Skip to content

Commit 213b4e8

Browse files
authored
Merge pull request #1836 from tweag/release-workflow
Refine release workflow
2 parents c233551 + b8d9a4e commit 213b4e8

File tree

6 files changed

+171
-62
lines changed

6 files changed

+171
-62
lines changed

.github/ISSUE_TEMPLATE/release.md

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
name: Prepare new release (for maintainers only)
3+
title: Prepare release MAJOR.MINOR
4+
about: Steps to work through in order to publish a new release
5+
6+
---
7+
8+
- [ ] Read through this process in its entirety so you understand it.
9+
- [ ] Create and checkout a new release preparation branch, named
10+
`release-<major>.<minor>`.
11+
- [ ] If the minimal Bazel version has changed:
12+
- [ ] update it in [the `start` script][start], in [`haskell/private/versions.bzl`][versions], and in [the `README`][readme]
13+
- [ ] add a note about this change to the [`CHANGELOG`][changelog]
14+
- [ ] Remove any feature that is still too experimental to go into a
15+
release, by cherry-picking reverts (or by manually deleting the
16+
feature).
17+
- [ ] Check the list [here](/MAINTAINERS.md#remove-these-prs-from-minor-releases)
18+
for PRs that have been explicitly marked for removal, if any.
19+
- [ ] Amend the [`CHANGELOG`][changelog] by summarising all significant
20+
pull requests since the last release (see
21+
[here](/MAINTAINERS.md#generating-the-pr-list-for-the-changelog)). Specifically:
22+
- [ ] Add a "Highlights" section for major improvements/changes.
23+
- [ ] Create "Added", "Removed", "Changed" and "Fixed" sections, as
24+
necessary.
25+
- [ ] If relevant, add links to the corresponding PRs to the entries.
26+
- [ ] Set the revision in [the `start` script][start] and
27+
[`docs/haskell-use-cases`][usecases] to the current release
28+
preparation branch; comment out the checksum. (n.b., Search for
29+
`http_archive` in these files.)
30+
- [ ] Push the `release-<major>.<minor>` branch and open a **draft** PR
31+
to verify CI is green.
32+
- [ ] Create a release tag (`v<major>.<minor>`) on the release
33+
preparation branch and push the tag; or use Github's UI.
34+
- [ ] Go to the [release page][releases]:
35+
- [ ] Open the corresponding draft release and copy the workspace snippet.
36+
- [ ] Insert the workspace snippet into [the `start` script][start]
37+
and [`docs/haskell-use-cases`][usecases] replacing the existing snippet.
38+
- [ ] Push the changes to the remote branch and mark the PR as ready;
39+
go through review and merge to `master` upon success.
40+
- If any changes need to be made, upon review, you will need to delete
41+
the release tag (from local and origin) and repeat the previous four
42+
steps appropriately before requesting a follow-up review.
43+
- If there are changes on the release preparation branch that should
44+
*not* go to `master`, create a second branch
45+
`release-<major>.<minor>-master` on `master` and cherry-pick all
46+
relevant commits from the release branch preparation branch. Open a
47+
pull request with that branch, go through review and push changes
48+
back to the release preparation branch.
49+
- [ ] Go to the [release page][releases]:
50+
- [ ] Open the draft release for the current version.
51+
- [ ] Release.
52+
- [ ] After the "Publish" workflow is finished check whether https://haskell.build/start
53+
is now the latest [`start` script][start] (Netlify sometimes has problems).
54+
- [ ] Announce the new version on Twitter by asking someone with access.
55+
56+
57+
[start]: /start
58+
[versions]: /haskell/private/versions.bzl
59+
[changelog]: /CHANGELOG.md
60+
[usecases]: /docs/haskell-use-cases.rst
61+
[readme]: /README.md
62+
[releases]: https://github.com/tweag/rules_haskell/releases

.github/workflows/changelog.awk

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
BEGIN {
3+
buffer=""
4+
version=substr(ENVIRON["GITHUB_REF_NAME"], 2)
5+
}
6+
7+
/^## / {
8+
if (index($0, version)) {
9+
in_version=1
10+
} else if (in_version) {
11+
exit # at the next section
12+
}
13+
}
14+
15+
!in_version { next }
16+
17+
# start at the first sub section of the version section
18+
/^### / {
19+
print_out=1
20+
}
21+
22+
!print_out { next }
23+
24+
# buffer empty lines until hitting text again; cuts off empty lines at the end
25+
/^[ \t]*$/ {
26+
buffer=buffer $0 "\n"
27+
next
28+
}
29+
30+
# print lines and buffer
31+
{
32+
print buffer $0
33+
buffer=""
34+
}
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Prepare release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]*.[0-9]*"
7+
8+
jobs:
9+
update-release-notes:
10+
name: Update release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
- name: Prepare workspace snippet
16+
run: .github/workflows/workspace_snippet.sh > release_notes.txt
17+
- name: Generate changelog
18+
run: |
19+
printf '\n-----\n\n' >> release_notes.txt
20+
awk -f .github/workflows/changelog.awk CHANGELOG.md >> release_notes.txt
21+
- name: Release
22+
uses: softprops/action-gh-release@v1
23+
with:
24+
prerelease: true
25+
body_path: release_notes.txt

.github/workflows/publish.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch: # allows manual triggering
7+
8+
jobs:
9+
webpage:
10+
name: Update webpage
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
with:
16+
ref: release
17+
- name: Configure git
18+
run: |
19+
git config user.name github-actions
20+
git config user.email [email protected]
21+
- name: Merge master into release
22+
run: git merge --no-edit origin/master
23+
- name: Push
24+
run: git push
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit -o nounset -o pipefail
4+
5+
# Set by GH actions, see
6+
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
7+
TAG=${GITHUB_REF_NAME}
8+
REPO_NAME=${GITHUB_REPOSITORY#*/}
9+
PREFIX="${REPO_NAME}-${TAG:1}"
10+
SHA=$(git archive --format=tar.gz --prefix=${PREFIX}/ ${TAG} | shasum -a 256 | awk '{print $1}')
11+
12+
cat << EOF
13+
WORKSPACE snippet:
14+
\`\`\`starlark
15+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
16+
http_archive(
17+
name = "",
18+
sha256 = "${SHA}",
19+
strip_prefix = "${PREFIX}",
20+
url = "https://github.com/${GITHUB_REPOSITORY}/archive/refs/tags/${TAG}.tar.gz",
21+
)
22+
\`\`\`
23+
EOF

MAINTAINERS.md

+3-62
Original file line numberDiff line numberDiff line change
@@ -26,64 +26,8 @@ so bumping Bazel regularly is required.
2626

2727
## Cutting a New Release
2828

29-
- [ ] Read through this process in its entirety so you understand it.
30-
- [ ] Copy this list of steps into an empty `rules_haskell` issue.
31-
- [ ] Create and checkout a new release preparation branch, named
32-
`release-<major>.<minor>`.
33-
- [ ] Update the minimal Bazel version in [the `start` script][start],
34-
[`haskell/private/versions.bzl`][versions], and [the
35-
`README`][readme]; add it to the [`CHANGELOG`][changelog] if it
36-
changed.
37-
- [ ] Remove any feature that is still too experimental to go into a
38-
release, by cherry-picking reverts (or by manually deleting the
39-
feature).
40-
- [ ] Check the list [below](#remove-these-prs-from-minor-releases)
41-
for PRs that have been explicitly marked for removal, if any.
42-
- [ ] Amend the [`CHANGELOG`][changelog] by summarising all significant
43-
pull requests since the last release (see
44-
[below](#generating-the-pr-list-for-the-changelog)). Specifically:
45-
- [ ] Add a "Highlights" section for major improvements/changes.
46-
- [ ] Create "Added", "Removed", "Changed" and "Fixed" sections, as
47-
necessary.
48-
- [ ] If relevant, add links to the corresponding PRs to the entries.
49-
- [ ] Set the revision in [the `start` script][start] and
50-
[`docs/haskell-use-cases`][usecases] to the current release
51-
preparation branch; comment out the checksum. (n.b., Search for
52-
`http_archive` in these files.)
53-
- [ ] Push and verify that the `release-<major>.<minor>` branch is
54-
green in the CI.
55-
- [ ] Create a release tag (`v<major>.<minor>`) on the release
56-
preparation branch.
57-
- [ ] Similar to above, set the revision in [the `start` script][start]
58-
and [`docs/haskell-use-cases`][usecases] to the release tag and
59-
update the checksum, uncommenting it out from previously. (See
60-
[below](#generating-the-archive-checkum) to get the checksum.)
61-
- [ ] Push the above, including the release tag, and open a PR from the
62-
release preparation branch; go through review and merge to
63-
`master` upon success.
64-
- If any changes need to be made, upon review, you will need to delete
65-
the release tag (from local and origin) and repeat the previous four
66-
steps appropriately before requesting a follow-up review.
67-
- If there are changes on the release preparation branch that should
68-
*not* go to `master`, create a second branch
69-
`release-<major>.<minor>-master` on `master` and cherry-pick all
70-
relevant commits from the release branch preparation branch. Open a
71-
pull request with that branch, go through review and push changes
72-
back to the release preparation branch.
73-
- [ ] Go to the [release page][releases] to create a new release:
74-
- [ ] Click on "Draft a new release".
75-
- [ ] Name "`v<major>.<minor>`".
76-
- [ ] Select the tag you created previously (it should be in
77-
GitHub's dropdown list).
78-
- [ ] Copy the [CHANGELOG][changelog] section for this release into
79-
the description. (You don't need to provide the source `.zip`
80-
and `.tar.gz` archives; GitHub does this automatically.)
81-
- [ ] Release.
82-
- [ ] Merge `master` into the `release` branch and push to trigger
83-
deployment.
84-
- [ ] Check whether https://haskell.build/start is now the latest
85-
[`start` script][start] (Netlify sometimes has problems).
86-
- [ ] Announce the new version on Twitter by asking someone with access.
29+
- [ ] Create a [new issue][release-issue] from the "Prepare new release"
30+
template and follow the instructions there.
8731

8832
### Generating the PR List for the CHANGELOG
8933

@@ -130,7 +74,4 @@ the initial "v"; adjust as necessary.
13074
<!-- Links -->
13175
[start]: ./start
13276
[versions]: ./haskell/private/versions.bzl
133-
[readme]: ./README.md
134-
[changelog]: ./CHANGELOG.md
135-
[usecases]: ./docs/haskell-use-cases.rst
136-
[releases]: https://github.com/tweag/rules_haskell/releases
77+
[release-issue]: https://github.com/tweag/rules_haskell/issues/new?template=release.md

0 commit comments

Comments
 (0)