-
-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (104 loc) · 3.94 KB
/
Copy pathpublish.yml
File metadata and controls
118 lines (104 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Build and Publish to PyPI
# Trigger: on GitHub Release published event (recommended).
# Also supports manual trigger for pipeline validation.
on:
release:
types: [published]
workflow_dispatch:
inputs:
dry_run:
description: "Dry run (build + smoke-test only, skip publish)"
required: false
default: "true"
type: choice
options:
- "true"
- "false"
jobs:
# ──────────────────────────────────────────────
# Job 1: Build wheel and sdist from uml/.gen
# ──────────────────────────────────────────────
build:
name: Build distribution
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Build wheel and sdist
run: |
rm -rf dist
uv build
- name: List dist contents (evidence)
run: ls -lh dist/
- name: Upload dist artifacts
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
if-no-files-found: error
# ──────────────────────────────────────────────
# Job 2: Smoke test — verify CLI entry points
# ──────────────────────────────────────────────
smoke-test:
name: Smoke test CLI entry points
needs: build
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Download dist artifacts
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install package from wheel
run: |
WHEEL=$(ls -1 dist/*.whl | sort | tail -n 1)
echo "Installing: $WHEEL"
uv venv .venv
uv pip install --python .venv/bin/python "$WHEEL"
- name: Verify CLI entry points
run: |
echo "=== umlc --help ==="
.venv/bin/umlc --help
echo "=== umls --help ==="
.venv/bin/umls --help
echo "=== umlc-gen --help ==="
.venv/bin/umlc-gen --help
echo "=== umls-gen --help ==="
.venv/bin/umls-gen --help
# ──────────────────────────────────────────────
# Job 3: Publish to PyPI via API Token (Plan B)
# For first-time release before Trusted Publisher is configured.
# Skipped on workflow_dispatch with dry_run=true
# ──────────────────────────────────────────────
publish:
name: Publish to PyPI (Token Mode)
needs: smoke-test
runs-on: ubuntu-latest
# Only publish on real release events, or manual trigger with dry_run=false
if: |
github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'false')
steps:
- name: Download dist artifacts
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Publish to PyPI
run: uv publish
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
# Note: UV_PUBLISH_TOKEN must be set as GitHub Repository Secret.
# Token must be created on PyPI with "Entire account" scope for first release.