-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (95 loc) · 3.28 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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: publish
on:
push:
branches:
- master
jobs:
build:
name: Build and Test package
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
steps:
- name: Checkout repository
uses: actions/checkout@master
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@master
with:
node-version: ${{ matrix.node-version }}
registry-url: https://npm.pkg.github.com/
scope: "@x42en"
- run: npm i -g pnpm
- run: pnpm install
- run: pnpm run build
- run: pnpm test
env:
CI: true
publish:
name: Publish to NPM & GitHub Package Registry
runs-on: ubuntu-latest
if: contains(
'refs/heads/master
refs/heads/develop'
, github.ref) # Publish it only if the push comes from the master or develop branch
needs: build # We need to wait for the build to be committed before publishing
steps:
- name: Checkout repository
uses: actions/checkout@master
with:
ref: master
- name: Check version changes
uses: EndBug/version-check@v2
id: check
with:
file-url: https://unpkg.com/ioserver@latest/package.json
static-checking: localIsNew
- 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: Push tag version
if: steps.check.outputs.changed == 'true'
uses: mathieudutour/github-tag-action@v5
with:
custom_tag: ${{ steps.check.outputs.version }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub release
if: steps.check.outputs.changed == 'true'
uses: actions/create-release@master
with:
tag_name: ${{ steps.check.outputs.version }}
release_name: Release ${{ steps.check.outputs.version }}
body: ${{ steps.tag_version.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js for NPM
if: steps.check.outputs.changed == 'true'
uses: actions/setup-node@master
with:
registry-url: "https://registry.npmjs.org"
scope: "@x62en"
- name: Install PNPM
if: steps.check.outputs.changed == 'true'
run: npm i -g pnpm
- name: Install dependencies
if: steps.check.outputs.changed == 'true'
run: pnpm install
- name: Publish package to NPM
if: steps.check.outputs.changed == 'true'
run: pnpm publish --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: Set up Node.js for GPR
if: steps.check.outputs.changed == 'true'
uses: actions/setup-node@master
with:
registry-url: "https://npm.pkg.github.com/"
scope: "@x42en"
- name: Set up package for GPR
if: steps.check.outputs.changed == 'true'
run: pnpm run gpr-setup
- name: Publish package to GPR
if: steps.check.outputs.changed == 'true'
run: pnpm publish --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}