-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (69 loc) · 2.39 KB
/
release.yml
File metadata and controls
82 lines (69 loc) · 2.39 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
name: Release
on:
workflow_dispatch:
push:
branches: [main]
permissions:
contents: write
jobs:
release:
name: Build & Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check for version change
id: version
run: |
NEW=$(node -p "require('./package.json').version")
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "version=$NEW" >> "$GITHUB_OUTPUT"
echo "Manual dispatch, publishing $NEW"
else
OLD=$(git show HEAD~1:package.json 2>/dev/null | node -p "JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')).version" 2>/dev/null || echo "")
if [ "$NEW" != "$OLD" ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "version=$NEW" >> "$GITHUB_OUTPUT"
echo "Version changed: $OLD -> $NEW"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "Version unchanged ($NEW), skipping publish"
fi
fi
- uses: pnpm/action-setup@v4
if: steps.version.outputs.changed == 'true'
with:
version: 10
- uses: actions/setup-node@v4
if: steps.version.outputs.changed == 'true'
with:
node-version: 20
cache: pnpm
registry-url: https://registry.npmjs.org
- name: Install dependencies
if: steps.version.outputs.changed == 'true'
run: pnpm install --frozen-lockfile
- name: Build
if: steps.version.outputs.changed == 'true'
run: pnpm build
- name: Test
if: steps.version.outputs.changed == 'true'
run: pnpm test
- name: Type tests
if: steps.version.outputs.changed == 'true'
run: pnpm test:types
- name: Typecheck
if: steps.version.outputs.changed == 'true'
run: pnpm typecheck
- name: Publish to npm
if: steps.version.outputs.changed == 'true'
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
if: steps.version.outputs.changed == 'true'
run: gh release create "v${{ steps.version.outputs.version }}" --generate-notes
env:
GH_TOKEN: ${{ github.token }}