Compare commits

..

7 Commits

Author SHA1 Message Date
Khải 57b9359b4c Merge pull request #41 from nelson6e65/patch-1
docs(readme): improve Cache example
2022-05-07 10:00:37 +07:00
Khải ec1a8b444c Change runs-on back to ubuntu-latest 2022-05-07 09:59:56 +07:00
Nelson Martell 73e15250cb docs(readme): improve and fix cache example
Dynamically detect the Store directory and use the latest GitHub actions.
2022-05-06 21:57:00 -05:00
Khải 10b4b0b462 Merge pull request #36 from pnpm/dependabot/github_actions/actions/checkout-3
Bump actions/checkout from 2 to 3
2022-03-08 10:33:01 +07:00
Khải 5fa8980bf4 Update dependabot.yml 2022-03-08 10:32:48 +07:00
dependabot[bot] ae78e9abbe Bump actions/checkout from 2 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-07 23:02:26 +00:00
Jack Works 35ab4267a1 fix: packageManager reader (#35)
* fix: packageManager reader

* chore: resolve review

* chore: run build
2022-02-25 12:43:26 +08:00
6 changed files with 46 additions and 25 deletions
-3
View File
@@ -5,6 +5,3 @@ updates:
schedule: schedule:
interval: weekly interval: weekly
open-pull-requests-limit: 10 open-pull-requests-limit: 10
labels:
- dependabot
- github-actions
+3 -3
View File
@@ -22,7 +22,7 @@ jobs:
- windows-latest - windows-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Run the action - name: Run the action
uses: ./ uses: ./
@@ -51,7 +51,7 @@ jobs:
- windows-latest - windows-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Run the action - name: Run the action
uses: ./ uses: ./
@@ -107,7 +107,7 @@ jobs:
- pnpm - pnpm
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Run the action - name: Run the action
uses: ./ uses: ./
+28 -13
View File
@@ -102,21 +102,36 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
build: - name: Checkout
- uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Cache pnpm modules - name: Install Node.js
uses: actions/cache@v2 uses: actions/setup-node@v3
with: with:
path: ~/.pnpm-store node-version: 16
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- uses: pnpm/action-setup@v2.1.0 - uses: pnpm/action-setup@v2.0.1
with: name: Install pnpm
version: 6.0.2 id: pnpm-install
run_install: true with:
version: 7
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
``` ```
**Note:** You don't need to run `pnpm store prune` at the end; post-action has already taken care of that. **Note:** You don't need to run `pnpm store prune` at the end; post-action has already taken care of that.
-1
View File
@@ -6,7 +6,6 @@ branding:
inputs: inputs:
version: version:
description: Version of PNPM to install description: Version of PNPM to install
required: true
dest: dest:
description: Where to store PNPM files description: Where to store PNPM files
required: false required: false
+1 -1
View File
File diff suppressed because one or more lines are too long
+14 -4
View File
@@ -8,13 +8,15 @@ import { Inputs } from '../inputs'
export async function runSelfInstaller(inputs: Inputs): Promise<number> { export async function runSelfInstaller(inputs: Inputs): Promise<number> {
const { version, dest } = inputs const { version, dest } = inputs
const pkgJson = path.join(dest, 'package.json')
const target = await readTarget(pkgJson, version)
// prepare self install
await remove(dest) await remove(dest)
const pkgJson = path.join(dest, 'package.json')
await ensureFile(pkgJson) await ensureFile(pkgJson)
await writeFile(pkgJson, JSON.stringify({ private: true })) await writeFile(pkgJson, JSON.stringify({ private: true }))
// prepare target pnpm
const target = await readTarget(version)
const cp = spawn(execPath, ['-', 'install', target, '--no-lockfile'], { const cp = spawn(execPath, ['-', 'install', target, '--no-lockfile'], {
cwd: dest, cwd: dest,
stdio: ['pipe', 'inherit', 'inherit'], stdio: ['pipe', 'inherit', 'inherit'],
@@ -36,10 +38,18 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
return exitCode return exitCode
} }
async function readTarget(packageJsonPath: string, version?: string | undefined) { async function readTarget(version?: string | undefined) {
if (version) return `pnpm@${version}` if (version) return `pnpm@${version}`
const { packageManager } = JSON.parse(await readFile(packageJsonPath, 'utf8')) const { GITHUB_WORKSPACE } = process.env
if (!GITHUB_WORKSPACE) {
throw new Error(`No workspace is found.
If you're intended to let pnpm/action-setup read preferred pnpm version from the "packageManager" field in the package.json file,
please run the actions/checkout before pnpm/action-setup.
Otherwise, please specify the pnpm version in the action configuration.`)
}
const { packageManager } = JSON.parse(await readFile(path.join(GITHUB_WORKSPACE, 'package.json'), 'utf8'))
if (typeof packageManager !== 'string') { if (typeof packageManager !== 'string') {
throw new Error(`No pnpm version is specified. throw new Error(`No pnpm version is specified.
Please specify it by one of the following ways: Please specify it by one of the following ways: