-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (98 loc) · 3.26 KB
/
release.yml
File metadata and controls
116 lines (98 loc) · 3.26 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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
id-token: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Verify tag matches package.json
if: github.event_name == 'push'
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
PKG_VERSION=$(node -p "require('./package.json').version")
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
echo "::error::Tag $GITHUB_REF_NAME does not match package.json version $PKG_VERSION"
exit 1
fi
- name: Determine dist-tag
id: disttag
run: |
VERSION=$(node -p "require('./package.json').version")
case "$VERSION" in
*-alpha*) TAG=alpha ;;
*-beta*) TAG=beta ;;
*-rc*) TAG=next ;;
*) TAG=latest ;;
esac
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
if [ "$TAG" = "latest" ]; then
echo "prerelease=false" >> "$GITHUB_OUTPUT"
else
echo "prerelease=true" >> "$GITHUB_OUTPUT"
fi
- name: Build
run: pnpm build
- name: Unit tests
run: pnpm test
- name: Dry-run smoke tests
run: bash scripts/test-run.sh
- name: npm publish (dry-run)
if: github.event_name == 'workflow_dispatch'
run: npm publish --dry-run --access public --tag ${{ steps.disttag.outputs.tag }}
- name: Dispatch summary
if: github.event_name == 'workflow_dispatch'
run: |
VERSION=$(node -p "require('./package.json').version")
{
echo "### Dry-run release validation"
echo ""
echo "- Version: \`$VERSION\`"
echo "- Would publish to dist-tag: \`${{ steps.disttag.outputs.tag }}\`"
echo "- No real publish or GitHub Release performed."
} >> "$GITHUB_STEP_SUMMARY"
- name: Publish to npm
if: github.event_name == 'push'
run: npm publish --provenance --access public --tag ${{ steps.disttag.outputs.tag }}
- name: Extract release notes from CHANGELOG
if: github.event_name == 'push'
id: notes
run: |
VERSION="${GITHUB_REF_NAME#v}"
awk -v ver="$VERSION" '
$0 ~ "^## \\[" ver "\\]" { capture=1; next }
capture && /^## \[/ { exit }
capture { print }
' CHANGELOG.md > /tmp/notes.md
{
echo 'body<<NOTES_EOF'
cat /tmp/notes.md
echo 'NOTES_EOF'
} >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
if: github.event_name == 'push'
uses: softprops/action-gh-release@v2
with:
name: ${{ github.ref_name }}
body: ${{ steps.notes.outputs.body }}
prerelease: ${{ steps.disttag.outputs.prerelease }}