-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (78 loc) · 2.34 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
name: publish
on:
push:
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 🌀 clone the repository
uses: actions/checkout@v4
- name: 🔧 setup node.js
uses: actions/setup-node@v4
with:
cache: 'yarn'
node-version: 20.x
- name: 🔧 get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: 🔧 setup cache
uses: actions/cache@v4
id: yarn-cache
with:
path: |
**/node_modules
**/.eslintcache
**/dist
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ github.run_id }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ github.run_id }}-
- name: 📦 install dependencies
run: yarn
- name: 🛠️ build
run: yarn build
publish:
needs: build
strategy:
matrix:
registry: ['registry.npmjs.org', 'npm.pkg.github.com']
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: 🌀 clone the repository
uses: actions/checkout@v4
- name: 🔧 setup node.js
uses: actions/setup-node@v4
with:
cache: 'yarn'
node-version: 20.x
registry-url: 'https://${{ matrix.registry }}'
- name: 🔧 get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: 🔧 setup cache
uses: actions/cache@v4
id: yarn-cache
with:
path: |
**/node_modules
**/.eslintcache
**/dist
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ github.run_id }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ github.run_id }}-
- name: 🚀 publish to GitHub
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GH_TOKEN }}
if: matrix.registry == 'npm.pkg.github.com'
- name: 🚀 publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: matrix.registry == 'registry.npmjs.org'