-
Notifications
You must be signed in to change notification settings - Fork 12
177 lines (155 loc) · 5.07 KB
/
release.yml
File metadata and controls
177 lines (155 loc) · 5.07 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Release
on:
push:
tags:
- "v*"
permissions: {}
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
verify-tag:
name: Verify release tag
runs-on: depot-ubuntu-24.04
permissions:
contents: read
outputs:
tag: ${{ steps.verify.outputs.tag }}
version: ${{ steps.verify.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Python and uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- id: verify
name: Verify tag matches pyproject.toml and main
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
version="${tag#v}"
project_version="$(uv version --short)"
if [[ "${version}" != "${project_version}" ]]; then
echo "::error::Tag ${tag} does not match project version ${project_version}."
exit 1
fi
if ! git merge-base --is-ancestor "${GITHUB_SHA}" "origin/main"; then
echo "::error::Tag ${tag} must point to a commit reachable from origin/main."
exit 1
fi
printf 'tag=%s\n' "${tag}" >> "${GITHUB_OUTPUT}"
printf 'version=%s\n' "${version}" >> "${GITHUB_OUTPUT}"
test:
name: Test
needs: verify-tag
permissions:
contents: read
uses: ./.github/workflows/test.yml
build:
name: Build release distributions
runs-on: depot-ubuntu-24.04
needs:
- verify-tag
- test
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Setup Python and uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- name: Build distributions
run: make build
- name: Upload distributions
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: python-package-distributions
path: dist/*
if-no-files-found: error
publish-github-draft:
name: Create GitHub draft release
runs-on: depot-ubuntu-24.04
needs:
- verify-tag
- build
permissions:
contents: write
steps:
- name: Download distributions
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: python-package-distributions
path: dist
- name: Create or update GitHub draft release
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
with:
tag: ${{ needs.verify-tag.outputs.tag }}
name: ${{ needs.verify-tag.outputs.tag }}
draft: true
allowUpdates: true
artifacts: dist/*
artifactErrorsFailBuild: true
generateReleaseNotes: true
makeLatest: false
removeArtifacts: true
skipIfReleaseExists: true
updateOnlyUnreleased: true
publish-testpypi:
name: Publish package distributions to TestPyPI
runs-on: depot-ubuntu-24.04
needs:
- verify-tag
- build
- publish-github-draft
environment:
name: testpypi
url: https://test.pypi.org/project/graphon/${{ needs.verify-tag.outputs.version }}/
permissions:
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: python-package-distributions
path: dist
- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
publish-pypi:
name: Publish package distributions to PyPI
runs-on: depot-ubuntu-24.04
needs:
- verify-tag
- build
- publish-testpypi
environment:
name: pypi
url: https://pypi.org/project/graphon/${{ needs.verify-tag.outputs.version }}/
permissions:
contents: write
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: python-package-distributions
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1
- name: Publish GitHub draft release
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
with:
tag: ${{ needs.verify-tag.outputs.tag }}
allowUpdates: true
draft: false
makeLatest: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
skipIfReleaseExists: true
updateOnlyUnreleased: true