Skip to content

Commit da0ae3f

Browse files
authored
Add CI to help automate releases (#115)
Adds a CI automation to auto-bump releases based on a github workflow Running the workflow is manual, but this removes the manual step of checking out and creating the "bump version" PR. I modeled the github action on the chapel-vscode one, so it should be correct: https://github.com/chapel-lang/chapel-vscode/blob/main/.github/workflows/bump-version.yml
2 parents 3036023 + 465d402 commit da0ae3f

File tree

3 files changed

+69
-6
lines changed

3 files changed

+69
-6
lines changed

.github/workflows/bump-version.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Bump version
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
bump-patch:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Install Node.js
12+
uses: actions/setup-node@v4
13+
with:
14+
node-version: 20
15+
- name: Exit if branch exists
16+
run: |
17+
BRANCH_NAME="update-version"
18+
if git ls-remote --heads origin $BRANCH_NAME | grep -q $BRANCH_NAME; then
19+
echo "Branch $BRANCH_NAME already exists."
20+
exit 1
21+
fi
22+
- name: Create a new branch
23+
run: |
24+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
25+
git config --global user.name "github-actions[bot]"
26+
git checkout -b update-version
27+
git push --set-upstream origin update-version
28+
- name: Bump Version
29+
run: |
30+
./util/bump-version.sh
31+
git commit -am "Bump version for next release"
32+
git push
33+
- name: create pull request
34+
run: >
35+
gh pr create
36+
-B main
37+
-H update-version
38+
--title 'Bump version for next release'
39+
--body 'Bump the version in prep for next release'
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ Making a Release
4646
#. Click “Draft a new release” button on top of screen
4747
#. For the tag, make a new tag with the new version number
4848
#. You can generate the release notes via the “generate release notes” button,
49-
comparing against the most recent release. This will autofill in the details
49+
comparing against the most recent release. This will autofill in the details
5050
for you
51-
#. Click Publish release
51+
#. Click "Publish release"
5252
- This will trigger the workflow to push a new release to PyPI, assuming no
5353
problems have snuck into our release procedure since the last time it was
5454
run
55-
#. Open a PR bumping the version to the next version number so that were ready
56-
for the next change. This should always be the first PR in a new release
57-
(otherwise well have build issues), so it should be straight-forward to
58-
figure out how to do this
55+
#. Open a PR bumping the version to the next version number so that we're ready
56+
for the next change. This should always be the first PR in a new release
57+
(otherwise we'll have build issues). This can be done by running the
58+
'bump-version' GitHub Action, which will create the PR for you.
5959

6060
In case of issues, the release pushing job is in
6161
.github/workflows/python-publish.yml

util/bump-version.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
6+
7+
version_file="$SCRIPT_DIR/../sphinxcontrib/chapeldomain/__init__.py"
8+
current_version=$(grep -E "VERSION\s*=\s*'[0-9.]+" "$version_file" | awk -F"=" '{print $2}' | tr -d ' ' | tr -d "'")
9+
echo "Current version: $current_version"
10+
major_version=$(echo "$current_version" | awk -F"." '{print $1}')
11+
minor_version=$(echo "$current_version" | awk -F"." '{print $2}')
12+
patch_version=$(echo "$current_version" | awk -F"." '{print $3}')
13+
14+
15+
new_patch_version=$((patch_version + 1))
16+
new_version="${major_version}.${minor_version}.${new_patch_version}"
17+
echo "New version: $new_version"
18+
19+
# update the version file
20+
set -x
21+
sed -E "s|^(VERSION[[:space:]]*=[[:space:]]*)'[^']+'$|\1'${new_version}'|" "$version_file" > "${version_file}.tmp"
22+
mv "${version_file}.tmp" "$version_file"

0 commit comments

Comments
 (0)