-
Notifications
You must be signed in to change notification settings - Fork 1
48 lines (42 loc) · 1.35 KB
/
publish-on-version-change.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
name: npm-publish
on:
push:
branches:
- chore/auto_publish # Change this to your default branch
jobs:
check-version-change:
name: check-version-change
runs-on: ubuntu-latest
outputs:
version: ${{ steps.check.outputs.triggered }}
did-version-change: ${{ steps.check.outputs.changed }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Determine if version has changed
- name: Check version changes
uses: EndBug/version-check@v2
id: check
publish-to-npm:
name: publish-to-npm
runs-on: ubuntu-latest
needs: [check-version-change]
if: needs.check-version-change.outputs.did-version-change == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Draft a release if version name changed
- name: Draft release
run: 'gh release create v${{ needs.check-version-change.outputs.version }} -d --notes ""'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js for NPM
uses: actions/setup-node@v4
with:
registry-url: "https://registry.npmjs.org"
- name: Build lib
run: "npm i && npm run buildLib"
- name: Publish package to NPM
run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}