Skip to content

Commit 935334a

Browse files
committed
feat(ci): use cache for yarn install and fix publication
1 parent 7ab8d7f commit 935334a

File tree

4 files changed

+3979
-4
lines changed

4 files changed

+3979
-4
lines changed

.github/workflows/publish.yml

+15-1
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,26 @@ jobs:
1313
name: Checkout [main]
1414
with:
1515
fetch-depth: 0
16+
17+
- name: Get yarn cache directory path
18+
id: yarn-cache-dir-path
19+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
20+
21+
- uses: actions/cache@v3
22+
id: yarn-cache
23+
with:
24+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
25+
key: ${{ runner.os }}-node18-yarn-${{ hashFiles('**/yarn.lock') }}
26+
restore-keys: |
27+
${{ runner.os }}-node18-yarn-
28+
1629
- uses: actions/setup-node@v3
1730
name: Setup Node
1831
with:
1932
node-version: '18'
33+
registry-url: 'https://registry.npmjs.org'
2034
- run: yarn install
2135
- run: yarn test
2236
- run: npm publish
2337
env:
24-
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
38+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

+28-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,27 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
node: [ 14, 16, 18 ]
13+
node: [14, 16, 18]
1414
if: ${{ github.event_name != 'pull_request' }}
1515
name: Test on main branch for node ${{ matrix.node }}
1616
steps:
1717
- uses: actions/checkout@v3
1818
name: Checkout [main]
1919
with:
2020
fetch-depth: 0
21+
22+
- name: Get yarn cache directory path
23+
id: yarn-cache-dir-path
24+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
25+
26+
- uses: actions/cache@v3
27+
id: yarn-cache
28+
with:
29+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
30+
key: ${{ runner.os }}-node${{ matrix.node }}-yarn-${{ hashFiles('**/yarn.lock') }}
31+
restore-keys: |
32+
${{ runner.os }}-node${{ matrix.node }}-yarn-
33+
2134
- uses: actions/setup-node@v3
2235
name: Setup Node
2336
with:
@@ -27,14 +40,27 @@ jobs:
2740
pr:
2841
strategy:
2942
matrix:
30-
node: [ 14, 16, 18 ]
43+
node: [14, 16, 18]
3144
runs-on: ubuntu-latest
3245
if: ${{ github.event_name == 'pull_request' }}
3346
steps:
3447
- uses: actions/checkout@v3
3548
with:
3649
ref: ${{ github.event.pull_request.head.ref }}
3750
fetch-depth: 0
51+
52+
- name: Get yarn cache directory path
53+
id: yarn-cache-dir-path
54+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
55+
56+
- uses: actions/cache@v3
57+
id: yarn-cache
58+
with:
59+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
60+
key: ${{ runner.os }}-node${{ matrix.node }}-yarn-${{ hashFiles('**/yarn.lock') }}
61+
restore-keys: |
62+
${{ runner.os }}-node${{ matrix.node }}-yarn-
63+
3864
- uses: actions/setup-node@v1
3965
with:
4066
node-version: ${{ matrix.node }}

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
node_modules
2-
yarn.lock
32
dist
43
coverage

0 commit comments

Comments
 (0)