-
Notifications
You must be signed in to change notification settings - Fork 1
98 lines (79 loc) · 2.85 KB
/
publish_stable.yml
File metadata and controls
98 lines (79 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Publish Stable to PyPI
on:
push:
branches: [ "main" ]
permissions:
contents: write
concurrency:
group: publish-stable
cancel-in-progress: false
jobs:
publish:
name: Bump version and publish je_web_runner to PyPI
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip-publish]')"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build tooling
run: |
python -m pip install --upgrade pip
pip install build twine tomlkit
- name: Bump patch version in pyproject.toml
id: bump
run: |
python - <<'PY'
import os
import tomlkit
path = "pyproject.toml"
with open(path, "r", encoding="utf-8") as f:
doc = tomlkit.parse(f.read())
current = str(doc["project"]["version"])
parts = current.split(".")
if len(parts) != 3 or not all(p.isdigit() for p in parts):
raise SystemExit(f"Unexpected version format: {current}")
major, minor, patch = (int(p) for p in parts)
new_version = f"{major}.{minor}.{patch + 1}"
doc["project"]["version"] = new_version
with open(path, "w", encoding="utf-8", newline="\n") as f:
f.write(tomlkit.dumps(doc))
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as out:
out.write(f"old_version={current}\n")
out.write(f"new_version={new_version}\n")
print(f"Bumped {current} -> {new_version}")
PY
- name: Commit version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add pyproject.toml
git commit -m "Bump stable version to ${{ steps.bump.outputs.new_version }} [skip-publish]"
git tag "v${{ steps.bump.outputs.new_version }}"
git push origin HEAD:main
git push origin "v${{ steps.bump.outputs.new_version }}"
- name: Build distribution
run: python -m build
- name: Verify distribution metadata
run: python -m twine check dist/*
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: python -m twine upload dist/*
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: v${{ steps.bump.outputs.new_version }}
run: |
gh release create "$TAG" \
--title "$TAG" \
--generate-notes \
--verify-tag \
dist/*