Skip to content

Commit 3cdd9e5

Browse files
committed
feat: add version bump and tag release workflows
1 parent 249d093 commit 3cdd9e5

File tree

2 files changed

+114
-0
lines changed

2 files changed

+114
-0
lines changed

.github/workflows/bump-version.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Bump Version
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version_part:
6+
description: 'Version part to bump (major, minor, patch)'
7+
required: true
8+
default: 'patch'
9+
type: choice
10+
options:
11+
- major
12+
- minor
13+
- patch
14+
15+
jobs:
16+
bump-version:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
pull-requests: write
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Set up Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: '3.11'
33+
34+
- name: Install bumpversion
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install bump2version
38+
39+
- name: Configure git
40+
run: |
41+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
42+
git config --local user.name "github-actions[bot]"
43+
44+
- name: Get current version
45+
id: current_version
46+
run: |
47+
echo "version=$(grep current_version .bumpversion.cfg | cut -d '=' -f 2 | tr -d ' ')" >> $GITHUB_OUTPUT
48+
49+
- name: Bump version
50+
id: bump_version
51+
run: |
52+
# Use --no-tag to prevent creating a tag (we'll tag after PR merge)
53+
# Use --no-commit to let create-pull-request handle the commit
54+
bump2version ${{ github.event.inputs.version_part }} --no-tag --no-commit
55+
echo "new_version=$(grep current_version .bumpversion.cfg | cut -d '=' -f 2 | tr -d ' ')" >> $GITHUB_OUTPUT
56+
57+
- name: Create Pull Request
58+
id: create_pr
59+
uses: peter-evans/create-pull-request@v5
60+
with:
61+
token: ${{ secrets.GITHUB_TOKEN }}
62+
commit-message: "chore: bump version from ${{ steps.current_version.outputs.version }} to ${{ steps.bump_version.outputs.new_version }}"
63+
title: "chore: bump version from ${{ steps.current_version.outputs.version }} to ${{ steps.bump_version.outputs.new_version }}"
64+
body: |
65+
## Version Bump
66+
67+
This PR bumps the version from `${{ steps.current_version.outputs.version }}` to `${{ steps.bump_version.outputs.new_version }}`.
68+
69+
### Changes
70+
- Updated version in `setup.py`
71+
- Updated version in `docs/conf.py`
72+
- Updated version in `src/datapilot/__init__.py`
73+
- Updated version in `.bumpversion.cfg`
74+
75+
### Type of change
76+
- Version bump (${{ github.event.inputs.version_part }})
77+
78+
---
79+
*This PR was automatically created by the bump version workflow.*
80+
branch: bump-version-${{ steps.bump_version.outputs.new_version }}
81+
delete-branch: true
82+
labels: |
83+
version-bump
84+
automated

.github/workflows/tag-release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Tag Release
2+
on:
3+
pull_request:
4+
types: [closed]
5+
branches: [main]
6+
7+
jobs:
8+
tag-release:
9+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'version-bump')
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Get version from file
21+
id: get_version
22+
run: |
23+
echo "version=$(grep current_version .bumpversion.cfg | cut -d '=' -f 2 | tr -d ' ')" >> $GITHUB_OUTPUT
24+
25+
- name: Create and push tag
26+
run: |
27+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
28+
git config --local user.name "github-actions[bot]"
29+
git tag -a "v${{ steps.get_version.outputs.version }}" -m "Release version ${{ steps.get_version.outputs.version }}"
30+
git push origin "v${{ steps.get_version.outputs.version }}"

0 commit comments

Comments
 (0)