Skip to content

Commit 481b949

Browse files
committed
feat: add version bump and tag release workflows (#58)
1 parent b39df5b commit 481b949

File tree

2 files changed

+136
-0
lines changed

2 files changed

+136
-0
lines changed

.github/workflows/bump-version.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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+
version=$(grep '^current_version' .bumpversion.cfg | cut -d '=' -f 2 | tr -d ' ')
48+
echo "version=${version}" >> "$GITHUB_OUTPUT"
49+
50+
- name: Bump version
51+
id: bump_version
52+
run: |
53+
# Use --no-tag to prevent creating a tag (we'll tag after PR merge)
54+
# Use --no-commit to let create-pull-request handle the commit
55+
bump2version ${{ github.event.inputs.version_part }} --no-tag --no-commit
56+
new_version=$(grep '^current_version' .bumpversion.cfg | cut -d '=' -f 2 | tr -d ' ')
57+
echo "new_version=${new_version}" >> "$GITHUB_OUTPUT"
58+
59+
- name: Create Pull Request
60+
id: create_pr
61+
uses: peter-evans/create-pull-request@v5
62+
with:
63+
token: ${{ secrets.GITHUB_TOKEN }}
64+
commit-message: "chore: bump version from ${{ steps.current_version.outputs.version }} to ${{ steps.bump_version.outputs.new_version }}"
65+
title: "chore: bump version from ${{ steps.current_version.outputs.version }} to ${{ steps.bump_version.outputs.new_version }}"
66+
body: |
67+
## Version Bump
68+
69+
This PR bumps the version from `${{ steps.current_version.outputs.version }}` to `${{ steps.bump_version.outputs.new_version }}`.
70+
71+
### Changes
72+
- Updated version in `setup.py`
73+
- Updated version in `docs/conf.py`
74+
- Updated version in `src/datapilot/__init__.py`
75+
- Updated version in `.bumpversion.cfg`
76+
77+
### Type of change
78+
- Version bump (${{ github.event.inputs.version_part }})
79+
80+
---
81+
*This PR was automatically created by the bump version workflow.*
82+
branch: bump-version-${{ steps.bump_version.outputs.new_version }}
83+
delete-branch: true
84+
labels: |
85+
version-bump
86+
automated

.github/workflows/tag-release.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.11'
24+
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install tox twine wheel setuptools
29+
30+
- name: Get version from file
31+
id: get_version
32+
run: |
33+
version=$(grep '^current_version' .bumpversion.cfg | cut -d '=' -f 2 | tr -d ' ')
34+
echo "version=${version}" >> "$GITHUB_OUTPUT"
35+
36+
- name: Create and push tag
37+
run: |
38+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
39+
git config --local user.name "github-actions[bot]"
40+
git tag -a "v${{ steps.get_version.outputs.version }}" -m "Release version ${{ steps.get_version.outputs.version }}"
41+
git push origin "v${{ steps.get_version.outputs.version }}"
42+
43+
- name: Make release script executable
44+
run: chmod +x release.sh
45+
46+
- name: Publish to PyPI
47+
env:
48+
TWINE_USERNAME: __token__
49+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
50+
run: ./release.sh

0 commit comments

Comments
 (0)