-
Notifications
You must be signed in to change notification settings - Fork 31
117 lines (96 loc) · 3.57 KB
/
release.yml
File metadata and controls
117 lines (96 loc) · 3.57 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
name: Release
on:
push:
tags:
- "v*"
- "[0-9]*"
permissions:
contents: write
id-token: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Validate tag/version consistency
shell: bash
run: |
set -euo pipefail
TAG_NAME="${GITHUB_REF_NAME}"
TAG_VERSION="${TAG_NAME#v}"
PYPROJECT_VERSION=$(python - <<'PY'
import tomllib
from pathlib import Path
data = tomllib.loads(Path("pyproject.toml").read_text(encoding="utf-8"))
print(data["project"]["version"])
PY
)
CHANGELOG_VERSION=$(python - <<'PY'
import re
from pathlib import Path
changelog = Path("CHANGELOG.md").read_text(encoding="utf-8")
# Skip the conventional [Unreleased] heading so keep-a-changelog
# workflow (pre-collecting notes above the released version) is
# preserved alongside tag-based release automation.
matches = re.findall(r"^## \[([^\]]+)\]", changelog, re.MULTILINE)
version = next(
(m.strip() for m in matches if m.strip().lower() != "unreleased"),
None,
)
if version is None:
raise SystemExit("CHANGELOG.md에서 버전 섹션(## [x.y.z])을 찾지 못했습니다.")
print(version)
PY
)
echo "Tag version: ${TAG_VERSION}"
echo "pyproject version: ${PYPROJECT_VERSION}"
echo "changelog version: ${CHANGELOG_VERSION}"
if [[ "${TAG_VERSION}" != "${PYPROJECT_VERSION}" ]]; then
echo "태그 버전(${TAG_VERSION})과 pyproject 버전(${PYPROJECT_VERSION})이 일치하지 않습니다." >&2
exit 1
fi
if [[ "${TAG_VERSION}" != "${CHANGELOG_VERSION}" ]]; then
echo "태그 버전(${TAG_VERSION})과 changelog 최신 버전(${CHANGELOG_VERSION})이 일치하지 않습니다." >&2
exit 1
fi
- name: Extract latest changelog section for release notes
run: |
python - <<'PY'
from pathlib import Path
lines = Path("CHANGELOG.md").read_text(encoding="utf-8").splitlines()
# Find the first released version heading, skipping [Unreleased].
start = next(
(
i
for i, line in enumerate(lines)
if line.startswith("## [") and "unreleased" not in line.lower()
),
None,
)
if start is None:
raise SystemExit("CHANGELOG.md에서 릴리스 섹션을 찾지 못했습니다.")
end = next(
(i for i in range(start + 1, len(lines)) if lines[i].startswith("## [")),
len(lines),
)
section = "\n".join(lines[start:end]).strip() + "\n"
Path("release_notes.md").write_text(section, encoding="utf-8")
PY
- name: Build distributions (migrated from scripts/build-and-publish.sh)
run: |
python -m pip install --upgrade build twine
rm -rf dist build
python -m build
twine check dist/*
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
body_path: release_notes.md
files: dist/*