Skip to content

Commit 1fbc971

Browse files
committed
chore: update demo to the latest cookiecutter-robust-python
1 parent 5d7ebd0 commit 1fbc971

File tree

7 files changed

+57
-118
lines changed

7 files changed

+57
-118
lines changed

.cookiecutter.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"_commit": "3bb543e9c4ea543fa92dcc1892dcf89049aebf0a",
2+
"_commit": "31a98e1a58496fdcd6f5eabee09440d27dc2ebcb",
33
"_template": "C:\\Users\\56kyl\\source\\repos\\cookiecutter-robust-python",
44
"add_rust_extension": false,
55
"author": "Kyle Oliver",

.cruft.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "C:\\Users\\56kyl\\source\\repos\\cookiecutter-robust-python",
3-
"commit": "3bb543e9c4ea543fa92dcc1892dcf89049aebf0a",
3+
"commit": "31a98e1a58496fdcd6f5eabee09440d27dc2ebcb",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -18,7 +18,7 @@
1818
"license": "MIT",
1919
"development_status": "Development Status :: 1 - Planning",
2020
"_template": "C:\\Users\\56kyl\\source\\repos\\cookiecutter-robust-python",
21-
"_commit": "3bb543e9c4ea543fa92dcc1892dcf89049aebf0a"
21+
"_commit": "31a98e1a58496fdcd6f5eabee09440d27dc2ebcb"
2222
}
2323
},
2424
"directory": null

.github/workflows/bump-version.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
19+
- name: Set up uv
20+
uses: astral-sh/setup-uv@v6
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version-file: .github/workflows/.python-version
26+
27+
- name: Get Current Version
28+
id: current_version
29+
run: echo "CURRENT_VERSION=$(uvx --from commitizen cz version -p)" >> $GITHUB_OUTPUT
30+
31+
- name: Get New Release Version
32+
id: new_version
33+
run: echo "NEW_VERSION=${GITHUB_REF_NAME#release/}" >> $GITHUB_OUTPUT
34+
35+
- name: Bump Version
36+
if: ${{ steps.current_version.outputs.CURRENT_VERSION != steps.new_version.outputs.NEW_VERSION }}
37+
run: uvx nox -s bump-version ${{ steps.new_version.outputs.NEW_VERSION }}
38+
39+
- name: Get Release Notes
40+
id: changelog
41+
run: echo "CHANGELOG=$(uvx nox -s get-release-notes)" >> $GITHUB_OUTPUT
42+
43+
- name: Create Release Draft
44+
uses: softprops/action-gh-release@v1
45+
with:
46+
body_path: body.md
47+
draft: true
48+
tag_name: ${{ steps.new_version.outputs.NEW_VERSION }}
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release-python.yml

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,6 @@ jobs:
5353
TWINE_PASSWORD: ${{ secrets.TESTPYPI_API_TOKEN }}
5454
run: uvx nox -s publish-package -- --repository testpypi
5555

56-
- name: Get Release Notes from Changelog
57-
id: changelog
58-
uses: simple-changelog/action@v3
59-
with:
60-
path: CHANGELOG.md
61-
tag: ${{ github.event_name == 'push' && github.ref_name || github.event.inputs.tag }}
62-
63-
outputs:
64-
changelog_body:
65-
description: "Release notes body extracted from CHANGELOG.md"
66-
value: ${{ steps.changelog.outputs.changes }} # Output the extracted changelog body
67-
6856
publish_pypi:
6957
name: Publish to Production PyPI
7058
runs-on: ubuntu-latest
@@ -91,39 +79,3 @@ jobs:
9179
TWINE_USERNAME: __token__
9280
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
9381
run: uvx nox -s publish-python
94-
95-
create_github_release:
96-
name: Create GitHub Release
97-
runs-on: ubuntu-latest
98-
needs: build_and_testpypi
99-
100-
if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')"
101-
102-
steps:
103-
- name: Download package artifacts # Get built artifacts for release assets
104-
uses: actions/download-artifact@v4
105-
with:
106-
name: distribution-packages
107-
108-
- name: Get tag name
109-
id: get_tag
110-
run: echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
111-
112-
- name: Generate Release Notes
113-
run: |
114-
if [ -z "${{ steps.previous_tag.outputs.previous }}" ]; then
115-
echo "No previous tag found: generating changelog for all commits."
116-
cz changelog --dry-run > RELEASE_NOTES.md
117-
else
118-
echo "Previous tag found: generating changelog diff."
119-
cz changelog --dry-run --rev-range ${{ steps.previous_tag.outputs.previous }}..${GITHUB_REF_NAME} > RELEASE_NOTES.md
120-
fi
121-
122-
- name: Create GitHub Release
123-
uses: softprops/action-gh-release@v2
124-
with:
125-
tag_name: ${{ steps.get_tag.outputs.tag }}
126-
name: Release ${{ steps.get_tag.outputs.tag }}
127-
body: ${{ needs.build_and_testpypi.outputs.changelog_body }}
128-
files: dist/*
129-
prerelease: ${{ contains(steps.get_tag.outputs.tag, '-') }} # Checks if tag contains hyphen (e.g. v1.0.0-rc.1)

scripts/get-release-notes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
def main() -> None:
1111
"""Parses args and passes through to bump_version."""
12-
release_notes: str = get_latest_release_notes()
13-
RELEASE_NOTES_PATH.write_text(release_notes)
12+
get_latest_release_notes()
1413

1514

1615
if __name__ == "__main__":

scripts/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def get_latest_tag() -> Optional[str]:
108108
return tag
109109

110110

111-
def get_latest_release_notes() -> str:
111+
def get_latest_release_notes() -> None:
112112
"""Gets the release notes.
113113
114114
Assumes the latest_tag hasn't been applied yet.
@@ -124,10 +124,10 @@ def get_latest_release_notes() -> str:
124124
result: subprocess.CompletedProcess = subprocess.run(
125125
["uvx", "--from", "commitizen", "cz", "changelog", rev_range, "--dry-run"],
126126
cwd=REPO_FOLDER,
127-
capture_output=True,
128127
check=True
129128
)
130-
return result.stdout.decode("utf-8")
129+
if result.returncode != 0:
130+
raise ValueError("Unable to get release notes.")
131131

132132

133133
def tag_release() -> None:

0 commit comments

Comments
 (0)