Repository navigation
280 lines (260 loc) · 11.1 KB
/
Copy pathpython-nightly.yml
File metadata and controls
280 lines (260 loc) · 11.1 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
name: python-publish
on:
schedule:
- cron: '17 8 * * *'
workflow_dispatch:
inputs:
channel:
description: Package channel to publish
required: true
default: nightly
type: choice
options:
- nightly
- stable
expected_version:
description: Exact source version to publish (required for stable)
required: false
type: string
smoke_tested_commit:
description: Full master commit SHA smoke-tested on a test cluster (required for stable)
required: false
type: string
concurrency:
group: python-publish-${{ inputs.channel || 'nightly' }}
cancel-in-progress: false
permissions:
contents: read
env:
NIGHTLY_VERSION: 0.3.1
jobs:
build:
runs-on: ubuntu-latest
outputs:
channel: ${{ steps.version.outputs.channel }}
version: ${{ steps.version.outputs.version }}
commit: ${{ steps.version.outputs.commit }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '3.12'
- name: Install pinned pip
run: python -m pip install "pip @ https://files.pythonhosted.org/packages/3f/06/3e4420302363fbb71be3c7f35ce042f54bfca330e3e66b3a2e3c4cca579f/pip-26.2.2-py3-none-any.whl#sha256=fd7f4dfa8190e014013b9f08f3e973f4e4c26ffd179a204895533a7254813a70"
- name: Select the publication version
id: version
env:
DISPATCH_CHANNEL: ${{ inputs.channel }}
run: |
commit="$(git rev-parse HEAD)"
test "$commit" = "$GITHUB_SHA"
source_version="$(python -c 'import cmax; print(cmax.__version__)')"
channel="${DISPATCH_CHANNEL:-nightly}"
case "$channel" in
stable)
version="$source_version"
;;
nightly)
date_utc="$(date -u +%Y%m%d)"
version="$(python .github/scripts/nightly_version.py \
--release-version "$NIGHTLY_VERSION" \
--date "$date_utc" \
--run-number "$GITHUB_RUN_NUMBER")"
;;
*)
echo "Unknown publication channel: $channel" >&2
exit 1
;;
esac
echo "channel=$channel" >> "$GITHUB_OUTPUT"
echo "commit=$commit" >> "$GITHUB_OUTPUT"
echo "source_version=$source_version" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "### ClusterMAX publication" >> "$GITHUB_STEP_SUMMARY"
echo "- Channel: \`$channel\`" >> "$GITHUB_STEP_SUMMARY"
echo "- Version: \`$version\`" >> "$GITHUB_STEP_SUMMARY"
echo "- Commit: \`$commit\`" >> "$GITHUB_STEP_SUMMARY"
- name: Check stable publication inputs and collisions
if: steps.version.outputs.channel == 'stable'
env:
GH_TOKEN: ${{ github.token }}
RELEASE_CHANNEL: ${{ steps.version.outputs.channel }}
EXPECTED_VERSION: ${{ inputs.expected_version }}
SMOKE_TESTED_COMMIT: ${{ inputs.smoke_tested_commit }}
VERSION: ${{ steps.version.outputs.version }}
COMMIT: ${{ steps.version.outputs.commit }}
run: |
python .github/scripts/stable_release.py preflight --version "$VERSION" --commit "$COMMIT"
test -s "docs/releases/${VERSION}.md"
- name: Test the exact stable commit
if: steps.version.outputs.channel == 'stable'
run: |
python -m pip install pytest pytest-xdist pyyaml prompt-toolkit packaging
python -m pytest -q
- name: Build the distributions
env:
CLUSTERMAX_BUILD_VERSION: ${{ steps.version.outputs.version }}
SOURCE_VERSION: ${{ steps.version.outputs.source_version }}
run: |
python -m pip install \
--require-hashes \
--only-binary=:all: \
--disable-pip-version-check \
-r .github/requirements/release.txt
python -m build --no-isolation
python -m twine check dist/*
check-wheel-contents dist/clustermax-*.whl
test "$(python -c 'import cmax; print(cmax.__version__)')" = "$SOURCE_VERSION"
- name: Verify the wheel
env:
EXPECTED_VERSION: ${{ steps.version.outputs.version }}
run: |
python -m venv /tmp/clustermax-publication
/tmp/clustermax-publication/bin/python -m pip install "pip @ https://files.pythonhosted.org/packages/3f/06/3e4420302363fbb71be3c7f35ce042f54bfca330e3e66b3a2e3c4cca579f/pip-26.2.2-py3-none-any.whl#sha256=fd7f4dfa8190e014013b9f08f3e973f4e4c26ffd179a204895533a7254813a70"
/tmp/clustermax-publication/bin/pip install dist/clustermax-*.whl
cd /tmp
test "$(/tmp/clustermax-publication/bin/cmax --version)" = "cmax ${EXPECTED_VERSION}"
/tmp/clustermax-publication/bin/cmax audit --show
/tmp/clustermax-publication/bin/cmax audit security --show
- name: Bind artifacts and release notes to the commit
env:
VERSION: ${{ steps.version.outputs.version }}
COMMIT: ${{ steps.version.outputs.commit }}
RELEASE_CHANNEL: ${{ steps.version.outputs.channel }}
run: |
mkdir -p publication/dist
cp dist/* publication/dist/
args=()
if [[ "$RELEASE_CHANNEL" == stable ]]; then
args+=(--notes "docs/releases/${VERSION}.md")
fi
python .github/scripts/stable_release.py prepare \
--version "$VERSION" --commit "$COMMIT" "${args[@]}"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: clustermax-${{ steps.version.outputs.version }}-${{ steps.version.outputs.commit }}
path: publication/
if-no-files-found: error
retention-days: ${{ steps.version.outputs.channel == 'stable' && 90 || 14 }}
publish:
if: github.repository == 'SemiAnalysisAI/ClusterMAX' && github.ref == 'refs/heads/master'
needs: build
runs-on: ubuntu-latest
environment:
name: ${{ needs.build.outputs.channel == 'nightly' && 'pypi-nightly' || 'pypi' }}
url: https://pypi.org/project/clustermax/
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '3.12'
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: clustermax-${{ needs.build.outputs.version }}-${{ needs.build.outputs.commit }}
path: publication/
- name: Verify the approved artifacts
env:
VERSION: ${{ needs.build.outputs.version }}
COMMIT: ${{ github.sha }}
RELEASE_CHANNEL: ${{ needs.build.outputs.channel }}
run: |
args=()
if [[ "$RELEASE_CHANNEL" == stable ]]; then args+=(--stable); fi
python .github/scripts/stable_release.py verify \
--version "$VERSION" --commit "$COMMIT" "${args[@]}"
- name: Recheck stable publication after approval
if: needs.build.outputs.channel == 'stable'
env:
GH_TOKEN: ${{ github.token }}
RELEASE_CHANNEL: ${{ needs.build.outputs.channel }}
EXPECTED_VERSION: ${{ inputs.expected_version }}
SMOKE_TESTED_COMMIT: ${{ inputs.smoke_tested_commit }}
VERSION: ${{ needs.build.outputs.version }}
COMMIT: ${{ github.sha }}
run: |
python .github/scripts/stable_release.py preflight --version "$VERSION" --commit "$COMMIT"
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # release/v1
with:
packages-dir: publication/dist/
verify-pypi:
if: >-
github.repository == 'SemiAnalysisAI/ClusterMAX' &&
github.ref == 'refs/heads/master' &&
github.event_name == 'workflow_dispatch' &&
needs.build.outputs.channel == 'stable'
needs: [build, publish]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '3.12'
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: clustermax-${{ needs.build.outputs.version }}-${{ needs.build.outputs.commit }}
path: publication/
- name: Verify PyPI hashes and download the published wheel
env:
VERSION: ${{ needs.build.outputs.version }}
COMMIT: ${{ github.sha }}
run: |
python .github/scripts/stable_release.py verify-pypi \
--version "$VERSION" --commit "$COMMIT"
- name: Smoke-test the wheel fetched from PyPI
env:
VERSION: ${{ needs.build.outputs.version }}
run: |
python -m venv /tmp/clustermax-from-pypi
/tmp/clustermax-from-pypi/bin/python -m pip --isolated install \
--index-url https://pypi.org/simple --no-cache-dir \
"/tmp/clustermax-pypi-wheel/clustermax-${VERSION}-py3-none-any.whl"
cd /tmp
test "$(/tmp/clustermax-from-pypi/bin/cmax --version)" = "cmax ${VERSION}"
/tmp/clustermax-from-pypi/bin/cmax audit --show
/tmp/clustermax-from-pypi/bin/cmax audit security --show
/tmp/clustermax-from-pypi/bin/cmax audit security --standalone --dry-run -o yaml
github-release:
if: >-
github.repository == 'SemiAnalysisAI/ClusterMAX' &&
github.ref == 'refs/heads/master' &&
github.event_name == 'workflow_dispatch' &&
needs.build.outputs.channel == 'stable'
needs: [build, verify-pypi]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '3.12'
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: clustermax-${{ needs.build.outputs.version }}-${{ needs.build.outputs.commit }}
path: publication/
- name: Create or resume the matching GitHub Release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_CHANNEL: ${{ needs.build.outputs.channel }}
VERSION: ${{ needs.build.outputs.version }}
COMMIT: ${{ github.sha }}
run: |
python .github/scripts/stable_release.py github-release \
--version "$VERSION" --commit "$COMMIT"