Skip to content

Commit 8c1be4a

Browse files
liyakaclaude
andcommitted
ci: generate _version.py before uv/docker builds (fix missing version source)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 628292b commit 8c1be4a

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ jobs:
3535
permissions:
3636
contents: write # push the git tag on main builds
3737
outputs:
38-
version: ${{ steps.v.outputs.version }}
38+
version: ${{ steps.v.outputs.version }} # image tag (may carry -branch)
39+
pyver: ${{ steps.v.outputs.pyver }} # PEP 440 form for the wheel
3940
steps:
4041
- uses: actions/checkout@v6
4142
with:
@@ -90,12 +91,22 @@ jobs:
9091
SLUG=${SLUG:0:30}; SLUG=${SLUG%-}
9192
VERSION="$BASE.$PATCH-$SLUG"
9293
fi
94+
# The image tag may carry a -branch suffix (fine for Docker tags), but
95+
# the wheel/_version.py must be PEP 440 — so branch builds use .devN.
96+
if [ "$REF_NAME" = "main" ] && [ "$EVENT" = "push" ]; then
97+
PYVER="$BASE.$PATCH"
98+
else
99+
PYVER="$BASE.$PATCH.dev0"
100+
fi
93101
echo "version=$VERSION" | tee -a "$GITHUB_OUTPUT"
102+
echo "pyver=$PYVER" | tee -a "$GITHUB_OUTPUT"
94103
95104
python-checks:
96105
runs-on: ubuntu-latest
97106
steps:
98107
- uses: actions/checkout@v6
108+
- name: Generate _version.py (required before any uv build)
109+
run: make version
99110
- uses: astral-sh/setup-uv@v6
100111
with:
101112
version: 'latest'
@@ -126,6 +137,8 @@ jobs:
126137
packages: write
127138
steps:
128139
- uses: actions/checkout@v6
140+
- name: Generate _version.py (baked into the image via COPY src)
141+
run: VERSION="${{ needs.version.outputs.pyver }}" make version
129142
- uses: docker/setup-qemu-action@v3
130143
- uses: docker/setup-buildx-action@v3
131144
- name: Login to GHCR

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
- uses: astral-sh/setup-uv@v6
8383
- name: Stamp the release version + build
8484
run: |
85-
echo "${{ needs.validate.outputs.version }}" > version.txt
85+
VERSION="${{ needs.validate.outputs.version }}" make version
8686
uv build
8787
- name: Publish to PyPI (Trusted Publishing)
8888
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)