-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (52 loc) · 1.86 KB
/
publish-pypi.yml
File metadata and controls
64 lines (52 loc) · 1.86 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
name: Publish PyPI
on:
workflow_dispatch:
inputs:
expected_version:
description: "Package version expected from the selected ref, for example 0.1.6"
required: true
type: string
jobs:
publish:
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install release dependencies
run: python -m pip install -e .[release]
- name: Validate version
shell: bash
run: |
python - <<'PY'
import pathlib
import tomllib
import sys
root = pathlib.Path(".")
sys.path.insert(0, str(root / "src"))
from code2skill import __version__
expected = "${{ inputs.expected_version }}"
pyproject = tomllib.loads((root / "pyproject.toml").read_text(encoding="utf-8"))
dynamic = pyproject["project"].get("dynamic", [])
version_attr = pyproject["tool"]["setuptools"]["dynamic"]["version"]["attr"]
if dynamic != ["version"]:
raise SystemExit(f"Expected dynamic version metadata, got {dynamic!r}.")
if version_attr != "code2skill.version.__version__":
raise SystemExit(f"Unexpected dynamic version source: {version_attr}.")
if __version__ != expected:
raise SystemExit(f"Expected version {expected}, but runtime version is {__version__}.")
PY
- name: Build package
run: python -m build
- name: Check package metadata
run: python -m twine check dist/*
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1