Skip to content

Commit 236e74c

Browse files
authored
✨ add pnpm ci cache (#385)
* ✨ add pnpm ci cache * 📝 about pnpm/actions-setup
1 parent 7deccc1 commit 236e74c

File tree

5 files changed

+59
-6
lines changed

5 files changed

+59
-6
lines changed

.changeset/thirty-bears-doubt.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@aiou/generator-pnpm-ci": minor
3+
---
4+
5+
add pnpm ci cache

packages/generators/pnpm-ci/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ neo run @aiou/generator-pnpm-ci
1010

1111
prepack follow parts into your project
1212

13+
> **💡 NOTE**
14+
CI workflows will automatic choose pnpm version and cache `.pnpm-store` via <https://github.com/pnpm/action-setup>.
15+
1316
- `release.yml` - publish package with `changeset`
1417
- `snapshot-release.yml` - publish prerelease package with `changeset`
1518
- `husky`

packages/generators/pnpm-ci/assets/workflows/ci.yml

+17-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,23 @@ jobs:
2323
uses: actions/setup-node@v1
2424
with:
2525
node-version: ${{ matrix.node-version }}
26-
- name: Install pnpm
27-
run: npm i [email protected] -g
26+
- uses: pnpm/action-setup@v2
27+
name: Install pnpm
28+
id: pnpm-install
29+
with:
30+
run_install: false
31+
- name: get pnpm store directory
32+
id: pnpm-cache
33+
shell: bash
34+
run: |
35+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
36+
- uses: actions/cache@v3
37+
name: setup pnpm cache
38+
with:
39+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
40+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
41+
restore-keys: |
42+
${{ runner.os }}-pnpm-store-
2843
- name: Install
2944
run: |
3045
pnpm install --frozen-lockfile=false

packages/generators/pnpm-ci/assets/workflows/release.yml

+17-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,23 @@ jobs:
2727
uses: actions/setup-node@v2
2828
with:
2929
node-version: 14
30-
- name: install pnpm
31-
run: npm i [email protected] -g
30+
- uses: pnpm/action-setup@v2
31+
name: Install pnpm
32+
id: pnpm-install
33+
with:
34+
run_install: false
35+
- name: get pnpm store directory
36+
id: pnpm-cache
37+
shell: bash
38+
run: |
39+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
40+
- uses: actions/cache@v3
41+
name: setup pnpm cache
42+
with:
43+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
44+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
45+
restore-keys: |
46+
${{ runner.os }}-pnpm-store-
3247
- name: install dependencies
3348
run: pnpm install --frozen-lockfile=false
3449
- name: create and publish versions

packages/generators/pnpm-ci/assets/workflows/snapshot-release.yml

+17-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,23 @@ jobs:
2525
uses: actions/setup-node@v2
2626
with:
2727
node-version: 14
28-
- name: install pnpm
29-
run: npm i [email protected] -g
28+
- uses: pnpm/action-setup@v2
29+
name: Install pnpm
30+
id: pnpm-install
31+
with:
32+
run_install: false
33+
- name: get pnpm store directory
34+
id: pnpm-cache
35+
shell: bash
36+
run: |
37+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
38+
- uses: actions/cache@v3
39+
name: setup pnpm cache
40+
with:
41+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
42+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
43+
restore-keys: |
44+
${{ runner.os }}-pnpm-store-
3045
- name: install dependencies
3146
run: pnpm install --frozen-lockfile=false
3247
- name: create and publish versions

0 commit comments

Comments
 (0)