-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
auto-publish-example.yml
58 lines (47 loc) · 1.88 KB
/
auto-publish-example.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
49
50
51
52
53
54
55
56
57
58
name: Auto-publish
on: push
jobs:
build: ... # If your package needs to be built, you can put that process here, so that it stays constantly updated
publish:
name: Publish to NPM & GitHub Package Registry
runs-on: ubuntu-latest
if: contains(github.ref, 'main') # Publish it only if the push comes from the main branch
needs: build # We need to wait for the build to be committed before publishing
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
- name: Check version changes
uses: EndBug/version-check@v2
id: check
- name: Version update detected
if: steps.check.outputs.changed == 'true'
run: 'echo "Version change found! New version: ${{ steps.check.outputs.version }} (${{ steps.check.outputs.type }})"'
- name: Set up Node.js for NPM
if: steps.check.outputs.changed == 'true'
uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
if: steps.check.outputs.changed == 'true'
run: npm install --only=prod
- name: Publish package to NPM
if: steps.check.outputs.changed == 'true'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Set up Node.js for GPR
if: steps.check.outputs.changed == 'true'
uses: actions/setup-node@v4
with:
registry-url: 'https://npm.pkg.github.com/'
scope: '@endbug'
- name: Set up package for GPR # You need to make sure you package name has the scope needed for GPR
if: steps.check.outputs.changed == 'true'
run: npm run gpr-setup
- name: Publish package to GPR
if: steps.check.outputs.changed == 'true'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}