Skip to content

Commit 2d5ec45

Browse files
authored
ci: add automated release + changelog via release-please (#7)
1 parent c96a5ff commit 2d5ec45

5 files changed

Lines changed: 116 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: ci
33
on:
44
pull_request:
55
push:
6-
branches: [main]
6+
branches: [master]
77

88
jobs:
99
lint-and-test:

.github/workflows/release.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: release
2+
3+
# Automated releases via release-please. On every push to master, release-please
4+
# maintains a "release PR" that bumps the version (pyproject.toml + __init__.py) and
5+
# the CHANGELOG. Merging that PR creates the vX.Y.Z tag + GitHub Release, then this
6+
# same run publishes to PyPI (OIDC) and force-moves the sliding v0 major tag.
7+
#
8+
# Why publish here instead of relying on publish.yml's tag trigger: release-please
9+
# creates the tag via the GitHub API using GITHUB_TOKEN, and a GITHUB_TOKEN-created
10+
# tag does NOT trigger other workflows. So the publish + major-tag steps run as
11+
# release_created-gated jobs in this workflow. publish.yml / move-major-tag.yml stay
12+
# as the manual-tag fallback (a human can still `git tag vX.Y.Z && git push`).
13+
14+
on:
15+
push:
16+
branches: [master]
17+
workflow_dispatch:
18+
19+
permissions: {}
20+
21+
jobs:
22+
release-please:
23+
runs-on: ubuntu-24.04
24+
permissions:
25+
contents: write # create the release commit, tag, and GitHub Release
26+
pull-requests: write # open/update the release PR
27+
issues: write # manage the autorelease:* labels
28+
outputs:
29+
release_created: ${{ steps.release.outputs.release_created }}
30+
tag_name: ${{ steps.release.outputs.tag_name }}
31+
steps:
32+
- uses: googleapis/release-please-action@v5
33+
id: release
34+
with:
35+
token: ${{ secrets.GITHUB_TOKEN }}
36+
target-branch: master
37+
config-file: release-please-config.json
38+
manifest-file: .release-please-manifest.json
39+
40+
publish:
41+
needs: release-please
42+
if: ${{ needs.release-please.outputs.release_created == 'true' }}
43+
runs-on: ubuntu-24.04
44+
permissions:
45+
id-token: write # PyPI OIDC Trusted Publishing
46+
contents: read
47+
steps:
48+
- uses: actions/checkout@v7
49+
- uses: astral-sh/setup-uv@v8.2.0
50+
- run: uv sync --all-extras
51+
- name: Verify tag matches package version
52+
env:
53+
TAG_NAME: ${{ needs.release-please.outputs.tag_name }}
54+
run: |
55+
TAG="${TAG_NAME#v}"
56+
PKG=$(uv run python -c "import repro_lambda; print(repro_lambda.__version__)")
57+
if [[ "$TAG" != "$PKG" ]]; then
58+
echo "tag $TAG != package version $PKG" >&2
59+
exit 1
60+
fi
61+
- name: Build sdist + wheel
62+
run: uv build
63+
- name: Publish to PyPI
64+
uses: pypa/gh-action-pypi-publish@release/v1
65+
with:
66+
packages-dir: dist/
67+
68+
major-tag:
69+
needs: release-please
70+
if: ${{ needs.release-please.outputs.release_created == 'true' }}
71+
runs-on: ubuntu-24.04
72+
permissions:
73+
contents: write
74+
steps:
75+
- uses: actions/checkout@v7
76+
with:
77+
fetch-depth: 0
78+
fetch-tags: true
79+
- name: Force-move sliding major tag
80+
env:
81+
TAG: ${{ needs.release-please.outputs.tag_name }}
82+
run: |
83+
MAJOR="${TAG%%.*}" # v0.4.1 -> v0
84+
git tag -f "$MAJOR" "$TAG"
85+
git push -f origin "refs/tags/$MAJOR"

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.6.0"
3+
}

release-please-config.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"packages": {
4+
".": {
5+
"release-type": "python",
6+
"package-name": "repro-lambda",
7+
"include-component-in-tag": false,
8+
"bump-minor-pre-major": true,
9+
"bump-patch-for-minor-pre-major": false,
10+
"changelog-path": "CHANGELOG.md",
11+
"extra-files": [
12+
"src/repro_lambda/__init__.py"
13+
],
14+
"changelog-sections": [
15+
{ "type": "feat", "section": "Features" },
16+
{ "type": "fix", "section": "Bug Fixes" },
17+
{ "type": "perf", "section": "Performance Improvements" },
18+
{ "type": "refactor", "section": "Code Refactoring" },
19+
{ "type": "docs", "section": "Documentation" },
20+
{ "type": "test", "section": "Tests", "hidden": true },
21+
{ "type": "chore", "section": "Miscellaneous", "hidden": true },
22+
{ "type": "ci", "section": "Continuous Integration", "hidden": true }
23+
]
24+
}
25+
}
26+
}

src/repro_lambda/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""repro-lambda — reproducible AWS Lambda packaging outside Terraform."""
22

3-
__version__ = "0.6.0"
3+
__version__ = "0.6.0" # x-release-please-version

0 commit comments

Comments
 (0)