-
Notifications
You must be signed in to change notification settings - Fork 16
77 lines (63 loc) · 1.72 KB
/
ci-cd.yaml
File metadata and controls
77 lines (63 loc) · 1.72 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
name: CI and Publish
on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches:
- master
permissions:
id-token: write # Required for OIDC (https://docs.npmjs.com/trusted-publishers)
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test
publish:
runs-on: ubuntu-latest
needs: test
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Check tag is beta
id: is_tag_beta
run: |
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
tags_name="${{ github.ref }}"
tags_name="${tags_name#refs/tags/}"
if [[ $tags_name == *"beta"* ]]; then
echo "is_beta=true" >> $GITHUB_OUTPUT
else
echo "is_beta=false" >> $GITHUB_OUTPUT
fi
fi
- name: Publish to npm (beta)
if: steps.is_tag_beta.outputs.is_beta == 'true'
run: npm publish --tag beta
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to npm
if: steps.is_tag_beta.outputs.is_beta == 'false'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}