-
-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (86 loc) · 3.72 KB
/
Copy pathrelease.yml
File metadata and controls
95 lines (86 loc) · 3.72 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
name: Release
# Tag-triggered build → zip → GitHub Release pipeline (PLAN.md Phase 0, #71).
#
# Pushing a `vX.Y.Z` tag builds the theme, assembles the same bundle that
# `make build-theme` ships (adapted from upstream jupyter-book/myst-theme's
# `theme-assets.yml`), and publishes a GitHub Release for the tag with
# `quantecon-theme.zip` attached. Lectures then pin a release URL:
# …/releases/download/vX.Y.Z/quantecon-theme.zip
#
# The zip contains:
# build/, public/ (from `npm run prod:build`)
# template.yml (version stamped from package.json — #71)
# server.js, package.json, LICENSE, README.md, thumbnail.png, qe-logo.png
# (from template/, with VERSION substituted)
# package-lock.json (generated; node_modules is NOT shipped)
# CHANGELOG.md
#
# Guards (both fail the release):
# - the tag must match `package.json` `version`
# - CHANGELOG.md must have a `## [X.Y.Z]` section — it becomes the release notes
#
# This replaces the Changesets release.yml (removed in #72). The legacy
# `make deploy` push to QuantEcon/quantecon-theme remains only until consumers
# are repointed to pinned release URLs (PLAN.md Phase 0 consumer migration).
on:
push:
tags: ['v*.*.*']
permissions:
contents: write
jobs:
release:
name: Build & publish release zip
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 24
cache: npm
- name: Verify tag matches package.json version
run: |
VERSION=$(node -p "require('./package.json').version")
if [ "v$VERSION" != "$GITHUB_REF_NAME" ]; then
echo "::error::Tag $GITHUB_REF_NAME does not match package.json version v$VERSION — bump package.json (see CONTRIBUTING.md \"Releases\") and re-tag."
exit 1
fi
- name: Extract release notes from CHANGELOG.md
run: |
VERSION=$(node -p "require('./package.json').version")
awk -v ver="$VERSION" '
index($0, "## [" ver "]") == 1 { flag = 1; next }
/^## / { flag = 0 }
flag
' CHANGELOG.md > release-notes.md
if ! grep -q '[^[:space:]]' release-notes.md; then
echo "::error::CHANGELOG.md has no \"## [$VERSION]\" section — add the curated entry (see CONTRIBUTING.md \"Releases\") and re-tag."
exit 1
fi
- run: npm ci
- run: npm run compile
- name: Build
# esbuild occasionally deadlocks (QuantEcon/quantecon-theme-src — known
# flake); time out fast so the run can simply be retried.
timeout-minutes: 20
run: npm run prod:build
- name: Assemble theme bundle and zip
run: |
VERSION=$(node -p "require('./package.json').version")
DIST=dist/quantecon-theme
mkdir -p "$DIST"
find template -type f -exec cp {} "$DIST" \;
cp -r public "$DIST/public"
cp -r build "$DIST/build"
cp CHANGELOG.md "$DIST/CHANGELOG.md"
# Stamp both version fields from package.json so the shipped bundle
# cannot drift (#71).
sed -i "s/VERSION/$VERSION/g" "$DIST/package.json"
sed -E "s/^version: .*/version: $VERSION/" template.yml > "$DIST/template.yml"
# Lockfile for reproducible consumer installs, without shipping node_modules.
(cd "$DIST" && npm install --package-lock-only)
(cd dist && zip -r ../quantecon-theme.zip quantecon-theme)
- name: Publish GitHub Release
uses: softprops/action-gh-release@v3
with:
body_path: release-notes.md
files: quantecon-theme.zip