-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (82 loc) · 2.97 KB
/
Copy pathrelease.yml
File metadata and controls
100 lines (82 loc) · 2.97 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
name: release wheel
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
wheel:
name: build and publish release wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Build wheel
run: |
python -m pip install --upgrade pip build
python -m build --wheel
- name: Verify wheel boundary
run: |
python - <<'PY'
from pathlib import Path
from zipfile import ZipFile
wheels = list(Path("dist").glob("cge_core-*.whl"))
assert len(wheels) == 1, wheels
wheel = wheels[0]
with ZipFile(wheel) as archive:
names = archive.namelist()
roots = {name.split("/", 1)[0] for name in names}
assert "cge_core" in roots
assert "cam" not in roots, "legacy cam package returned to wheel"
assert any(root.endswith(".dist-info") for root in roots)
forbidden_roots = {
"docs", "notebooks", "tests", "examples", ".github", "release",
}
unexpected = sorted(roots & forbidden_roots)
assert not unexpected, f"repository-only content leaked into wheel: {unexpected}"
print(f"WHEEL {wheel.name}")
print(f"SIZE_BYTES {wheel.stat().st_size}")
print("ROOTS", sorted(roots))
PY
- name: Smoke-install built wheel
run: |
python -m venv .wheel-smoke
.wheel-smoke/bin/python -m pip install --upgrade pip
.wheel-smoke/bin/python -m pip install dist/*.whl
.wheel-smoke/bin/python - <<'PY'
import cge_core
from cge_core import CamCGE, IFPRICGE, SimpleCGE, StandardCGE
assert cge_core.__version__ == "0.8.0"
assert all((SimpleCGE, StandardCGE, CamCGE, IFPRICGE))
print("wheel import smoke test passed")
PY
- name: Publish wheel and synchronize release notes
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${GITHUB_REF_NAME}"
if [[ "${GITHUB_REF_TYPE}" != "tag" ]]; then
echo "workflow_dispatch without a tag ref: build verified, publish skipped"
exit 0
fi
NOTES=".github/release-notes/${TAG}.md"
if gh release view "${TAG}" >/dev/null 2>&1; then
gh release upload "${TAG}" dist/*.whl --clobber
if [[ -f "${NOTES}" ]]; then
gh release edit "${TAG}" --notes-file "${NOTES}"
fi
else
if [[ -f "${NOTES}" ]]; then
gh release create "${TAG}" dist/*.whl \
--title "CGE-Core ${TAG} — Practitioner-First Modelling" \
--notes-file "${NOTES}"
else
gh release create "${TAG}" dist/*.whl \
--title "CGE-Core ${TAG}" \
--generate-notes
fi
fi