-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (37 loc) · 1.2 KB
/
publish.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
name: Publish npm package
on:
push:
branches:
- main
jobs:
publish:
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'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: pnpm i
- name: Run tests
run: pnpm test
- name: Check if version changed
id: version_check
run: |
git fetch origin main
PREVIOUS_VERSION=$(git show origin/main:package.json | jq -r .version)
CURRENT_VERSION=$(jq -r .version package.json)
echo "previous_version=$PREVIOUS_VERSION" >> $GITHUB_OUTPUT
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
if [ "$PREVIOUS_VERSION" == "$CURRENT_VERSION" ]; then
echo "Version has not changed. Exiting."
exit 0
fi
- name: Publish to npm
if: ${{ steps.version_check.outputs.current_version != steps.version_check.outputs.previous_version }}
run: pnpm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}