Repository navigation
AI-3561: release.yml publishes only a checked version #2226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b3b8c42
1c7e63a
f43a88a
8884e08
4015c70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| name: Build the Python packages | ||
| description: Build every workspace package and check that each carries the version of the release tag. Never uploads. | ||
| inputs: | ||
| tag: | ||
| description: The release tag, vX.Y.Z. The checkout must see it. | ||
| required: true | ||
| outputs: | ||
| version: | ||
| description: The version, X.Y.Z, that every built file carries | ||
| value: ${{ steps.check.outputs.version }} | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| # No dependency cache in a job that holds an OIDC token: a cache poisoned by another | ||
| # run would hand that token to whatever it planted. | ||
| - uses: ./.github/actions/python-uv-setup | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Nit] R1.5 This step runs a full
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 8884e08: |
||
| with: | ||
| enable-cache: "false" | ||
| # `uv build` makes its own build environments and needs none of the dev dependencies. | ||
| sync: "false" | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Nit] S1.1 |
||
|
|
||
| - name: Clean dist directory | ||
| shell: bash | ||
| run: | | ||
| rm -rf dist | ||
|
|
||
| - name: Build all distributions | ||
| shell: bash | ||
| env: | ||
| UV_BUILD_CONSTRAINT: ${{ github.workspace }}/.github/release-build-constraints.txt | ||
| run: | | ||
| uv build --all | ||
|
|
||
| - name: Check that every file has the release version | ||
| id: check | ||
| shell: bash | ||
| env: | ||
| TAG: ${{ inputs.tag }} | ||
| run: | | ||
| .github/scripts/check-release-version.sh "$TAG" dist | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #!/usr/bin/env bash | ||
| # Fails unless the Python packages built in <dist-dir> all carry the version of the release tag. | ||
| # | ||
| # Each package takes its version from the nearest git tag (hatch-vcs). When the checkout does not | ||
| # see the release tag, the build does not fail: it gets a dev version from another tag, or 0.0.0 | ||
| # (`fallback_version` in each pyproject.toml). PyPI never takes a version twice, so this runs | ||
| # before the upload. | ||
| # | ||
| # Usage: check-release-version.sh <tag> [<dist-dir>] (tag: vX.Y.Z; dist-dir: dist) | ||
| # Writes `version=X.Y.Z` to $GITHUB_OUTPUT when it is set. | ||
| set -euo pipefail | ||
|
|
||
| tag=${1:?usage: check-release-version.sh <tag> [<dist-dir>]} | ||
| dist=${2:-dist} | ||
|
|
||
| fail() { | ||
| echo "::error::$*" | ||
| exit 1 | ||
| } | ||
|
|
||
| [[ $tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || fail "release tag '$tag' is not vX.Y.Z" | ||
| want=${tag#v} | ||
|
|
||
| # `uv publish` uploads everything in the directory, so every file there must be checked. | ||
| shopt -s nullglob dotglob | ||
| files=() | ||
| for f in "$dist"/*; do | ||
| case $(basename "$f") in | ||
| .gitignore) ;; | ||
| *.whl | *.tar.gz) files+=("$f") ;; | ||
| *) fail "$f is neither a wheel nor an sdist, and 'uv publish' would upload it" ;; | ||
| esac | ||
| done | ||
| (( ${#files[@]} > 0 )) || fail "no wheel or sdist in $dist" | ||
| for f in "${files[@]}"; do | ||
| name=$(basename "$f") | ||
| case $name in | ||
| # A wheel is {name}-{version}-{python}-{abi}-{platform}.whl, and name has no '-'. | ||
| *.whl) version=$(cut -d- -f2 <<<"$name") ;; | ||
| # An sdist is {name}-{version}.tar.gz. | ||
| *) stem=${name%.tar.gz}; version=${stem##*-} ;; | ||
| esac | ||
| [[ $version == "$want" ]] || fail "$name has version '$version', expected '$want'" | ||
| done | ||
|
|
||
| echo "${#files[@]} files in $dist, all at version $want" | ||
| if [[ -n ${GITHUB_OUTPUT:-} ]]; then | ||
| echo "version=$want" >> "$GITHUB_OUTPUT" | ||
| fi |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| name: Release check | ||
| # Proves, without publishing, that a release would build every Python package at the tag's | ||
| # version. It runs the build steps of release.yml (the build-python-packages action) on a local | ||
| # tag, and has no `uv publish`, no `pypi` environment and no `id-token` permission, so it can | ||
| # never reach PyPI. Run it by hand (Actions > Release check) before you tag a release. | ||
| on: | ||
| pull_request: | ||
| branches: [ "**" ] | ||
| # A draft runs nothing: CI starts when the pull request is marked ready (ready_for_review). | ||
| types: [ opened, synchronize, reopened, ready_for_review ] | ||
| paths: | ||
| - '.github/workflows/release.yml' | ||
| - '.github/workflows/release-check.yml' | ||
| - '.github/actions/build-python-packages/**' | ||
| - '.github/actions/python-uv-setup/**' | ||
| - '.github/scripts/check-release-version.sh' | ||
| - '.github/release-build-constraints.txt' | ||
| - '**/pyproject.toml' | ||
| - 'uv.lock' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: release-check-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build every package at the release version | ||
| if: github.event.pull_request.draft != true | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| # A version no release has, so the check never meets a real tag. | ||
| TAG: v99.0.0 | ||
| steps: | ||
| # The release job checks out the same way: one commit, no tags but the release's. | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Tag this commit as the release | ||
| run: | | ||
| git tag "$TAG" | ||
| git tag --list | ||
|
|
||
| - name: Build all distributions | ||
| id: build | ||
| uses: ./.github/actions/build-python-packages | ||
| with: | ||
| tag: ${{ env.TAG }} | ||
|
|
||
| # The action's output is what release.yml hands to the install check, so it must be the | ||
| # tag's version. This fails if the action no longer runs the version check or no longer | ||
| # reports its result. | ||
| - name: The build reports the tag's version | ||
| run: | | ||
| echo "build output: '${{ steps.build.outputs.version }}', tag: '$TAG'" | ||
| test "${{ steps.build.outputs.version }}" = "${TAG#v}" | ||
|
|
||
| # Each wrong input must fail the version check. If one passes, the check no longer guards | ||
| # the upload. | ||
| - name: A wrong tag or a wrong file version must fail the check | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Should fix] R1.1 Three mutants of the version guard survive this controls step, so the check can break and the Release check stays green:
Rows to add (each one checked: it fails as expected on the head and passes under its mutant):
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in f43a88a (rows) / 4015c70 head: |
||
| run: | | ||
| fails() { | ||
| if "$@" > /dev/null 2>&1; then | ||
| echo "::error::passed, but must fail: $*" | ||
| exit 1 | ||
| fi | ||
| echo "failed as expected: $*" | ||
| } | ||
| fails .github/scripts/check-release-version.sh v99.0.1 dist | ||
| fails .github/scripts/check-release-version.sh 99.0.0 dist | ||
| fails .github/scripts/check-release-version.sh v99.0.0-rc1 dist | ||
| wheels=(dist/*.whl) | ||
| sdists=(dist/*.tar.gz) | ||
| wrong_wheel=$(basename "${wheels[0]}" | sed 's/-99\.0\.0-/-99.0.1-/') | ||
| wrong_sdist=$(basename "${sdists[0]}" | sed 's/-99\.0\.0\.tar/-99.0.1.tar/') | ||
| four_wheel=$(basename "${wheels[0]}" | sed 's/-99\.0\.0-/-99.0.0.1-/') | ||
| four_sdist=$(basename "${sdists[0]}" | sed 's/-99\.0\.0\.tar/-99.0.0.1.tar/') | ||
| post_sdist=$(basename "${sdists[0]}" | sed 's/-99\.0\.0\.tar/-99.0.0.post1.tar/') | ||
| mkdir empty wheel-wrong sdist-wrong four post stray | ||
| # One wrong file of a kind, beside a right file of the other kind. | ||
| cp "${wheels[0]}" "wheel-wrong/$wrong_wheel" | ||
| cp "${sdists[0]}" wheel-wrong/ | ||
| cp "${sdists[0]}" "sdist-wrong/$wrong_sdist" | ||
| cp "${wheels[0]}" sdist-wrong/ | ||
| fails .github/scripts/check-release-version.sh "$TAG" wheel-wrong | ||
| fails .github/scripts/check-release-version.sh "$TAG" sdist-wrong | ||
| fails .github/scripts/check-release-version.sh "$TAG" empty | ||
| # A version that merely starts with the tag's must fail. So must a tag that is not | ||
| # vX.Y.Z even when the files carry its version: hatch-vcs builds 99.0.0.1 from v99.0.0.1. | ||
| cp "${wheels[0]}" "post/${wheels[0]##*/}" | ||
| cp "${sdists[0]}" "post/$post_sdist" | ||
| fails .github/scripts/check-release-version.sh "$TAG" post | ||
| cp "${wheels[0]}" "four/$four_wheel" | ||
| cp "${sdists[0]}" "four/$four_sdist" | ||
| fails .github/scripts/check-release-version.sh v99.0.0.1 four | ||
| # `uv publish` uploads every file in dist, so a file that is no wheel or sdist must fail. | ||
| cp "${wheels[0]}" "${sdists[0]}" stray/ | ||
| touch stray/notes.zip | ||
| fails .github/scripts/check-release-version.sh "$TAG" stray | ||
|
|
||
| # Metadata PyPI refuses, such as a long description that does not render. | ||
| - name: Check the package metadata | ||
| run: uvx -q --from twine==7.0.0 twine check dist/* | ||
|
|
||
| # PyPI takes an upload to a project that does not exist only from a pending trusted | ||
| # publisher. This repo cannot read that setting, so the step lists the projects to look at. | ||
| - name: List the projects PyPI does not have yet | ||
| run: | | ||
| missing="" | ||
| for wheel in dist/*.whl; do | ||
| name=$(basename "$wheel" | cut -d- -f1 | tr _ -) | ||
| code=$(curl -s -o /dev/null -w '%{http_code}' "https://pypi.org/pypi/$name/json") | ||
| [ "$code" = 200 ] || missing="$missing $name($code)" | ||
| done | ||
| if [ -n "$missing" ]; then | ||
| echo "::warning::not on PyPI, needs a pending trusted publisher before a release:$missing" | ||
| fi | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Should fix] R1.2 Publishing is not gated on the
integrationjob, and that is decided: provider suites being red must not block a release. But two things do not match this decision yet:gh run list ... --workflow release.ymlmust showsuccess. Theintegrationjob runs in the same workflow and has been red in every past run, so a release that published correctly endsfailure.release.ymlbuild-core(line 22) does not say that the missingneeds: integrationis deliberate.Fix: step 6 checks the
Build & Test Core SDKandVerify PIP install worksjobs (gh run view <id> --json jobs) and says that the integration result is reported but does not gate. Add a one-line comment atbuild-coreinrelease.yml. In the body, turn the question into the decision.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 4015c70: skill step 6 now reads the jobs
Build & Test Core SDKandVerify PIP install worksviagh run view <id> --json jobs, says the run conclusion is not to be read and that integration is not a gate;release.ymlhas a comment atbuild-core; the PR body states the decision and Question 1 is removed.