-
Notifications
You must be signed in to change notification settings - Fork 2
48 lines (40 loc) · 1.07 KB
/
npm.yaml
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
name: Publish to npm
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
registry-url: 'https://registry.npmjs.org/'
- name: Determine pre-release tag
id: release-tag
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "Detected tag: $TAG_NAME"
if [[ "$TAG_NAME" == *-alpha.* ]]; then
echo "tag=alpha" >> $GITHUB_ENV
npm version --no-git-tag-version $TAG_NAME
else
echo "tag=latest" >> $GITHUB_ENV
fi
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Compile the code
run: npm run compile
- name: Publish
run: npm publish --access public --tag ${{ env.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}