-
Notifications
You must be signed in to change notification settings - Fork 23
65 lines (55 loc) · 1.7 KB
/
publish-lib.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
65
name: Publish Library to NPM
# Trigger on tag push
on:
push:
tags:
- 'API-v*'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Setup Node.js environment
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
# Extract version from tag
- name: Extract API version
run: echo "API_VERSION=${GITHUB_REF_NAME#API-v}" >> $GITHUB_ENV
# Setup Bun
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
# Update version in source code
- name: Update API version constant
run: |
sed -i "s/COCKPIT_WIDGET_API_VERSION = '.*'/COCKPIT_WIDGET_API_VERSION = '${{ env.API_VERSION }}'/" src/libs/external-api/api.ts
# Install dependencies
- name: Install dependencies
run: bun install --frozen-lockfile
# Build library
- name: Build library
run: bun run build:lib
working-directory: .
# Create package.json for distribution
- name: Create package.json for library
run: |
cd dist/lib
{
echo '{
"name": "@bluerobotics/cockpit-api",
"version": "'${{ env.API_VERSION }}'",
"main": "cockpit-external-api.umd.js",
"module": "cockpit-external-api.es.js",
"publishConfig": {
"access": "public"
}
}'
} > package.json
# Publish to NPM
- name: Publish to NPM
run: npm publish
working-directory: dist/lib
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}