-
Notifications
You must be signed in to change notification settings - Fork 1
98 lines (86 loc) · 3.13 KB
/
npm-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
name: Publish Package
on:
release:
types:
- released
workflow_dispatch:
inputs:
gpr:
default: "yes"
description: Publish to GPR?
required: true
jobs:
prepare:
name: Prepare the source code
runs-on: ubuntu-latest
if: github.event_name == 'release' || github.event.inputs.npm == 'yes' || github.event.inputs.gpr == 'yes'
steps:
- name: Checkout source
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
ref: ${{ github.event.release.tag_name }}
- name: Set up Node.js environment
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: lts/*
registry-url: https://npm.pkg.github.com
cache: npm
- name: Install dependencies
run: npm ci --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run postinstall scripts
run: npm rebuild && npm run prepare --if-present
- name: Create tarball
run: npm pack
- name: Save tarball
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3
with:
name: package
path: "*.tgz"
retention-days: 1
publish:
name: Publish package
runs-on: ubuntu-latest
needs: prepare
strategy:
matrix:
registry:
- gpr
include:
- registry: gpr
secret: GITHUB_TOKEN
registry_url: https://npm.pkg.github.com/
steps:
- name: Set commit status to PENDING
uses: myrotvorets/set-commit-status-action@243b4f7e597f62335408d58001edf8a02cf3e1fd # v1.1.7
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: pending
context: Publish to ${{ matrix.registry }}
sha: ${{ github.sha }}
if: github.event.inputs[matrix.registry] == 'yes' || github.event_name == 'release'
- name: Set up Node.js environment
if: github.event.inputs[matrix.registry] == 'yes' || github.event_name == 'release'
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: lts/*
registry-url: ${{ matrix.registry_url }}
- name: Download tarball
if: github.event.inputs[matrix.registry] == 'yes' || github.event_name == 'release'
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3
with:
name: package
- name: Publish package
if: github.event.inputs[matrix.registry] == 'yes' || github.event_name == 'release'
run: npm publish *.tgz
env:
NODE_AUTH_TOKEN: ${{ secrets[matrix.secret] }}
- name: Set final commit status
uses: myrotvorets/set-commit-status-action@243b4f7e597f62335408d58001edf8a02cf3e1fd # v1.1.7
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
context: Publish to ${{ matrix.registry }}
sha: ${{ github.sha }}
if: always() && (github.event.inputs[matrix.registry] == 'yes' || github.event_name == 'release')