@@ -5,12 +5,12 @@ name: zarr-metadata release
55# `release:` or `push: tags:` trigger.
66#
77# Operator picks the target index at dispatch time:
8- # - `pypi` -> https://pypi.org publishes the version as-declared in
9- # pyproject.toml. Each version is a single shot — re-runs
10- # for the same version will be rejected by PyPI.
11- # - `testpypi` -> https://test.pypi.org. The build appends a
12- # `.dev<run_number>` suffix to the version automatically
13- # so each test push gets a unique version on TestPyPI .
8+ # - `pypi` -> https://pypi.org
9+ # - `testpypi` -> https://test.pypi.org
10+ #
11+ # Both indexes reject re-uploads of an existing version, so each publish
12+ # requires a version bump in pyproject.toml. For TestPyPI dry-runs, use a
13+ # PEP 440 pre-release/dev suffix (e.g. `0.1.0.dev1`) in the source .
1414on :
1515 workflow_dispatch :
1616 inputs :
4343 with :
4444 persist-credentials : false
4545
46- - name : Apply dev-suffix for TestPyPI builds
47- if : inputs.target == 'testpypi'
48- env :
49- RUN_NUMBER : ${{ github.run_number }}
50- run : |
51- python3 <<'PY'
52- import os, re
53- from pathlib import Path
54-
55- run_number = os.environ["RUN_NUMBER"]
56- pyp = Path("pyproject.toml")
57- init = Path("src/zarr_metadata/__init__.py")
58-
59- base = re.search(r'^version\s*=\s*"([^"]+)"', pyp.read_text(), re.M).group(1)
60- new_version = f"{base}.dev{run_number}"
61- print(f"::notice::TestPyPI build: {base} -> {new_version}")
62-
63- pyp.write_text(re.sub(
64- r'^(version\s*=\s*)"[^"]+"',
65- rf'\1"{new_version}"',
66- pyp.read_text(),
67- count=1,
68- flags=re.M,
69- ))
70- init.write_text(re.sub(
71- r'^(__version__\s*=\s*)"[^"]+"',
72- rf'\1"{new_version}"',
73- init.read_text(),
74- count=1,
75- flags=re.M,
76- ))
77- PY
78-
7946 - name : Install Hatch
8047 uses : pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc
8148 with :
0 commit comments