Skip to content

Commit 6efcb2f

Browse files
authored
fix: align metadata with defaults and auto-publish docs on merge to main (#51)
* fix: align pyproject.toml and Dockerfile metadata with project_defaults.json Reset project name, description, author, email, and URLs to match the canonical values in project_defaults.json. * feat(ci): auto-publish docs to GitHub Pages on merge to main Add publish-docs job to CI that runs task doc-publish (ghp-import) only on push events to main, after quality and test jobs pass. Scoped to least-privilege contents:write permission. * chore: update uv.lock after project name change to python-project-template
1 parent cfd466f commit 6efcb2f

File tree

5 files changed

+132
-54
lines changed

5 files changed

+132
-54
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ on:
1010
permissions:
1111
contents: read
1212
actions: read
13+
pages: write
14+
id-token: write
1315

1416
env:
1517
# Improve pip performance
@@ -158,6 +160,39 @@ jobs:
158160
path: docs/api/
159161
retention-days: 30
160162

163+
publish-docs:
164+
name: Publish Documentation
165+
runs-on: ubuntu-latest
166+
needs: [quality, test]
167+
# Only run when a PR is merged to main (push event), not on PRs
168+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
169+
permissions:
170+
contents: write
171+
172+
steps:
173+
- name: Checkout code
174+
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.1
175+
176+
- name: Install uv
177+
uses: astral-sh/setup-uv@cdfb2ee6dde255817c739680168ad81e184c4bfb # v4.0.0
178+
with:
179+
enable-cache: true
180+
cache-dependency-glob: "uv.lock"
181+
182+
- name: Set up Python 3.13
183+
run: uv python install 3.13
184+
185+
- name: Install dependencies
186+
run: uv sync --locked --all-extras --dev
187+
188+
- name: Build and publish documentation
189+
run: uv run task doc-publish
190+
env:
191+
GIT_AUTHOR_NAME: github-actions[bot]
192+
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
193+
GIT_COMMITTER_NAME: github-actions[bot]
194+
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
195+
161196
# Security summary job
162197
security-summary:
163198
name: Security Summary

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ CMD ["python", "-m", "python_package_template.python_module_template"]
4646

4747
# Labels
4848
LABEL maintainer="eol"
49-
LABEL version="2.0.20260411"
50-
LABEL description="Python project template - simplified Docker setup"
49+
LABEL version="3.0.20260414"
50+
LABEL description="Python template with some awesome tools to quickstart any Python project"
5151
LABEL org.opencontainers.image.source="https://github.com/nullhack/python-project-template"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Feature: Auto-Publish Documentation on Merge to Main
2+
3+
## User Stories
4+
- As a maintainer, I want documentation to be automatically built and published to GitHub Pages every time a PR is merged to main, so that the published docs are always in sync with the latest code.
5+
6+
## Acceptance Criteria
7+
8+
- `e9b6be8c-c786-4113-9920-f098a954869d`: Docs publish job only runs on push to main.
9+
Given: A workflow event is triggered
10+
When: The event is a pull_request (not a merge to main)
11+
Then: The docs publish job is skipped
12+
Test strategy: integration
13+
14+
- `75619a7d-7eb8-45ac-901c-b86486c30690`: Docs are built before publishing.
15+
Given: A commit is merged to main
16+
When: The publish job runs
17+
Then: `task doc-build` runs successfully and produces output in `docs/api/` and `docs/coverage/`
18+
Test strategy: integration
19+
20+
- `23cf4a4e-3960-458d-994d-efea5d854895`: Docs are published to GitHub Pages.
21+
Given: The doc-build step succeeded
22+
When: The publish step runs
23+
Then: `ghp-import` (or equivalent) deploys the `docs/` directory to the `gh-pages` branch
24+
Test strategy: integration
25+
26+
- `c580dcb9-00c7-4124-9762-70ff1192bd09`: Publish job runs only after quality and tests pass.
27+
Given: The quality or test job fails
28+
When: The CI workflow runs on main
29+
Then: The publish job does not execute
30+
Test strategy: integration
31+
32+
- `c942990a-a69c-473e-a820-8ce51e337262`: Workflow has least-privilege permissions for Pages deployment.
33+
Given: The publish job needs to write to GitHub Pages
34+
When: The job is defined
35+
Then: It has `contents: write` (or `pages: write` + `id-token: write`) and no broader permissions
36+
Test strategy: integration
37+
38+
## Notes
39+
- GitHub Pages must be configured on the repo (source: `gh-pages` branch or GitHub Actions deployment)
40+
- The existing `task doc-publish` already runs `ghp-import -n -p -f docs` — reuse it or inline the equivalent steps
41+
- Out of scope: publishing on tags/releases (covered by git-release skill), PR preview deployments
42+
- Out of scope: changing the docs toolchain (pdoc stays)
43+
- Priority: Must

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
[project]
2-
name = "test-project"
2+
name = "python-project-template"
33
version = "3.0.20260414"
4-
description = "A test project"
4+
description = "Python template with some awesome tools to quickstart any Python project"
55
readme = "README.md"
66
requires-python = ">=3.13"
77
license = { file = "LICENSE" }
88
authors = [
9-
{ name = "Test Author", email = "testuser@users.noreply.github.com" }
9+
{ name = "eol", email = "nullhack@users.noreply.github.com" }
1010
]
1111
maintainers = [
12-
{ name = "Test Author", email = "testuser@users.noreply.github.com" }
12+
{ name = "eol", email = "nullhack@users.noreply.github.com" }
1313
]
1414
dependencies = [
1515
"fire>=0.7.1",
1616
]
1717

1818
[project.urls]
19-
Repository = "https://github.com/testuser/test-project"
20-
Documentation = "https://github.com/testuser/test-project/tree/main/docs/api/"
19+
Repository = "https://github.com/nullhack/python-project-template"
20+
Documentation = "https://github.com/nullhack/python-project-template/tree/main/docs/api/"
2121

2222
[project.optional-dependencies]
2323
dev = [

uv.lock

Lines changed: 46 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)