-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (112 loc) · 3.69 KB
/
Copy pathrelease.yml
File metadata and controls
138 lines (112 loc) · 3.69 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Release
run-name: Release • ${{ github.ref_name }}
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
tag:
description: 'Existing release tag to validate and publish, for example v0.1.0'
required: true
type: string
permissions:
contents: write
concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: false
jobs:
release:
name: Test, build docs, and publish release
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve release tag
id: release_tag
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
TAG="${{ inputs.tag }}"
git fetch --tags origin "refs/tags/${TAG}:refs/tags/${TAG}"
git checkout "${TAG}"
else
TAG="${GITHUB_REF_NAME}"
fi
echo "tag=${TAG}" >> "${GITHUB_OUTPUT}"
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: uv sync --frozen --group dev --group docs
- name: Validate release metadata
run: uv run python scripts/check_release.py --ci "${{ steps.release_tag.outputs.tag }}"
- name: Run tests
run: uv run pytest
- name: Build docs
env:
DISABLE_MKDOCS_2_WARNING: 'true'
run: uv run mkdocs build --strict
- name: Build Python package artifacts
run: uv build
- name: Build source archive
shell: bash
run: |
TAG="${{ steps.release_tag.outputs.tag }}"
git archive --format=zip --output "cloudscope-${TAG}.source.zip" HEAD
- name: Build docs archive
shell: bash
run: |
TAG="${{ steps.release_tag.outputs.tag }}"
cd site
zip -r "../cloudscope-${TAG}.docs.zip" .
- name: Extract release notes from CHANGELOG.md
shell: bash
run: |
python - <<'PY'
from pathlib import Path
import sys
tag = "${{ steps.release_tag.outputs.tag }}"
version = tag.removeprefix("v")
header_prefix = f"## [{version}]"
lines = Path("CHANGELOG.md").read_text(encoding="utf-8").splitlines()
start = None
for index, line in enumerate(lines):
if line.startswith(header_prefix):
start = index + 1
break
if start is None:
print(f"ERROR: Could not find CHANGELOG.md section for version {version}")
sys.exit(1)
body_lines = []
for line in lines[start:]:
if line.startswith("## ["):
break
body_lines.append(line)
body = "\n".join(body_lines).strip()
print(f"Extracted release notes for {tag}:")
print(body)
if not body:
print(f"ERROR: CHANGELOG.md section for version {version} is empty")
sys.exit(1)
Path("RELEASE_NOTES.md").write_text(body + "\n", encoding="utf-8")
PY
- name: Create GitHub Release and upload artifacts
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.release_tag.outputs.tag }}
shell: bash
run: |
gh release create "${TAG}" \
--title "CloudScope ${TAG}" \
--notes-file RELEASE_NOTES.md \
dist/* \
"cloudscope-${TAG}.source.zip" \
"cloudscope-${TAG}.docs.zip"