Repository navigation
141 lines (122 loc) · 3.93 KB
/
Copy pathrelease.yml
File metadata and controls
141 lines (122 loc) · 3.93 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Releases t3api-utils when a version tag (e.g. v2.0.0) is pushed:
# 1. build: check the tag matches pyproject's version and CHANGELOG.md has
# a section for it, then build the sdist and wheel;
# 2. publish: upload to PyPI through trusted publishing;
# 3. github-release: create the GitHub release, with the CHANGELOG.md
# section as its notes and the distributions attached;
# 4. docs: deploy the docs site to the gh-pages branch, so
# https://classvsoftware.github.io/t3api-python-utils/ matches the
# version on PyPI.
#
# PyPI needs a trusted publisher for this to upload:
# https://pypi.org/manage/project/t3api-utils/settings/publishing/
# GitHub publisher: owner "classvsoftware", repository "t3api-python-utils",
# workflow "release.yml", environment "pypi".
# If it's missing, the publish job fails and nothing is released; add it and
# re-run the failed jobs.
#
# Release checklist: bump the version in pyproject.toml, add a CHANGELOG.md
# section headed "## X.Y.Z", run scripts/update_spec.py and the sandbox smoke
# tests, wait for CI to pass, then push the tag vX.Y.Z.
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: read
jobs:
build:
name: Build distributions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v7
- name: Check the tag matches the package version
run: |
version=$(uv version --short)
tag="${GITHUB_REF_NAME#v}"
if [ "$version" != "$tag" ]; then
echo "Release tag $GITHUB_REF_NAME doesn't match pyproject version $version" >&2
exit 1
fi
- name: Extract the release notes from CHANGELOG.md
run: |
version="${GITHUB_REF_NAME#v}"
awk -v heading="## $version" '
$0 == heading { found = 1; next }
found && /^## / { exit }
found { print }
' CHANGELOG.md > notes.md
if ! grep -q '[^[:space:]]' notes.md; then
echo "CHANGELOG.md has no '## $version' section" >&2
exit 1
fi
- name: Build
run: uv build
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
if-no-files-found: error
- uses: actions/upload-artifact@v7
with:
name: notes
path: notes.md
if-no-files-found: error
publish:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/t3api-utils/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
github-release:
name: Create GitHub release
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- uses: actions/download-artifact@v8
with:
name: notes
- name: Create the release
env:
GH_TOKEN: ${{ github.token }}
run: >-
gh release create "$GITHUB_REF_NAME" dist/*
--repo "$GITHUB_REPOSITORY"
--title "t3api-utils ${GITHUB_REF_NAME#v}"
--notes-file notes.md
--verify-tag
docs:
name: Deploy docs
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: uv sync
- name: Deploy to GitHub Pages
env:
NO_MKDOCS_2_WARNING: "1"
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git fetch origin gh-pages:gh-pages || true
uv run mkdocs gh-deploy --strict