Repository navigation
210 lines (203 loc) · 7.69 KB
/
Copy pathrelease.yml
File metadata and controls
210 lines (203 loc) · 7.69 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
name: Tagged Python release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
mode:
description: Manual workflow mode
type: choice
required: true
default: build-and-test
options:
- build-and-test
- promote-pypi
release_tag:
description: 'Version tag for branch builds (e.g. v0.0.1); leave empty when running at a tag. No Git tag is created.'
type: string
required: false
permissions:
contents: read
concurrency:
group: python-release-${{ github.ref }}-${{ inputs.mode == 'build-and-test' && 'validation' || 'release' }}
cancel-in-progress: false
jobs:
build:
if: >-
${{ github.event_name == 'push' ||
(github.event_name == 'workflow_dispatch' && inputs.mode == 'build-and-test') }}
runs-on: ubuntu-24.04
timeout-minutes: 15
outputs:
version: ${{ steps.tag.outputs.version }}
prerelease: ${{ steps.tag.outputs.prerelease }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: '3.12'
- name: Install release tools
run: python -m pip install --disable-pip-version-check -r requirements/release.txt
- name: Resolve package version from release tag
id: tag
env:
INPUT_RELEASE_TAG: ${{ inputs.release_tag }}
REF_TYPE: ${{ github.ref_type }}
REF_NAME: ${{ github.ref_name }}
run: |
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" && -n "$INPUT_RELEASE_TAG" ]]; then
RELEASE_TAG="$INPUT_RELEASE_TAG"
elif [[ "$REF_TYPE" == "tag" ]]; then
RELEASE_TAG="$REF_NAME"
else
echo "Manual branch builds require release_tag, for example v0.0.1. No Git tag needs to exist." >&2
exit 1
fi
python scripts/release_artifacts.py check-tag "$RELEASE_TAG" --github-output "$GITHUB_OUTPUT"
- name: Build release distributions once
env:
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RUNTIMECONDITIONS_PROFILER: ${{ steps.tag.outputs.version }}
run: python -m build
- name: Validate metadata and distribution contents
env:
RELEASE_VERSION: ${{ steps.tag.outputs.version }}
run: |
python -m twine check --strict dist/*.whl dist/*.tar.gz
mkdir -p release-evidence
python scripts/check_distributions.py dist/*.whl dist/*.tar.gz --expected-version "$RELEASE_VERSION" > release-evidence/contents.json
python scripts/release_artifacts.py checksums --dist-dir dist
- name: Run self-contained regression tests
run: |
wheel=(dist/*.whl)
python -m pip install "${wheel[0]}[test]"
python -m pytest -q
- name: Preserve exact release distributions
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: release-distributions
path: |
dist/*.whl
dist/*.tar.gz
dist/SHA256SUMS
if-no-files-found: error
retention-days: 30
- name: Preserve distribution validation evidence
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: distribution-evidence
path: release-evidence/
if-no-files-found: error
smoke:
needs: build
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04]
python: ['3.11', '3.12', '3.13', '3.14']
include:
- os: macos-14
python: '3.12'
- os: windows-2022
python: '3.12'
runs-on: ${{ matrix.os }}
timeout-minutes: 20
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: ${{ matrix.python }}
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: release-distributions
path: dist
- name: Install and smoke-check both exact artifacts
shell: bash
env:
RELEASE_VERSION: ${{ needs.build.outputs.version }}
run: python scripts/smoke_install.py --dist-dir dist --report release-evidence/smoke.json --expected-version "$RELEASE_VERSION"
- name: Preserve installed-package evidence
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: smoke-${{ matrix.os }}-python-${{ matrix.python }}
path: release-evidence/
if-no-files-found: warn
release:
needs: [build, smoke]
if: github.event_name == 'push' && github.ref_type == 'tag'
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: write
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: release-distributions
path: dist
- name: Attach verified assets and publish the GitHub Release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ github.ref_name }}
RELEASE_COMMIT: ${{ github.sha }}
IS_PRERELEASE: ${{ needs.build.outputs.prerelease }}
run: |
args=()
if [[ "$IS_PRERELEASE" == "true" ]]; then
args+=(--prerelease)
fi
python3 scripts/release_artifacts.py publish --dist-dir dist \
--repository "$GITHUB_REPOSITORY" --tag "$RELEASE_TAG" \
--commit "$RELEASE_COMMIT" "${args[@]}"
pypi:
needs: release
if: >-
${{ !cancelled() && vars.PYPI_PUBLISH_ENABLED == 'true' &&
github.ref_type == 'tag' &&
((github.event_name == 'push' && needs.release.result == 'success') ||
(github.event_name == 'workflow_dispatch' && inputs.mode == 'promote-pypi' &&
needs.release.result == 'skipped')) }}
runs-on: ubuntu-24.04
timeout-minutes: 10
environment:
name: pypi
url: https://pypi.org/p/runtimeconditions-profiler
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: '3.12'
- name: Install artifact validation dependency
run: python -m pip install --disable-pip-version-check packaging==26.3
- name: Download and verify the published GitHub Release assets
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ github.ref_name }}
RELEASE_COMMIT: ${{ github.sha }}
run: |
python scripts/release_artifacts.py prepare-pypi \
--repository "$GITHUB_REPOSITORY" --tag "$RELEASE_TAG" \
--commit "$RELEASE_COMMIT" --dist-dir release-assets \
--packages-dir pypi-dist
- name: Publish the exact verified distributions to PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
packages-dir: pypi-dist/
attestations: true
print-hash: true