Skip to content

Commit f67c9cf

Browse files
mchadesCopilot
andauthored
[#27] improve(ci): replace testpypi with dev/rc pre-release publishing to PyPI (#28)
### What changes were proposed in this pull request? Remove the `testpypi` environment from the `publish.yml` workflow and replace it with native PyPI pre-release versioning. The workflow now accepts an optional `version` input: if it ends with `.devN` or `.rcN`, the version is patched via `uv version` before building and publishing to PyPI; otherwise the version in `pyproject.toml` is used directly for a production release. ### Why are the changes needed? - TestPyPI requires a separate trusted publisher configuration and has storage limits that need manual cleanup - Pre-release packages on PyPI (`.dev`, `.rc`) are already hidden from default installs (`pip install` won't pick them up without `--pre`), making TestPyPI unnecessary - Reduces workflow complexity: one target registry, one publish command ### Does this PR introduce _any_ user-facing change? - The `environment` input (testpypi / pypi) is removed from the `Publish to PyPI` workflow dispatch - A pre-release can now be published by providing a version like `0.1.0.dev1` or `0.1.0.rc1` in the `version` input ### How was this patch tested? Workflow logic change only — no code changes. Validated by reviewing the updated YAML and confirming the bash version check regex (`\.devN` / `.rcN`) matches expected inputs. Fix: #27 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a36c0f1 commit f67c9cf

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

.github/workflows/publish.yml

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,9 @@ on:
1818
workflow_dispatch:
1919
inputs:
2020
version:
21-
description: "Version to publish (required for testpypi, e.g. 0.1.0.dev1). Ignored for pypi."
21+
description: "Optional pre-release version to publish (e.g. 0.1.0.dev1 or 0.1.0.rc1). Must end with .devN or .rcN. Leave blank to publish the version from pyproject.toml as a production release."
2222
required: false
2323
type: string
24-
environment:
25-
description: "Target PyPI environment"
26-
required: true
27-
type: choice
28-
default: "pypi"
29-
options:
30-
- "pypi"
31-
- "testpypi"
3224
ref:
3325
description: "Branch or tag to publish from (e.g. main, v0.1.0). Defaults to the branch selected above."
3426
required: false
@@ -38,8 +30,8 @@ jobs:
3830
publish:
3931
runs-on: ubuntu-latest
4032
environment:
41-
name: ${{ github.event.inputs.environment }}
42-
url: ${{ github.event.inputs.environment == 'pypi' && 'https://pypi.org/project/adp-sdk/' || 'https://test.pypi.org/project/adp-sdk/' }}
33+
name: pypi
34+
url: https://pypi.org/project/adp-sdk/
4335
permissions:
4436
id-token: write
4537
contents: read
@@ -57,17 +49,17 @@ jobs:
5749

5850
- name: Resolve version
5951
run: |
60-
if [ "${{ github.event.inputs.environment }}" = "testpypi" ]; then
61-
VERSION="${{ github.event.inputs.version }}"
62-
if [ -z "${VERSION}" ]; then
63-
echo "Error: version input is required when publishing to testpypi"
52+
VERSION="${{ github.event.inputs.version }}"
53+
if [ -n "${VERSION}" ]; then
54+
if [[ ! "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.(dev|rc)[0-9]+$ ]]; then
55+
echo "Error: version must follow the format X.Y.Z.devN or X.Y.Z.rcN (e.g. 0.1.0.dev1, 0.1.0.rc1)"
6456
exit 1
6557
fi
66-
echo "Patching pyproject.toml with version: ${VERSION}"
67-
sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" pyproject.toml
58+
echo "Patching pyproject.toml with pre-release version: ${VERSION}"
59+
uv version "${VERSION}"
6860
else
6961
VERSION=$(uv run python -c "import tomllib; f=open('pyproject.toml','rb'); d=tomllib.load(f); print(d['project']['version'])")
70-
echo "Publishing version from pyproject.toml: ${VERSION}"
62+
echo "Publishing production version from pyproject.toml: ${VERSION}"
7163
fi
7264
7365
- name: Build
@@ -77,9 +69,4 @@ jobs:
7769
run: uv run --isolated --no-project --with "$(ls dist/*.whl)" -- python -c "import adp_sdk; print(adp_sdk.__version__)"
7870

7971
- name: Publish
80-
run: |
81-
if [ "${{ github.event.inputs.environment }}" = "testpypi" ]; then
82-
uv publish --index testpypi
83-
else
84-
uv publish
85-
fi
72+
run: uv publish

0 commit comments

Comments
 (0)