Skip to content

Commit 6237694

Browse files
mchadesCopilot
andcommitted
[#27] improve(ci): replace testpypi with dev/rc pre-release publishing to PyPI
- Remove the 'environment' choice input (testpypi / pypi) - Add optional 'version' input for pre-release builds - Validate version ends with .devN or .rcN; error on invalid format - Use 'uv version' to patch pyproject.toml instead of sed - Fix GitHub environment to 'pypi' only - Simplify publish step to a single 'uv publish' command Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a36c0f1 commit 6237694

1 file changed

Lines changed: 11 additions & 24 deletions

File tree

.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}" =~ \.dev[0-9]+$ && ! "${VERSION}" =~ \.rc[0-9]+$ ]]; then
55+
echo "Error: version must end with .devN or .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)