-
Notifications
You must be signed in to change notification settings - Fork 0
34 lines (32 loc) · 1 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
name: Publish on version change
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Check version and publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version");
git checkout $(git log --format="%H" -n 2 | tail -1) --quiet;
LAST_VERSION=$(node -p "require('./package.json').version");
if [ "$CURRENT_VERSION" != "$LAST_VERSION" ]; then
git checkout main;
npm install;
npm run build;
npm run test;
npm publish;
else
echo "Version has not changed. Skipping publish. CURRENT_VERSION: $CURRENT_VERSION, LAST_VERSION: $LAST_VERSION";
fi