Skip to content

Commit 7066a23

Browse files
committed
add package release workflows
1 parent e3b58f1 commit 7066a23

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

.github/workflows/ci.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test-and-build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Check out repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.11"
24+
25+
- name: Install project and build tooling
26+
run: |
27+
python -m pip install --upgrade pip
28+
python -m pip install -e . build twine
29+
30+
- name: Run CLI smoke tests
31+
run: python -m unittest discover -s tests -p "test_*.py" -v
32+
33+
- name: Build distribution artifacts
34+
run: python -m build
35+
36+
- name: Validate package metadata
37+
run: python -m twine check dist/*
38+
39+
- name: Verify built wheel entrypoints
40+
run: |
41+
python -m venv .release-smoke
42+
.release-smoke/bin/pip install --upgrade pip
43+
.release-smoke/bin/pip install dist/*.whl
44+
.release-smoke/bin/attend --help
45+
.release-smoke/bin/python -m always_attend --version

.github/workflows/release.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
id-token: write
11+
12+
jobs:
13+
build-release:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Check out repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.11"
24+
25+
- name: Verify tag matches project version
26+
env:
27+
GITHUB_REF_NAME: ${{ github.ref_name }}
28+
run: |
29+
python - <<'PY'
30+
import os
31+
import pathlib
32+
import tomllib
33+
34+
pyproject = pathlib.Path("pyproject.toml")
35+
data = tomllib.loads(pyproject.read_text(encoding="utf-8"))
36+
version = data["project"]["version"]
37+
expected_tag = f"v{version}"
38+
actual_tag = os.environ["GITHUB_REF_NAME"]
39+
40+
if actual_tag != expected_tag:
41+
raise SystemExit(f"Tag {actual_tag!r} does not match project version {expected_tag!r}.")
42+
PY
43+
44+
- name: Install release tooling
45+
run: |
46+
python -m pip install --upgrade pip
47+
python -m pip install -e . build twine
48+
49+
- name: Run CLI smoke tests
50+
run: python -m unittest discover -s tests -p "test_*.py" -v
51+
52+
- name: Build distribution artifacts
53+
run: python -m build
54+
55+
- name: Validate package metadata
56+
run: python -m twine check dist/*
57+
58+
- name: Publish GitHub release
59+
uses: softprops/action-gh-release@v2
60+
with:
61+
files: dist/*
62+
generate_release_notes: true
63+
64+
- name: Upload release artifacts
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: python-dist
68+
path: dist/
69+
70+
publish-pypi:
71+
needs: build-release
72+
runs-on: ubuntu-latest
73+
environment:
74+
name: pypi
75+
url: https://pypi.org/p/always-attend
76+
permissions:
77+
id-token: write
78+
79+
steps:
80+
- name: Download release artifacts
81+
uses: actions/download-artifact@v4
82+
with:
83+
name: python-dist
84+
path: dist/
85+
86+
- name: Publish to PyPI
87+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)