Repository navigation
81 lines (72 loc) · 2.43 KB
/
Copy pathrelease.yml
File metadata and controls
81 lines (72 loc) · 2.43 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
name: Release
# Creates a GitHub Release when a semver tag is pushed (`vX.Y.Z` or `vX.Y.Z-lts`).
# Downstream image builds pin this repo at the same tag.
on:
push:
tags:
- "v*.*.*"
- "v*.*.*-lts"
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Parse version / channel
id: meta
run: |
RAW="${GITHUB_REF_NAME}"
VER="${RAW#v}"
IS_LTS=false
if [[ "$RAW" == *-lts ]]; then
VER="${VER%-lts}"
IS_LTS=true
fi
echo "version=${VER}" >> "$GITHUB_OUTPUT"
echo "is_lts=${IS_LTS}" >> "$GITHUB_OUTPUT"
- uses: actions/setup-node@v5
with:
node-version: "24"
cache: npm
- run: npm ci
- run: npm run build
- run: npm test
- name: Write release notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
# Fresh notes every publish. Updating a release with generated notes
# appends another Full Changelog line, so the body is replaced below.
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
"/repos/${GITHUB_REPOSITORY}/releases/generate-notes" \
-f "tag_name=${GITHUB_REF_NAME}" \
--jq .body > /tmp/generated.md
python3 - << 'PY'
from pathlib import Path
lines = Path("/tmp/generated.md").read_text().splitlines()
body, changelogs = [], []
for line in lines:
plain = line.replace("*", "").strip().lower()
if plain.startswith("full changelog:"):
changelogs.append(line.strip())
else:
body.append(line)
while body and not body[-1].strip():
body.pop()
if changelogs:
body += ["", changelogs[-1]]
Path("release-notes.md").write_text("\n".join(body).rstrip() + "\n")
PY
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.meta.outputs.is_lts == 'true' && format('v{0} LTS', steps.meta.outputs.version) || format('v{0}', steps.meta.outputs.version) }}
body_path: release-notes.md
append_body: false