Repository navigation
72 lines (64 loc) · 2.75 KB
/
Copy pathprepare_release.yml
File metadata and controls
72 lines (64 loc) · 2.75 KB
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
name: Prepare release
# Bumps the version everywhere it appears and opens a PR with the result.
# Run this before tagging, so the commit you tag already carries the right
# version. Deriving it here rather than at publish time means what ships
# always corresponds to a real commit in history.
on:
workflow_dispatch:
inputs:
version:
description: 'Release version, without a leading v (e.g. 3.6.0)'
required: true
jobs:
prepare_release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v5
with:
python-version: '3.x'
# Nothing is built or tested here; that all happens on the resulting PR.
# The lockfiles are edited in place rather than regenerated with npm
# install, which keeps this fast and limits the commit to the version.
- name: Set the version
run: python3 scripts/set_version.py "${{ inputs.version }}"
# gh rather than a third-party action; release_file.yml already uses it.
- name: Commit and open a pull request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ inputs.version }}
run: |
set -e
if git diff --quiet; then
echo "Already at $VERSION; nothing to do."
exit 0
fi
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git checkout -b "release/v$VERSION"
git commit -am "Set version to $VERSION"
# Force, so a re-run replaces an earlier attempt's branch rather than
# being rejected. The branch is generated, so there is nothing to lose.
git push --force origin "release/v$VERSION"
# Heredoc so the body is not indented by the YAML block scalar,
# which markdown would render as a code block.
cat > /tmp/pr-body.md <<EOF
Generated by the Prepare release workflow.
Sets the version to \`$VERSION\` across CMakeLists.txt, pyproject.toml,
flake.nix, bindings/wasm/package.json and scripts/test-cmake.sh, and
refreshes the package-lock files.
Once merged, tag the merge commit \`v$VERSION\` and publish the release.
The tagged commit then carries the matching version, which is what
publish_npm reads.
EOF
sed -i 's/^ //' /tmp/pr-body.md
# --base is required. Without it gh targets the repository's default
# branch, so a backport release dispatched against v3.5.x would open
# a PR into master carrying the whole branch difference.
gh pr create \
--base "$GITHUB_REF_NAME" \
--title "Release v$VERSION" \
--body-file /tmp/pr-body.md