Repository navigation
59 lines (52 loc) · 1.8 KB
/
Copy pathgithub-release.yml
File metadata and controls
59 lines (52 loc) · 1.8 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
name: GitHub release
# Pushing a tag such as v0.14.0 publishes a GitHub release whose notes are that
# version's section of CHANGELOG.md. npm publishing stays manual; see
# docs/releasing.md.
on:
push:
tags: ["v[0-9]+.[0-9]+.[0-9]+*"]
permissions:
contents: read
jobs:
release:
name: Publish release notes
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
env:
TAG: ${{ github.ref_name }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
fetch-tags: true
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Check the tag against the package version
run: |
set -euo pipefail
version="$(node -p 'require("./package.json").version')"
if [ "$TAG" != "v$version" ]; then
echo "Tag $TAG does not match package version $version." >&2
exit 1
fi
- name: Write the release notes from CHANGELOG.md
run: |
set -euo pipefail
# The newest earlier release tag, for the comparison link; empty on the first release.
previous="$(git describe --tags --abbrev=0 --match 'v[0-9]*' "$TAG^" 2>/dev/null || true)"
node scripts/changelog-section.mjs "$TAG" --release "$previous" > "$RUNNER_TEMP/notes.md"
- name: Create the GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
prerelease=()
case "$TAG" in *-*) prerelease=(--prerelease) ;; esac
gh release create "$TAG" --repo "$GITHUB_REPOSITORY" --verify-tag \
--title "$TAG" --notes-file "$RUNNER_TEMP/notes.md" "${prerelease[@]}"