Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ current_version = 6.2.12
files = lib/dt_shell/__init__.py
commit = True
tag = True
tag_name = v{new_version}
message = Bump version: {current_version} → {new_version}
130 changes: 130 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: Automated Release

on:
workflow_dispatch:
inputs:
version_bump:
description: "Version bump type"
required: true
default: "patch"
type: choice
options: [patch, minor, major]
pre_release:
description: "Mark as pre-release"
required: false
default: false
type: boolean

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install bump2version
run: |
python -m pip install --upgrade pip
pip install bump2version

- name: Configure git
run: |
git config --local user.email "action@github.com"
git config --local user.name "github-actions[bot]"
git config --global --add safe.directory "$GITHUB_WORKSPACE"

# Read current/new versions using bump2version's dry-run output
- name: Preview bump
id: preview
run: |
bump="${{ github.event.inputs.version_bump }}"
out="$(bump2version --dry-run --list "$bump" || true)"
echo "$out"
current="$(echo "$out" | grep -E '^current_version=' | cut -d= -f2)"
new="$(echo "$out" | grep -E '^new_version=' | cut -d= -f2)"
if [ -z "$new" ]; then
echo "No new_version computed. Check your .bumpversion.cfg or bump type." >&2
exit 1
fi
echo "current=$current" >> "$GITHUB_OUTPUT"
echo "new=$new" >> "$GITHUB_OUTPUT"

- name: Bump version (commit + tag)
run: |
bump2version --commit --tag ${{ github.event.inputs.version_bump }}
# optional: make tag annotated (if your config makes lightweight tags)
# latest_tag=$(git describe --tags --abbrev=0)
# git tag -f -a "$latest_tag" -m "Release $latest_tag"

- name: Push changes and tags
env:
GH_BRANCH: ${{ github.ref_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# If the workflow was dispatched from the default branch, this is correct.
# If you always want to push to default, replace $GH_BRANCH with your branch name.
git push origin "HEAD:${GH_BRANCH}"
git push --tags

- name: Generate changelog
id: changelog
run: |
latest_tag=$(git describe --tags --abbrev=0)
# previous tag if exists
previous_tag=$(git describe --tags --abbrev=0 "${latest_tag}^" 2>/dev/null || true)

{
echo "## Changes"
if [ -n "$previous_tag" ]; then
echo ""
echo "Comparing $previous_tag...$latest_tag"
echo ""
git log --pretty=format:"* %s (%an)" "$previous_tag..$latest_tag"
else
echo ""
echo "Initial release"
echo ""
git log --pretty=format:"* %s (%an)"
fi
} > changelog.md

{
echo 'body<<EOF'
cat changelog.md
echo EOF
} >> "$GITHUB_OUTPUT"

# Use maintained release action
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.preview.outputs.new }} # ↔️ ensure your bump2version tags also have the 'v' prefix
name: Release v${{ steps.preview.outputs.new }}
body: ${{ steps.changelog.outputs.body }}
draft: false
prerelease: ${{ github.event.inputs.pre_release }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Summary
run: |
{
echo "🚀 Successfully released v${{ steps.preview.outputs.new }}"
echo "📦 Release type: ${{ github.event.inputs.version_bump }}"
echo "🏷️ Previous version: v${{ steps.preview.outputs.current }}"
echo "✨ New version: v${{ steps.preview.outputs.new }}"
if [ "${{ github.event.inputs.pre_release }}" = "true" ]; then
echo "⚠️ Pre-release: Yes"
fi
} >> "$GITHUB_STEP_SUMMARY"
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,3 +446,23 @@ Open webpages in the host's default browser from the container:
```bash
"$BROWSER" https://www.duckietown.org
```

## Development & Releases

### Automated Releases

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:

- **Go to Actions → Automated Release → Run workflow**
- **Choose version bump type:**
- `patch` - Bug fixes (6.2.12 → 6.2.13)
- `minor` - New features (6.2.12 → 6.3.0)
- `major` - Breaking changes (6.2.12 → 7.0.0)

The workflow automatically:
- Updates version numbers
- Creates git tags
- Generates changelogs
- Creates GitHub releases

For detailed instructions, see [docs/RELEASE_PROCESS.md](docs/RELEASE_PROCESS.md).
Loading