-
-
Notifications
You must be signed in to change notification settings - Fork 341
62 lines (55 loc) · 1.63 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
name: Publish Package
on:
release:
types: [created]
workflow_dispatch:
inputs:
skip:
description: Skip release to repository
required: false
tag:
description: Tag name
required: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout release
if: github.event_name != 'workflow_dispatch'
uses: actions/checkout@v4
- name: Checkout tag
uses: actions/checkout@v4
if: github.event_name == 'workflow_dispatch'
with:
ref: ${{ github.event.inputs.tag }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '16.x'
registry-url: https://registry.npmjs.org
- name: Install dependencies and add lib
run: |
npm install
npm run build
sed -i -e '/lib\//d' .gitignore
- name: Publish to NPM
if: "!contains(github.event.inputs.skip, 'skip-npm')"
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Change to GitHub Packages registry
uses: actions/setup-node@v4
with:
registry-url: https://npm.pkg.github.com
scope: '@shivammathur'
- name: Patch package.json
run: |
sed -i 's#"name": "#"name": "@shivammathur/#' package.json
- name: Publish to GitHub Packages
if: "!contains(github.event.inputs.skip, 'skip-github-packages')"
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}