-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (62 loc) · 2.08 KB
/
release.yml
File metadata and controls
73 lines (62 loc) · 2.08 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
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-*"
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
sanity:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 22
cache: npm
- run: npm ci
- name: Verify tag matches package.json version
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
PKG_VERSION=$(node -e "console.log(require('./package.json').version)")
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) does not match package.json ($PKG_VERSION)"
exit 1
fi
- name: Verify package.json hygiene
run: |
node -e "
const pkg = require('./package.json');
const required = ['name', 'version', 'description', 'license', 'repository', 'engines'];
const missing = required.filter(f => !pkg[f]);
if (missing.length) { console.error('Missing:', missing.join(', ')); process.exit(1); }
"
- run: npm run lint
- run: npm test
release:
needs: sanity
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Extract version
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Extract changelog
run: |
VERSION="${{ steps.version.outputs.version }}"
awk "/^## \[${VERSION}\]/{found=1; next} /^## \[/{if(found) exit} found{print}" CHANGELOG.md > release-notes.txt
if [ ! -s release-notes.txt ]; then echo "Release v${VERSION}" > release-notes.txt; fi
- name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "$GITHUB_REF_NAME" \
--title "v${{ steps.version.outputs.version }}" \
--notes-file release-notes.txt \
--verify-tag