Skip to content

Commit 76f36a2

Browse files
committed
feat: add automated semantic versioning release system
- Add GitHub Actions workflow for automated releases - Update bumpversion configuration - Support patch/minor/major semantic versioning
1 parent 875e595 commit 76f36a2

File tree

3 files changed

+152
-0
lines changed

3 files changed

+152
-0
lines changed

.bumpversion.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ current_version = 6.2.12
33
files = lib/dt_shell/__init__.py
44
commit = True
55
tag = True
6+
tag_name = v{new_version}
7+
message = Bump version: {current_version} → {new_version}

.github/workflows/release.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Automated Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_bump:
7+
description: "Version bump type"
8+
required: true
9+
default: "patch"
10+
type: choice
11+
options: [patch, minor, major]
12+
pre_release:
13+
description: "Mark as pre-release"
14+
required: false
15+
default: false
16+
type: boolean
17+
18+
jobs:
19+
release:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: write
23+
pull-requests: write
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: "3.10"
35+
36+
- name: Install bump2version
37+
run: |
38+
python -m pip install --upgrade pip
39+
pip install bump2version
40+
41+
- name: Configure git
42+
run: |
43+
git config --local user.email "action@github.com"
44+
git config --local user.name "github-actions[bot]"
45+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
46+
47+
# Read current/new versions using bump2version's dry-run output
48+
- name: Preview bump
49+
id: preview
50+
run: |
51+
bump="${{ github.event.inputs.version_bump }}"
52+
out="$(bump2version --dry-run --list "$bump" || true)"
53+
echo "$out"
54+
current="$(echo "$out" | grep -E '^current_version=' | cut -d= -f2)"
55+
new="$(echo "$out" | grep -E '^new_version=' | cut -d= -f2)"
56+
if [ -z "$new" ]; then
57+
echo "No new_version computed. Check your .bumpversion.cfg or bump type." >&2
58+
exit 1
59+
fi
60+
echo "current=$current" >> "$GITHUB_OUTPUT"
61+
echo "new=$new" >> "$GITHUB_OUTPUT"
62+
63+
- name: Bump version (commit + tag)
64+
run: |
65+
bump2version --commit --tag ${{ github.event.inputs.version_bump }}
66+
# optional: make tag annotated (if your config makes lightweight tags)
67+
# latest_tag=$(git describe --tags --abbrev=0)
68+
# git tag -f -a "$latest_tag" -m "Release $latest_tag"
69+
70+
- name: Push changes and tags
71+
env:
72+
GH_BRANCH: ${{ github.ref_name }}
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
run: |
75+
# If the workflow was dispatched from the default branch, this is correct.
76+
# If you always want to push to default, replace $GH_BRANCH with your branch name.
77+
git push origin "HEAD:${GH_BRANCH}"
78+
git push --tags
79+
80+
- name: Generate changelog
81+
id: changelog
82+
run: |
83+
latest_tag=$(git describe --tags --abbrev=0)
84+
# previous tag if exists
85+
previous_tag=$(git describe --tags --abbrev=0 "${latest_tag}^" 2>/dev/null || true)
86+
87+
{
88+
echo "## Changes"
89+
if [ -n "$previous_tag" ]; then
90+
echo ""
91+
echo "Comparing $previous_tag...$latest_tag"
92+
echo ""
93+
git log --pretty=format:"* %s (%an)" "$previous_tag..$latest_tag"
94+
else
95+
echo ""
96+
echo "Initial release"
97+
echo ""
98+
git log --pretty=format:"* %s (%an)"
99+
fi
100+
} > changelog.md
101+
102+
{
103+
echo 'body<<EOF'
104+
cat changelog.md
105+
echo EOF
106+
} >> "$GITHUB_OUTPUT"
107+
108+
# Use maintained release action
109+
- name: Create GitHub Release
110+
uses: softprops/action-gh-release@v2
111+
with:
112+
tag_name: v${{ steps.preview.outputs.new }} # ↔️ ensure your bump2version tags also have the 'v' prefix
113+
name: Release v${{ steps.preview.outputs.new }}
114+
body: ${{ steps.changelog.outputs.body }}
115+
draft: false
116+
prerelease: ${{ github.event.inputs.pre_release }}
117+
env:
118+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119+
120+
- name: Summary
121+
run: |
122+
{
123+
echo "🚀 Successfully released v${{ steps.preview.outputs.new }}"
124+
echo "📦 Release type: ${{ github.event.inputs.version_bump }}"
125+
echo "🏷️ Previous version: v${{ steps.preview.outputs.current }}"
126+
echo "✨ New version: v${{ steps.preview.outputs.new }}"
127+
if [ "${{ github.event.inputs.pre_release }}" = "true" ]; then
128+
echo "⚠️ Pre-release: Yes"
129+
fi
130+
} >> "$GITHUB_STEP_SUMMARY"

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,3 +446,23 @@ Open webpages in the host's default browser from the container:
446446
```bash
447447
"$BROWSER" https://www.duckietown.org
448448
```
449+
450+
## Development & Releases
451+
452+
### Automated Releases
453+
454+
This repository uses automated semantic versioning for releases. Instead of manually creating tags like `v0.2.8`, you can now specify the type of release:
455+
456+
- **Go to Actions → Automated Release → Run workflow**
457+
- **Choose version bump type:**
458+
- `patch` - Bug fixes (6.2.12 → 6.2.13)
459+
- `minor` - New features (6.2.12 → 6.3.0)
460+
- `major` - Breaking changes (6.2.12 → 7.0.0)
461+
462+
The workflow automatically:
463+
- Updates version numbers
464+
- Creates git tags
465+
- Generates changelogs
466+
- Creates GitHub releases
467+
468+
For detailed instructions, see [docs/RELEASE_PROCESS.md](docs/RELEASE_PROCESS.md).

0 commit comments

Comments
 (0)