Skip to content

Commit a0c6460

Browse files
authored
Merge pull request #69 from robust-python/feature/add-calver-release-process
Feature/add calver release process
2 parents be58c21 + d5b8fe5 commit a0c6460

21 files changed

+873
-94
lines changed

.cz.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[tool.commitizen]
2+
tag_format = "v$version"
3+
version_provider = "pep621"
4+
update_changelog_on_bump = true

.github/workflows/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

.github/workflows/merge-demo-feature.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ env:
1111
ROBUST_MATURIN_DEMO__APP_AUTHOR: ${{ github.repository_owner }}
1212

1313
jobs:
14+
update-demo:
15+
name: Update Demo
16+
uses: ./.github/workflows/update-demo.yml
17+
strategy:
18+
matrix:
19+
demo_name:
20+
- "robust-python-demo"
21+
- "robust-maturin-demo"
22+
with:
23+
demo_name: ${{ matrix.demo_name }}
24+
1425
merge-demo-feature:
1526
name: Merge Demo Feature
1627
runs-on: ubuntu-latest
@@ -24,12 +35,21 @@ jobs:
2435
uses: actions/checkout@v4
2536
with:
2637
repository: ${{ github.repository }}
27-
path: "${{ github.workspace }}/cookiecutter-robust-python"
2838

29-
- name: Sync Demo
30-
uses: "${{ github.workspace }}/cookiecutter-robust-python/.github/workflows/update-demo.yml"
39+
- name: Checkout Demo
40+
uses: actions/checkout@v4
41+
with:
42+
repository: "${{ github.repository_owner }}/${{ inputs.demo_name }}"
43+
path: ${{ inputs.demo_name }}
44+
ref: develop
45+
46+
- name: Set up uv
47+
uses: astral-sh/setup-uv@v6
48+
49+
- name: Set up Python
50+
uses: actions/setup-python@v5
3151
with:
32-
demo_name: ${{ matrix.demo_name }}
52+
python-version-file: "${{ github.workspace }}/cookiecutter-robust-python/.github/workflows/.python-version"
3353

3454
- name: Merge Demo Feature PR into Develop
3555
working-directory: "${{ github.workspace }}/${{ matrix.demo_name }}"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Prepare Release
2+
3+
on:
4+
push:
5+
branches:
6+
- "release/*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
prepare-release:
13+
name: Prepare Release
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
fetch-tags: true
21+
22+
- name: Set up uv
23+
uses: astral-sh/setup-uv@v6
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version-file: .github/workflows/.python-version
29+
30+
- name: Get Current Version
31+
id: current_version
32+
run: echo "CURRENT_VERSION=$(uvx --from commitizen cz version -p)" >> $GITHUB_OUTPUT
33+
34+
- name: Get New Release Version
35+
id: new_version
36+
run: echo "NEW_VERSION=${GITHUB_REF_NAME#release/}" >> $GITHUB_OUTPUT
37+
38+
- name: Bump Version
39+
if: ${{ steps.current_version.outputs.CURRENT_VERSION != steps.new_version.outputs.NEW_VERSION }}
40+
run: uvx nox -s bump-version ${{ steps.new_version.outputs.NEW_VERSION }}
41+
42+
- name: Get Release Notes
43+
run: uvx nox -s get-release-notes -- ${{ github.workspace }}-CHANGELOG.md
44+
45+
- name: Create Release Draft
46+
uses: softprops/action-gh-release@v2
47+
with:
48+
body_path: ${{ github.workspace }}-CHANGELOG.md
49+
draft: true
50+
tag_name: v${{ steps.new_version.outputs.NEW_VERSION }}
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# .github/workflows/release-template.yml
2+
# Automated release workflow for the cookiecutter-robust-python template
3+
# Uses Calendar Versioning (CalVer): YYYY.MM.MICRO
4+
5+
name: Release Template
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
12+
workflow_dispatch:
13+
inputs:
14+
micro_version:
15+
description: 'Override micro version (leave empty for auto-increment)'
16+
required: false
17+
type: string
18+
19+
jobs:
20+
bump_and_build:
21+
name: Bump Version & Build
22+
runs-on: ubuntu-latest
23+
outputs:
24+
version: ${{ steps.version.outputs.VERSION }}
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
fetch-tags: true
31+
32+
- name: Set up uv
33+
uses: astral-sh/setup-uv@v6
34+
35+
- name: Set up Python
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version-file: ".github/workflows/.python-version"
39+
40+
- name: Configure Git
41+
run: |
42+
git config user.name "github-actions[bot]"
43+
git config user.email "github-actions[bot]@users.noreply.github.com"
44+
45+
- name: Bump version and generate changelog
46+
run: |
47+
if [ -n "${{ inputs.micro_version }}" ]; then
48+
uvx nox -s bump-version -- ${{ inputs.micro_version }}
49+
else
50+
uvx nox -s bump-version
51+
fi
52+
53+
- name: Get version
54+
id: version
55+
run: |
56+
VERSION=$(uvx --from commitizen cz version -p)
57+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
58+
59+
- name: Push version bump commit
60+
run: git push origin HEAD
61+
62+
- name: Build packages
63+
run: uvx nox -s build-python
64+
65+
- name: Upload build artifacts
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: dist-${{ steps.version.outputs.VERSION }}
69+
path: dist/
70+
retention-days: 7
71+
72+
publish_testpypi:
73+
name: Publish to TestPyPI
74+
runs-on: ubuntu-latest
75+
needs: bump_and_build
76+
permissions:
77+
id-token: write
78+
steps:
79+
- name: Checkout code
80+
uses: actions/checkout@v4
81+
82+
- name: Set up uv
83+
uses: astral-sh/setup-uv@v6
84+
85+
- name: Download build artifacts
86+
uses: actions/download-artifact@v4
87+
with:
88+
name: dist-${{ needs.bump_and_build.outputs.version }}
89+
path: dist/
90+
91+
- name: Publish to TestPyPI
92+
run: uvx nox -s publish-python -- --test-pypi
93+
94+
publish_pypi:
95+
name: Tag & Publish to PyPI
96+
runs-on: ubuntu-latest
97+
needs: [bump_and_build, publish_testpypi]
98+
permissions:
99+
id-token: write
100+
contents: write
101+
steps:
102+
- name: Checkout code
103+
uses: actions/checkout@v4
104+
with:
105+
fetch-depth: 0
106+
ref: main
107+
108+
- name: Set up uv
109+
uses: astral-sh/setup-uv@v6
110+
111+
- name: Set up Python
112+
uses: actions/setup-python@v5
113+
with:
114+
python-version-file: ".github/workflows/.python-version"
115+
116+
- name: Configure Git
117+
run: |
118+
git config user.name "github-actions[bot]"
119+
git config user.email "github-actions[bot]@users.noreply.github.com"
120+
121+
- name: Pull latest (includes version bump)
122+
run: git pull origin main
123+
124+
- name: Download build artifacts
125+
uses: actions/download-artifact@v4
126+
with:
127+
name: dist-${{ needs.bump_and_build.outputs.version }}
128+
path: dist/
129+
130+
- name: Create and push tag
131+
run: uvx nox -s tag-version -- push
132+
133+
- name: Publish to PyPI
134+
run: uvx nox -s publish-python
135+
136+
- name: Extract release notes
137+
run: uvx nox -s get-release-notes -- release_notes.md
138+
139+
- name: Create GitHub Release
140+
uses: softprops/action-gh-release@v2
141+
with:
142+
tag_name: v${{ needs.bump_and_build.outputs.version }}
143+
name: v${{ needs.bump_and_build.outputs.version }}
144+
body_path: release_notes.md
145+
files: dist/*
146+
env:
147+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/sync-demos.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,11 @@ on:
77
jobs:
88
update-demo:
99
name: Update Demo
10-
runs-on: ubuntu-latest
11-
10+
uses: ./.github/workflows/update-demo.yml
1211
strategy:
1312
matrix:
1413
demo_name:
1514
- "robust-python-demo"
1615
- "robust-maturin-demo"
17-
steps:
18-
- name: Checkout Template
19-
uses: actions/checkout@v4
20-
with:
21-
repository: ${{ github.repository }}
22-
path: "${{ github.workspace }}/cookiecutter-robust-python"
23-
24-
- name: Update Demo
25-
uses: "${{ github.workspace }}/cookiecutter-robust-python/.github/workflows/update-demo.yml"
26-
with:
27-
demo_name: ${{ matrix.demo_name }}
16+
with:
17+
demo_name: ${{ matrix.demo_name }}

.github/workflows/update-demo.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ jobs:
1616
update-demo:
1717
runs-on: ubuntu-latest
1818
steps:
19+
- name: Checkout Template
20+
uses: actions/checkout@v4
21+
with:
22+
repository: ${{ github.repository }}
23+
path: "${{ github.workspace }}/cookiecutter-robust-python"
24+
1925
- name: Checkout Demo
2026
uses: actions/checkout@v4
2127
with:
@@ -29,7 +35,7 @@ jobs:
2935
- name: Set up Python
3036
uses: actions/setup-python@v5
3137
with:
32-
python-version-file: ".github/workflows/.python-version"
38+
python-version-file: "${{ github.workspace }}/cookiecutter-robust-python/.github/workflows/.python-version"
3339

3440
- name: Update Demo
3541
working-directory: "${{ github.workspace }}/cookiecutter-robust-python"

0 commit comments

Comments
 (0)