Skip to content

Commit d9146e0

Browse files
authored
[codex] fix release build versioning (#869)
fix release build versioning
1 parent e839420 commit d9146e0

3 files changed

Lines changed: 33 additions & 6 deletions

File tree

.github/workflows/pypi-publish-dry-run.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717

1818
steps:
1919
- uses: actions/checkout@v6.0.2
20+
with:
21+
fetch-depth: 0
2022

2123
- name: Set up Python
2224
uses: actions/setup-python@v6.2.0
@@ -30,9 +32,14 @@ jobs:
3032
run: |
3133
make build-whl
3234
35+
- name: Verify release artifact version
36+
run: |
37+
ls -1 dist
38+
! ls dist/oaklib-0.0.0* 1>/dev/null 2>&1
39+
3340
# - name: Publish package to TestPyPI
3441
# uses: pypa/gh-action-pypi-publish@release/v1
3542
# with:
3643
# password: "TEST_PASSWORD"
3744
# repository-url: https://test.pypi.org/legacy/
38-
45+

.github/workflows/pypi-publish.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,25 @@ jobs:
1111

1212
steps:
1313
- uses: actions/checkout@v6.0.2
14+
with:
15+
fetch-depth: 0
1416

1517
- name: Set up Python
1618
uses: actions/setup-python@v6.2.0
1719
with:
1820
python-version: 3.12
1921

2022
- name: Build source and wheel archives
23+
env:
24+
OAK_BUILD_TAG: ${{ github.event.release.tag_name }}
2125
run: |
2226
make build-whl
2327
28+
- name: Verify release artifact version
29+
run: |
30+
ls -1 dist
31+
! ls dist/oaklib-0.0.0* 1>/dev/null 2>&1
32+
2433
- name: Publish distribution 📦 to PyPI
2534
uses: pypa/gh-action-pypi-publish@v1.2.2
2635
with:

Makefile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,22 @@ tests:
88

99
.PHONY: build-whl
1010
build-whl:
11-
#Set the version of oaklib and build the python whl.
12-
$(INSTALL)
13-
uv version $(git describe --tags --abbrev=0)
14-
uv build
11+
# Set the version from the release tag before building the wheel.
12+
# uv-dynamic-versioning does not currently derive the version for `uv build`.
13+
@build_tag="$${OAK_BUILD_TAG:-$$(git describe --tags --abbrev=0)}"; \
14+
build_version="$$(printf '%s\n' "$$build_tag" | sed -E 's/^v//; s/-rc([0-9]+)$$/rc\1/')"; \
15+
case "$$build_tag" in \
16+
v[0-9]*.[0-9]*.[0-9]*|v[0-9]*.[0-9]*.[0-9]*-rc[0-9]*) ;; \
17+
*) echo "Unsupported release tag: $$build_tag"; exit 1 ;; \
18+
esac; \
19+
tmpdir="$$(mktemp -d)"; \
20+
trap 'rm -rf "$$tmpdir"' EXIT; \
21+
echo "Building oaklib $$build_version from $$build_tag"; \
22+
git archive --format=tar HEAD | tar -xf - -C "$$tmpdir"; \
23+
python3 -c 'import re, sys; from pathlib import Path; path = Path(sys.argv[1]); version = sys.argv[2]; text = path.read_text(); text, n = re.subn(r"(?m)^version = \"[^\"]+\"$$", f"version = \"{version}\"", text, count=1); assert n == 1, "Could not update version in pyproject.toml"; path.write_text(text)' "$$tmpdir/pyproject.toml" "$$build_version" \
24+
&& (cd "$$tmpdir" && uv build) \
25+
&& mkdir -p dist \
26+
&& cp "$$tmpdir"/dist/* dist/
1527

1628
# not yet deployed
1729
doctest:
@@ -169,4 +181,3 @@ phenio-benchmarks:
169181
phenio-profiles:
170182
python $(PROFILER_SCRIPT) $(SEMSIMIAN_PHENIO_PROFILE)
171183
python $(PROFILER_SCRIPT) $(NON_SEMSIMIAN_PHENIO_PROFILE)
172-

0 commit comments

Comments
 (0)