@@ -12,14 +12,18 @@ name: wheels
1212# Triggers:
1313# - pull_request / push to main: build + test against the browser
1414# `nightly` release, no publish.
15- # - release published: build + test the browser release with the SAME tag
16- # and publish to PyPI. A release tag on this repo must equal the browser
17- # release tag it ships (e.g. 0.4.0); the wheel version is derived from
18- # it. Releases here are created automatically by the browser repo's
19- # release workflow (its `update-python-package` job) whenever it builds a
20- # version tag, so a browser release flows to PyPI with no polling — the
21- # publish still stops at the pypi environment's required-reviewer gate.
22- # - workflow_dispatch: pick any browser tag and publish target manually.
15+ # - release published: build + test the browser release named by the tag
16+ # and publish to PyPI. A release tag on this repo is the browser release
17+ # tag it ships (e.g. 0.4.0), optionally followed by `-N` (or `.postN`) for
18+ # a Python-only re-release of that same browser version: `0.4.0-1` bundles
19+ # browser 0.4.0 and publishes as the PEP 440 post-release `0.4.0.post1`.
20+ # Plain `X.Y.Z` releases here are created automatically by the browser
21+ # repo's release workflow (its `update-python-package` job) whenever it
22+ # builds a version tag, so a browser release flows to PyPI with no
23+ # polling — the publish still stops at the pypi environment's
24+ # required-reviewer gate.
25+ # - workflow_dispatch: pick any browser tag, an optional post-release
26+ # number and the publish target manually.
2327
2428on :
2529 pull_request :
3236 release :
3337 description : " browser release tag to bundle (nightly or a version tag)"
3438 default : " nightly"
39+ post :
40+ description : " post-release number (publishes <release>.post<N>; leave empty for none)"
41+ default : " "
3542 publish :
3643 description : " where to publish"
3744 type : choice
4653 BROWSER_REPO : lightpanda-io/browser
4754
4855jobs :
49- # Map the triggering event to the browser tag to bundle and the publish
50- # target, so the downstream jobs don't each re-derive it .
56+ # Map the triggering event to the browser tag to bundle, the wheel version
57+ # and the publish target, so the downstream jobs don't each re-derive them .
5158 params :
5259 runs-on : ubuntu-latest
5360 timeout-minutes : 5
5461 outputs :
5562 release_tag : ${{ steps.resolve.outputs.release_tag }}
63+ wheel_version : ${{ steps.resolve.outputs.wheel_version }}
5664 publish : ${{ steps.resolve.outputs.publish }}
5765 steps :
58- - name : Resolve release tag and publish target
66+ - name : Resolve browser tag, wheel version and publish target
5967 id : resolve
6068 run : |
6169 case "${{ github.event_name }}" in
6270 release)
63- echo "release_tag= ${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT "
64- echo " publish=pypi" >> "$GITHUB_OUTPUT"
71+ tag=" ${{ github.event.release.tag_name }}"
72+ publish=pypi
6573 ;;
6674 workflow_dispatch)
67- echo "release_tag=${{ inputs.release }}" >> "$GITHUB_OUTPUT"
68- echo "publish=${{ inputs.publish }}" >> "$GITHUB_OUTPUT"
75+ tag="${{ inputs.release }}"
76+ [ -n "${{ inputs.post }}" ] && tag="$tag-${{ inputs.post }}"
77+ publish="${{ inputs.publish }}"
6978 ;;
7079 *)
71- echo "release_tag =nightly" >> "$GITHUB_OUTPUT"
72- echo " publish=none" >> "$GITHUB_OUTPUT"
80+ tag =nightly
81+ publish=none
7382 ;;
7483 esac
75- cat "$GITHUB_OUTPUT"
76- # A nightly build keeps pyproject's dev version; never let one
77- # reach PyPI, whatever dispatched it.
78- if grep -q '^publish=pypi$' "$GITHUB_OUTPUT" && grep -q '^release_tag=nightly$' "$GITHUB_OUTPUT"; then
84+
85+ # Split the tag into the browser release to bundle and the wheel
86+ # version. `X.Y.Z` ships browser X.Y.Z as version X.Y.Z; `X.Y.Z-N`
87+ # (Debian style) or `X.Y.Z.postN` ships the same browser X.Y.Z as
88+ # the PEP 440 post-release X.Y.Z.postN — a Python-only re-release.
89+ # A nightly build keeps pyproject's dev version (empty wheel_version).
90+ tag="${tag#v}"
91+ case "$tag" in
92+ nightly) browser=nightly; version= ;;
93+ *-[0-9]*) browser="${tag%-*}"; version="${tag%-*}.post${tag##*-}" ;;
94+ *.post[0-9]*) browser="${tag%.post*}"; version="$tag" ;;
95+ *) browser="$tag"; version="$tag" ;;
96+ esac
97+ if [ "$browser" != nightly ] && ! echo "$browser" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
98+ echo "::error::'$tag' is not a browser release tag (X.Y.Z, optionally followed by -N or .postN)"
99+ exit 1
100+ fi
101+ if [ -n "$version" ] && ! echo "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(\.post[0-9]+)?$'; then
102+ echo "::error::'$tag' does not map to a PEP 440 version (got '$version')"
103+ exit 1
104+ fi
105+ # Never let a nightly build reach PyPI, whatever dispatched it.
106+ if [ "$publish" = pypi ] && [ "$browser" = nightly ]; then
79107 echo "::error::refusing to publish a nightly build to PyPI (pick a version tag)"
80108 exit 1
81109 fi
82110
111+ {
112+ echo "release_tag=$browser"
113+ echo "wheel_version=$version"
114+ echo "publish=$publish"
115+ } >> "$GITHUB_OUTPUT"
116+ cat "$GITHUB_OUTPUT"
117+
83118 build :
84119 needs : params
85120 runs-on : ubuntu-latest
@@ -136,11 +171,11 @@ jobs:
136171 esac
137172
138173 - name : Set wheel version from tag
139- if : needs.params.outputs.release_tag != 'nightly '
174+ if : needs.params.outputs.wheel_version != ''
140175 run : |
141- # Wheel version == browser release tag (PEP 440 expects no leading v).
142- tag="${{ needs.params.outputs.release_tag }}"
143- sed -i " s/^version = .*/version = \ "${tag#v}\"/" pyproject.toml
176+ # Already normalized by the params job (X.Y.Z or X.Y.Z.postN), so the
177+ # wheel filename and the PyPI listing match the tag as written here.
178+ sed -i ' s/^version = .*/version = "${{ needs.params.outputs.wheel_version }}"/' pyproject.toml
144179 grep '^version' pyproject.toml
145180
146181 - name : Build wheel
0 commit comments