-
-
Notifications
You must be signed in to change notification settings - Fork 4
155 lines (130 loc) · 4.31 KB
/
Copy pathrelease.yml
File metadata and controls
155 lines (130 loc) · 4.31 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Release
on:
push:
pull_request:
permissions:
contents: read
jobs:
build-wheel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- name: Build wheel
run: uv build --wheel
- name: Upload wheel
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dist-wheel
path: dist/*.whl
if-no-files-found: error
build-sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- name: Build source distribution
run: uv build --sdist
- name: Upload source distribution
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dist-sdist
path: dist/*.tar.gz
if-no-files-found: error
lint-dist:
runs-on: ubuntu-latest
needs:
- build-wheel
- build-sdist
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- name: Download distributions
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: dist-*
path: dist
merge-multiple: true
- name: Verify wheel install
run: |
uv venv .venv-install-whl
source .venv-install-whl/bin/activate
uv pip install dist/*.whl
- name: Verify source install
run: |
uv venv .venv-install-tar
source .venv-install-tar/bin/activate
uv pip install dist/*.tar.gz
- name: Check package metadata
run: uvx twine check dist/*
- name: Check distribution contents
run: uvx pydistcheck --inspect dist/*
- name: Check source metadata
run: uvx pyroma dist/*.tar.gz
- name: Check wheel contents
run: uvx check-wheel-contents dist/*.whl
- name: Check source manifest
run: uvx check-manifest -v
publish-pypi:
runs-on: ubuntu-latest
needs: lint-dist
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
permissions:
id-token: write
steps:
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- name: Download distributions
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: dist-*
path: dist
merge-multiple: true
- name: Publish to PyPI
run: uv publish --trusted-publishing always
publish-github-release:
runs-on: ubuntu-latest
needs: lint-dist
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Download distributions
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: dist-*
path: dist
merge-multiple: true
- name: Extract release notes
env:
TAG_NAME: ${{ github.ref_name }}
run: |
version="${TAG_NAME#v}"
awk -v version="$version" '
index($0, "## [" version "]") == 1 { in_section = 1; next }
in_section && /^## / { exit }
in_section { print }
' CHANGELOG.md > release-notes.md
sed -i '1{/^$/d;}' release-notes.md
if ! grep -q '[^[:space:]]' release-notes.md; then
echo "No CHANGELOG.md section found for ${version}" >&2
exit 1
fi
- name: Update GitHub release notes
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.ref_name }}
run: gh release edit "$TAG_NAME" --notes-file release-notes.md
- name: Upload GitHub release assets
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.ref_name }}
run: gh release upload "$TAG_NAME" dist/*.whl dist/*.tar.gz --clobber