Skip to content

Commit 4ea045f

Browse files
committed
option to manually trigger workflow that publishes to test.pypi
Signed-off-by: Sreekanth <prsreekanth920@gmail.com>
1 parent 406a793 commit 4ea045f

1 file changed

Lines changed: 57 additions & 1 deletion

File tree

.github/workflows/pynumaflow-lite.yml

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ on:
1212
paths:
1313
- "packages/pynumaflow-lite/**"
1414
- ".github/workflows/pynumaflow-lite.yml"
15+
workflow_dispatch:
16+
inputs:
17+
publish-testpypi:
18+
description: "Publish pynumaflow-lite wheels to TestPyPI"
19+
type: boolean
20+
default: false
1521

1622
concurrency:
1723
group: ${{ github.workflow }}-${{ github.ref }}
@@ -183,6 +189,50 @@ jobs:
183189
exit 1
184190
fi
185191
192+
- name: Set manual TestPyPI version
193+
if: github.event_name == 'workflow_dispatch' && inputs['publish-testpypi']
194+
run: |
195+
set -euo pipefail
196+
197+
base_version="$(cargo metadata --locked --no-deps --format-version 1 | python -c 'import json, sys; print(json.load(sys.stdin)["packages"][0]["version"])')"
198+
if [[ "${base_version}" == *-* ]]; then
199+
manual_version="${base_version}.dev.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}"
200+
else
201+
manual_version="${base_version}-dev.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}"
202+
fi
203+
export MANUAL_VERSION="${manual_version}"
204+
205+
python - <<'PY'
206+
import os
207+
import re
208+
from pathlib import Path
209+
210+
version = os.environ["MANUAL_VERSION"]
211+
212+
cargo_toml = Path("Cargo.toml")
213+
cargo_toml.write_text(
214+
re.sub(
215+
r'(?m)^version = "[^"]+"',
216+
f'version = "{version}"',
217+
cargo_toml.read_text(),
218+
count=1,
219+
)
220+
)
221+
222+
cargo_lock = Path("Cargo.lock")
223+
cargo_lock.write_text(
224+
re.sub(
225+
r'(?ms)(\[\[package\]\]\nname = "pynumaflow-lite"\nversion = ")[^"]+(")',
226+
lambda match: f"{match.group(1)}{version}{match.group(2)}",
227+
cargo_lock.read_text(),
228+
count=1,
229+
)
230+
)
231+
PY
232+
233+
cargo metadata --locked --no-deps --format-version 1 >/dev/null
234+
echo "Using manual TestPyPI version ${manual_version}"
235+
186236
- name: Build wheel
187237
uses: PyO3/maturin-action@v1
188238
with:
@@ -208,7 +258,13 @@ jobs:
208258
name: Publish to TestPyPI
209259
needs: build-wheels
210260
runs-on: ubuntu-24.04
211-
if: github.repository == 'numaproj/numaflow-python' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/pynumaflow-lite-v')
261+
if: >
262+
github.repository == 'numaproj/numaflow-python' &&
263+
github.run_attempt == 1 &&
264+
(
265+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/pynumaflow-lite-v')) ||
266+
(github.event_name == 'workflow_dispatch' && inputs['publish-testpypi'])
267+
)
212268
213269
steps:
214270
- name: Install uv

0 commit comments

Comments
 (0)