Skip to content

Commit eb1ebbf

Browse files
authored
Merge pull request #4 from lightpanda-io/post-release-tags
ci: accept post-release tags (0.4.0-1) for Python-only re-releases
2 parents 8198b03 + ad79085 commit eb1ebbf

2 files changed

Lines changed: 68 additions & 25 deletions

File tree

‎.github/workflows/wheels.yml‎

Lines changed: 60 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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

2428
on:
2529
pull_request:
@@ -32,6 +36,9 @@ on:
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
@@ -46,40 +53,68 @@ env:
4653
BROWSER_REPO: lightpanda-io/browser
4754

4855
jobs:
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

‎README.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ release can also be triggered by hand: create a GitHub release here whose tag
202202
matches a browser release tag, or use the `workflow_dispatch` path (any
203203
browser tag, publish to TestPyPI or PyPI) for dry runs.
204204

205+
To ship a packaging or client-side fix without waiting for a new browser
206+
release, create a GitHub release here tagged `<browser tag>-N`, e.g.
207+
`0.4.0-1`: it bundles browser `0.4.0` again and publishes as the PEP 440
208+
post-release `0.4.0.post1` (`.postN` is accepted as the tag too). Bare
209+
`pip install lightpanda`, `>=` and `~=` requirements pick post-releases up;
210+
an exact `==0.4.0` pin deliberately does not, so pin with `~=0.4.0` to
211+
receive them. The `workflow_dispatch` path has a matching `post` input.
212+
205213
The API reference at [lightpanda.io/docs/python](https://lightpanda.io/docs/python/)
206214
is regenerated from the PyPI package by the
207215
[docs repo's `python-reference` workflow](https://github.com/lightpanda-io/docs/blob/main/.github/workflows/python-reference.yml),

0 commit comments

Comments
 (0)