-
Notifications
You must be signed in to change notification settings - Fork 4
43 lines (38 loc) · 1.22 KB
/
js-publish-package.yml
File metadata and controls
43 lines (38 loc) · 1.22 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
name: Publish JS package
on:
workflow_call:
inputs:
path:
required: true
type: string
name:
required: true
type: string
secrets:
NPM_TOKEN:
required: true
jobs:
publish:
if: (github.event_name == 'push' && github.ref_name == 'main') || github.event_name =='workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Restore build artifacts
uses: actions/cache/restore@v3
with:
path: ${{ format('{0}{1}/', inputs.path, 'dist') }}
key: ${{ inputs.name }}-dist
- name: Publish package
run: |
package=$(basename "${{ inputs.name }}")
scope=$(dirname "${{ inputs.name }}" | sed -r 's/@//g')
cd "${{ inputs.path }}dist/${scope}/${package}"
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}">>.npmrc
version=$(npm view ${{ inputs.name }} version 2>/dev/null) && npm version $version || true
npm version patch # patch current version
npm publish --access=public