-
Notifications
You must be signed in to change notification settings - Fork 1
65 lines (53 loc) · 1.63 KB
/
publish-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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Deploy to npm
on:
push:
tags:
- 'v*' # Only trigger when a version tag (e.g., v1.0.0) is pushed
jobs:
publish:
runs-on: ubuntu-latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Display Git Information
run: |
echo "GITHUB_REF: $GITHUB_REF"
echo "GITHUB_SHA: $GITHUB_SHA"
git log -1
- name: Get the tag name
id: get_tag
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Use the tag name
run: echo "The tag name is $TAG_NAME"
env:
TAG_NAME: ${{ env.TAG_NAME }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18.18.0
registry-url: 'https://registry.npmjs.org'
scope: '@wireio'
cache: 'npm'
- name: Check version match
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if [[ "v$PACKAGE_VERSION" != "$TAG_NAME" ]]; then
echo "Error: package.json version (v$PACKAGE_VERSION) does not match the git tag ($TAG_NAME). Please update package.json and rerun the action."
exit 1
else
echo "Version match ✅"
fi
env:
TAG_NAME: ${{ env.TAG_NAME }}
- name: Install dependencies
run: npm ci
- name: Build
run: make lib
- name: Run make publish
run: make ci-publish
env:
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}