-
Notifications
You must be signed in to change notification settings - Fork 84
64 lines (55 loc) · 1.64 KB
/
widget-npm.yml
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
name: Publish Hexabot Widget NPM Package
on:
push:
tags:
- 'v*'
workflow_dispatch: # Allow manual trigger
jobs:
publish-package:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18' # Ensure it matches your project requirements
cache: 'npm'
- name: Install Husky
run: npx husky install
- name: Install dependencies
run: |
cd widget/
npm ci
- name: Build the package
run: |
cd widget/
npm run build
- name: Determine release type
id: determine-release
run: |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV
if [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.0$ ]]; then
echo "release=minor" >> $GITHUB_ENV
elif [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "release=patch" >> $GITHUB_ENV
else
echo "release=none" >> $GITHUB_ENV
fi
else
echo "release=none" >> $GITHUB_ENV
fi
- name: Login to npm
if: env.release != 'none'
uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org/'
node-version: '18'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to npm
if: env.release != 'none'
run: |
cd widget/
npm publish