77
88env :
99 SOURCE_DATE_EPOCH : " 1763060600"
10- BITCOIN_CORE_ARCHIVE : bitcoin-32.0rc2-x86_64-linux-gnu.tar.gz
11- BITCOIN_CORE_SHA256 : 0255103718033e6aee15fa944717fc277e047b845bff1e7408af0ea732d8d0c1
12- BITCOIN_CORE_URL : https://bitcoincore.org/bin/bitcoin-core-32.0/test.rc2
1310
1411permissions :
1512 contents : read
@@ -19,42 +16,50 @@ jobs:
1916 runs-on : ubuntu-latest
2017 permissions :
2118 contents : read
19+ actions : read
2220 outputs :
2321 python_versions : ${{ steps.metadata.outputs.python_versions }}
24- version : ${{ steps.metadata.outputs.version }}
22+ prerelease : ${{ steps.metadata.outputs.prerelease }}
2523 steps :
2624 - uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
25+ - name : Require successful source CI
26+ env :
27+ GH_TOKEN : ${{ github.token }}
28+ run : |
29+ test "$(gh run list --repo "$GITHUB_REPOSITORY" --commit "$GITHUB_SHA" \
30+ --workflow python-package.yml --status completed --limit 1 \
31+ --json conclusion --jq '.[0].conclusion')" = success
2732 - uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2833 with :
2934 python-version : " 3.13"
35+ - run : >-
36+ python -m pip install --require-hashes
37+ -r requirements/release-build-dependencies.txt
3038 - id : metadata
3139 name : Check release metadata
3240 run : |
3341 python - <<'PY'
3442 import json
3543 import os
3644 import tomllib
45+ from packaging.version import Version
3746
3847 with open("pyproject.toml", "rb") as file:
3948 project = tomllib.load(file)["project"]
40- version = project["version"]
41- if os.environ["GITHUB_REF_NAME"] != f"v{version}":
49+ version = Version( project["version"])
50+ if os.environ["GITHUB_REF_NAME"] != f"v{project[' version'] }":
4251 raise SystemExit("release tag does not match package version")
4352 prefix = "Programming Language :: Python :: "
4453 versions = sorted(
45- classifier.removeprefix(prefix)
46- for classifier in project["classifiers"]
47- if classifier.startswith(prefix) and classifier.removeprefix(prefix).count(".") == 1
54+ item.removeprefix(prefix) for item in project["classifiers"]
55+ if item.startswith(prefix) and item.removeprefix(prefix).count(".") == 1
4856 )
4957 if not versions:
5058 raise SystemExit("no supported Python versions are classified")
5159 with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
52- output.write(f"version={version }\n")
53- output.write(f"python_versions={json.dumps(versions, separators=(',', ':') )}\n")
60+ output.write(f"python_versions={json.dumps(versions) }\n")
61+ output.write(f"prerelease={str(version.is_prerelease).lower( )}\n")
5462 PY
55- - run : >-
56- python -m pip install --require-hashes
57- -r requirements/release-build-dependencies.txt
5863 - run : python -m build --no-isolation
5964 - name : Normalize source-archive metadata
6065 run : |
@@ -64,213 +69,79 @@ jobs:
6469 tar --sort=name --mtime="@${SOURCE_DATE_EPOCH}" --owner=0 --group=0 --numeric-owner \
6570 -C normalized-sdist -cf - "codex32-${GITHUB_REF_NAME#v}" | gzip -n > "$archive.new"
6671 mv "$archive.new" "$archive"
67- - name : Record built artifact provenance
72+ - name : Record artifact hashes and source
6873 run : |
69- mkdir provenance
70- git rev-parse HEAD > provenance/source-commit.txt
71- sha256sum dist/* > provenance/artifact-sha256.txt
72- python -m pip freeze --all > provenance/build-environment.txt
74+ sha256sum dist/* > SHA256SUMS
75+ git rev-parse HEAD > SOURCE_COMMIT
7376 - uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
7477 with :
7578 name : distributions
76- path : dist/
77- - uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
78- with :
79- name : build-provenance
80- path : provenance/
79+ path : |
80+ dist/
81+ SHA256SUMS
82+ SOURCE_COMMIT
8183
82- supported-matrix :
84+ qualify :
8385 needs : build
8486 strategy :
8587 fail-fast : false
8688 matrix :
8789 os : [ubuntu-latest, macos-latest, windows-latest]
8890 python-version : ${{ fromJSON(needs.build.outputs.python_versions) }}
8991 runs-on : ${{ matrix.os }}
92+ defaults :
93+ run :
94+ shell : bash
9095 steps :
9196 - uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
9297 - uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
9398 with :
9499 python-version : ${{ matrix.python-version }}
95100 allow-prereleases : true
96- - run : python -m pip install --upgrade pip
97- - run : python -m pip install --require-hashes -r requirements/cli-build-dependencies.txt
98- - name : Install legacy wallet-test oracle when present
99- shell : bash
100- run : |
101- if [[ -f requirements/test-wallet-dependencies.txt ]]; then
102- python -m pip install --no-build-isolation --require-hashes \
103- -r requirements/test-wallet-dependencies.txt
104- fi
105- - run : python -m pip install --no-build-isolation -e '.[dev]'
106- - run : python -m pip check
107- - run : python -m pytest -q
108101 - uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
109102 with :
110103 name : distributions
111- path : dist/
112- - name : Install and test the exact wheel and sdist
113- shell : bash
104+ - name : Install and smoke-test the exact wheel and sdist
114105 run : |
106+ sha256sum --check SHA256SUMS
115107 for artifact in dist/codex32-*.whl dist/codex32-*.tar.gz; do
116108 python tools/verify_wheel_environment.py --artifact "$artifact"
117109 done
118- - name : Record qualification dependencies
119- shell : bash
120- run : >-
121- python -m pip freeze --all >
122- "qualification-${RUNNER_OS}-${{ matrix.python-version }}.txt"
123- - uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
124- with :
125- name : qualification-${{ runner.os }}-${{ matrix.python-version }}
126- path : qualification-*.txt
127-
128- quality :
129- needs : build
130- runs-on : ubuntu-latest
131- steps :
132- - uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
133- - uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
134- with :
135- python-version : " 3.13"
136- - run : python -m pip install --upgrade pip
137- - run : python -m pip install --require-hashes -r requirements/cli-build-dependencies.txt
138- - name : Install legacy wallet-test oracle when present
139- run : |
140- if [[ -f requirements/test-wallet-dependencies.txt ]]; then
141- python -m pip install --no-build-isolation --require-hashes \
142- -r requirements/test-wallet-dependencies.txt
143- fi
144- - run : python -m pip install --no-build-isolation -e '.[dev]'
145- - run : python -O -m pytest -q
146- - run : python -m mypy src/codex32
147- - run : python -m ruff check .
148- - run : python -m ruff format --check .
149- - run : python tools/differential_correction.py --verify
150- - name : Run legacy wallet differential when present
151- run : |
152- if [[ -f tools/differential_wallet.py ]]; then
153- python tools/differential_wallet.py --verify
154- fi
155-
156- bitcoin-core :
157- needs : build
158- runs-on : ubuntu-latest
159- steps :
160- - uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
161- - uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
162- with :
163- python-version : " 3.13"
164- - uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
165- with :
166- name : distributions
167- path : dist/
168- - name : Install qualified wheel
169- run : python -m pip install --no-deps dist/codex32-*.whl
170- - name : Download pinned Bitcoin Core
171- run : |
172- curl --fail --location --proto '=https' --tlsv1.2 \
173- --output "$RUNNER_TEMP/$BITCOIN_CORE_ARCHIVE" \
174- "$BITCOIN_CORE_URL/$BITCOIN_CORE_ARCHIVE"
175- echo "$BITCOIN_CORE_SHA256 $RUNNER_TEMP/$BITCOIN_CORE_ARCHIVE" | sha256sum --check
176- tar -xzf "$RUNNER_TEMP/$BITCOIN_CORE_ARCHIVE" -C "$RUNNER_TEMP"
177- - name : Run real-Core release integration
178- env :
179- PYTHONNOUSERSITE : " 1"
180- run : |
181- core="$RUNNER_TEMP/bitcoin-32.0rc2/bin"
182- "$core/bitcoind" --version | head -1 | tee bitcoin-core-version.txt
183- python tools/bitcoin_core_regtest.py \
184- --bitcoind "$core/bitcoind" \
185- --bitcoin-cli "$core/bitcoin-cli"
186- - uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
187- with :
188- name : bitcoin-core-provenance
189- path : bitcoin-core-version.txt
190110
191111 publish :
192- needs : [build, supported-matrix, quality, bitcoin-core]
112+ needs : [build, qualify]
113+ # Stable publication waits for the required Core qualification job (#207).
114+ if : needs.build.outputs.prerelease == 'true'
193115 runs-on : ubuntu-latest
194116 environment :
195117 name : pypi
196118 url : https://pypi.org/p/codex32
197119 permissions :
198120 contents : write
199121 id-token : write
122+ env :
123+ GH_REPO : ${{ github.repository }}
124+ GH_TOKEN : ${{ github.token }}
125+ PRERELEASE : ${{ needs.build.outputs.prerelease }}
200126 steps :
201127 - uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
202128 with :
203129 name : distributions
204- path : dist/
205- - uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
206- with :
207- name : build-provenance
208- path : provenance/
209- - uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
210- with :
211- name : bitcoin-core-provenance
212- path : provenance/
213- - uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
214- with :
215- pattern : qualification-*
216- path : provenance/dependencies/
217- merge-multiple : true
218130 - name : Verify qualified artifact bytes
219- run : sha256sum --check provenance/artifact-sha256.txt
220- - name : Record release qualification
221- env :
222- RELEASE_VERSION : ${{ needs.build.outputs.version }}
223- MATRIX_RESULT : ${{ needs.supported-matrix.result }}
224- QUALITY_RESULT : ${{ needs.quality.result }}
225- CORE_RESULT : ${{ needs.bitcoin-core.result }}
226- run : |
227- python - <<'PY'
228- import json
229- import os
230- from pathlib import Path
231-
232- hashes = {}
233- for line in Path("provenance/artifact-sha256.txt").read_text().splitlines():
234- digest, path = line.split(maxsplit=1)
235- hashes[Path(path).name] = digest
236- record = {
237- "source_commit": Path("provenance/source-commit.txt").read_text().strip(),
238- "tag": os.environ["GITHUB_REF_NAME"],
239- "version": os.environ["RELEASE_VERSION"],
240- "bitcoin_core": Path("provenance/bitcoin-core-version.txt").read_text().strip(),
241- "artifact_sha256": hashes,
242- "qualification": {
243- "supported_matrix": os.environ["MATRIX_RESULT"],
244- "quality": os.environ["QUALITY_RESULT"],
245- "bitcoin_core": os.environ["CORE_RESULT"],
246- },
247- }
248- Path("provenance/release-qualification.json").write_text(
249- json.dumps(record, indent=2, sort_keys=True) + "\n",
250- encoding="utf-8",
251- )
252- PY
253- - name : Bundle release provenance
254- run : >-
255- tar -czf "codex32-${{ needs.build.outputs.version }}-provenance.tar.gz"
256- -C provenance .
131+ run : sha256sum --check SHA256SUMS
257132 - name : Stage draft GitHub release
258- env :
259- GH_TOKEN : ${{ github.token }}
260133 run : |
261- artifact="codex32-${{ needs.build.outputs.version }}-provenance.tar.gz"
262134 if draft="$(gh release view "$GITHUB_REF_NAME" --json isDraft --jq .isDraft 2>/dev/null)"; then
263135 [ "$draft" = true ] || { echo "release is already public" >&2; exit 1; }
264- gh release upload "$GITHUB_REF_NAME" dist/* "$artifact" --clobber
136+ gh release edit "$GITHUB_REF_NAME" --prerelease="$PRERELEASE"
137+ gh release upload "$GITHUB_REF_NAME" dist/* SHA256SUMS SOURCE_COMMIT --clobber
265138 else
266- gh release create "$GITHUB_REF_NAME" --draft --verify-tag \
267- --title "$GITHUB_REF_NAME" --generate-notes dist/* "$artifact"
139+ gh release create "$GITHUB_REF_NAME" --draft --verify-tag --generate-notes \
140+ --title "$GITHUB_REF_NAME" --prerelease="$PRERELEASE" dist/* SHA256SUMS SOURCE_COMMIT
268141 fi
269142 - name : Publish qualified distributions to PyPI
270143 uses : pypa/gh-action-pypi-publish@a892a5a61159132606e93a2fa6f4358831b04d26 # v1.14.2
271144 with :
272145 packages-dir : dist/
273146 - name : Publish GitHub release
274- env :
275- GH_TOKEN : ${{ github.token }}
276147 run : gh release edit "$GITHUB_REF_NAME" --draft=false
0 commit comments