-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (59 loc) · 1.81 KB
/
Copy pathnpm-build-publish.yml
File metadata and controls
72 lines (59 loc) · 1.81 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
name: Build and Publish to npm
on:
push:
branches:
- main
jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['14.x', '16.x', '20.4.0']
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
publish:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- name: Extract version from package.json
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
- name: Check if version already published
run: |
echo "Checking version: ${{ env.VERSION }}"
NPM_VIEW_OUTPUT=$(npm view epsillajs@${{ env.VERSION }})
echo "npm view output: $NPM_VIEW_OUTPUT"
if [ -n "$NPM_VIEW_OUTPUT" ]; then
echo "Version ${{ env.VERSION }} already exists on npm. Please update the version."
exit 1
fi
- name: Bump version and push tag
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.PAT_TOKEN }}
tag_prefix: "v"
custom_tag: ${{ env.VERSION }}
dry_run: false
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}