Skip to content

Commit cbc970d

Browse files
author
smkc
committed
ci: automate releases (release-please + PyPI publish)
1 parent 16278cd commit cbc970d

4 files changed

Lines changed: 56 additions & 0 deletions

File tree

.github/workflows/publish-pypi.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,25 @@ jobs:
3333
python -m pip install -r requirements-dev.txt
3434
python -m pip install build twine
3535
36+
- name: Verify version matches tag
37+
run: |
38+
python - << 'PY'
39+
import tomllib
40+
from pathlib import Path
41+
42+
tag = "${{ github.ref_name }}"
43+
if tag.startswith("v"):
44+
tag = tag[1:]
45+
46+
data = tomllib.loads(Path("pyproject.toml").read_text(encoding="utf-8"))
47+
version = data["project"]["version"]
48+
if version != tag:
49+
raise SystemExit(
50+
f"pyproject.toml version ({version}) does not match tag ({tag})"
51+
)
52+
print(f"OK: {version} == {tag}")
53+
PY
54+
3655
- name: Lint and typecheck
3756
run: |
3857
python tools/lint.py --strict
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
release-please:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: googleapis/release-please-action@v4
17+
with:
18+
token: ${{ secrets.GITHUB_TOKEN }}
19+
config-file: .release-please-config.json
20+
manifest-file: .release-please-manifest.json

.release-please-config.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"release-type": "python",
4+
"include-v-in-tag": true,
5+
"include-component-in-tag": false,
6+
"packages": {
7+
".": {
8+
"package-name": "ksef-client",
9+
"extra-files": ["pyproject.toml"]
10+
}
11+
}
12+
}
13+

.release-please-manifest.json

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

0 commit comments

Comments
 (0)