-
Notifications
You must be signed in to change notification settings - Fork 82
108 lines (88 loc) · 2.58 KB
/
release.yml
File metadata and controls
108 lines (88 loc) · 2.58 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
name: Release to npm
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: 'Tag to publish (e.g., 9.5.0)'
required: true
type: string
jobs:
validate:
name: Validate Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name || github.event.inputs.tag }}
- name: Extract and validate version
id: version
run: |
TAG="${{ github.event.release.tag_name || github.event.inputs.tag }}"
VERSION="${TAG#v}"
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$'; then
echo "Error: Invalid version format: $VERSION"
exit 1
fi
PKG_VERSION=$(node -p "require('./package.json').version")
if [ "$VERSION" != "$PKG_VERSION" ]; then
echo "Error: Tag version ($VERSION) does not match package.json version ($PKG_VERSION)"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
test:
name: Test
runs-on: ubuntu-latest
needs: validate
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name || github.event.inputs.tag }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.14.0'
cache: 'yarn'
- name: Enable Corepack
run: corepack enable
- name: Install dependencies
run: yarn install --immutable
- name: Lint
run: yarn lint
- name: TypeScript
run: yarn typescript
- name: Unit tests
run: yarn test
- name: Build package
run: yarn prepare
publish:
name: Publish to npm
runs-on: ubuntu-latest
needs: [validate, test]
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name || github.event.inputs.tag }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.14.0'
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
- name: Enable Corepack
run: corepack enable
- name: Install dependencies
run: yarn install --immutable
- name: Build package
run: yarn prepare
- name: Publish to npm
run: npm publish --access public