-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (73 loc) · 2.29 KB
/
npm-publish.yml
File metadata and controls
84 lines (73 loc) · 2.29 KB
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
name: Publish Package
on:
release:
types:
- released
workflow_dispatch:
inputs:
npm:
default: "yes"
description: Publish to NPM?
required: true
permissions:
contents: read
jobs:
prepare:
name: Prepare the source code
runs-on: ubuntu-latest
if: github.event_name == 'release' || github.event.inputs.npm == 'yes'
steps:
- name: Checkout source
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
ref: ${{ github.event.release.tag_name }}
- name: Set up Node.js environment
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: lts/*
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@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: package
path: "*.tgz"
retention-days: 1
publish:
permissions:
contents: none
id-token: write
name: Publish package
runs-on: ubuntu-latest
needs: prepare
strategy:
matrix:
registry:
- npm
include:
- registry: npm
secret: NPM_TOKEN
registry_url: https://registry.npmjs.org/
steps:
- name: Set up Node.js environment
if: github.event.inputs[matrix.registry] == 'yes' || github.event_name == 'release'
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
registry-url: ${{ matrix.registry_url }}
- name: Download tarball
if: github.event.inputs[matrix.registry] == 'yes' || github.event_name == 'release'
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
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] }}