Skip to content

Commit 267a331

Browse files
committed
add ci action to auto generate PRs for bumping the release
Signed-off-by: Jade Abraham <[email protected]>
1 parent 3036023 commit 267a331

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
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 "[email protected]"
25+
git config --global user.name "github action"
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 }}

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)