Skip to content

Commit 751d6dc

Browse files
authored
ci: rework release workflow as tag-triggered pipeline (#10)
1 parent 7ddea48 commit 751d6dc

1 file changed

Lines changed: 56 additions & 18 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,66 @@
1-
name: "Release"
2-
description: 'Publishes python package to PyPI'
1+
name: Release
32

3+
# Conforms to the umbrella SDK release pipeline contract:
4+
# u5c-factory reference/sdk-pipeline-requirements.md
45
on:
5-
workflow_dispatch:
66
push:
7-
tags: [v*]
7+
tags: ['v*']
88

99
jobs:
10-
build:
10+
verify:
1111
runs-on: ubuntu-latest
1212
steps:
13+
- uses: actions/checkout@v4
14+
- name: Verify tag matches package version
15+
run: |
16+
TAG="${GITHUB_REF_NAME#v}"
17+
MANIFEST=$(sed -nE 's/^version = "(.+)"/\1/p' pyproject.toml | head -1)
18+
if [ "$TAG" != "$MANIFEST" ]; then
19+
echo "::error::tag $GITHUB_REF_NAME does not match pyproject.toml version $MANIFEST"
20+
exit 1
21+
fi
1322
14-
- name: Set up Python
15-
uses: actions/setup-python@v5
16-
with:
17-
python-version: "3.10"
23+
build:
24+
needs: verify
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- run: pipx install poetry
29+
- uses: actions/setup-python@v5
30+
with:
31+
python-version: "3.10"
32+
cache: poetry
33+
# Relock first: poetry.lock is stale vs pyproject.toml (see ci.yml).
34+
- run: poetry lock
35+
- run: poetry install
36+
- run: poetry build
1837

19-
- name: Install Poetry
20-
shell: bash
21-
run: pip install --no-input poetry
38+
test:
39+
needs: build
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- run: pipx install poetry
44+
- uses: actions/setup-python@v5
45+
with:
46+
python-version: "3.10"
47+
cache: poetry
48+
- run: poetry lock
49+
- run: poetry install
50+
# No pytest suite yet; import-smoke the package (see ci.yml).
51+
- run: poetry run python -c "import utxorpc"
2252

23-
- name: Publish to PyPI
24-
shell: bash
25-
env:
26-
PYPI_TOKEN: ${{ inputs.registry-token }}
27-
run: |
28-
poetry publish --build --username __token__ --password $PYPI_TOKEN
53+
publish:
54+
needs: test
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v4
58+
- run: pipx install poetry
59+
- uses: actions/setup-python@v5
60+
with:
61+
python-version: "3.10"
62+
cache: poetry
63+
- name: Publish to PyPI
64+
env:
65+
PYPI_REGISTRY_TOKEN: ${{ secrets.PYPI_REGISTRY_TOKEN }}
66+
run: poetry publish --build --username __token__ --password "$PYPI_REGISTRY_TOKEN"

0 commit comments

Comments
 (0)