diff --git a/.github/renovate.json b/.github/renovate.json index 086784e..d7607b1 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -26,12 +26,5 @@ "groupName": "major-update" } ], - "extends": [ - "config:recommended", - ":pinVersions", - "npm:unpublishSafe", - ":prNotPending", - ":preserveSemverRanges", - ":rebaseStalePrs" - ] + "extends": ["config:recommended", ":pinVersions", "npm:unpublishSafe", ":prNotPending", ":preserveSemverRanges", ":rebaseStalePrs"] } diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 871d6cb..e701e39 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: cwd: 'test' install-ignore-scripts: true - - name: Check version + - name: Check node version id: check-version run: | NODE_VERSION=$(node -v) @@ -47,17 +47,18 @@ jobs: if: ${{ steps.check-pnpm-version.outputs.PNPM_VERSION_FIRST_PART != steps.check-pnpm-version.outputs.MATRIX_PNPM_VERSION_FIRST_PART }} run: exit 1 - test-version-file: + test-node-version-file: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ./ with: + pnpm: 9 cwd: 'test' node-file: '.node-version' install-ignore-scripts: true - - name: check version + - name: check node version id: check-node-version run: echo "VERSION=$(node -v)" >> $GITHUB_OUTPUT @@ -75,3 +76,35 @@ jobs: - name: Fail on wrong pnpm version (${{ steps.check-pnpm-version.outputs.PNPM_VERSION_FIRST_PART }}) if: ${{ steps.check-pnpm-version.outputs.PNPM_VERSION_FIRST_PART != '9' }} run: exit 1 + + test-package-version-manager: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + node: 22 + cwd: 'test/test-package-version-manager' + install-ignore-scripts: true + + - name: check node version + id: check-node-version + run: | + NODE_VERSION=$(node -v) + NODE_VERSION_FIRST_PART=$(echo $NODE_VERSION | cut -d. -f1) + echo "NODE_VERSION_FIRST_PART=$NODE_VERSION_FIRST_PART" >> $GITHUB_OUTPUT + + - name: fail on wrong version (${{ steps.check-node-version.outputs.NODE_VERSION_FIRST_PART }}) + if: ${{ steps.check-node-version.outputs.NODE_VERSION_FIRST_PART != 'v22' }} + run: exit 1 + + - name: Check pnpm version + id: check-pnpm-version + run: | + PNPM_VERSION=$(pnpm -v) + PNPM_VERSION_FIRST_PART=$(echo $PNPM_VERSION | cut -d. -f1) + echo "PNPM_VERSION_FIRST_PART=$PNPM_VERSION_FIRST_PART" >> $GITHUB_OUTPUT + + - name: Fail on wrong pnpm version (${{ steps.check-pnpm-version.outputs.PNPM_VERSION_FIRST_PART }}) + if: ${{ steps.check-pnpm-version.outputs.PNPM_VERSION_FIRST_PART != '9' }} + run: exit 1 diff --git a/.gitignore b/.gitignore index 32f1ab5..3c890b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ test/node_modules +test/test-package-version-manager/node_modules /.idea/ \ No newline at end of file diff --git a/README.md b/README.md index b560e8d..c4b215b 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout your repository using git - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: setup node and pnpm - uses: dafnik/setup-node-pnpm@v3 + uses: dafnik/setup-node-pnpm@v4 # with: - # pnpm: 8 # node: 22 # node-file: '' # cwd: '.' @@ -24,14 +23,15 @@ jobs: ``` -| Inputs | Default value | Description | -|--------------------------|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `pnpm` | `9` | PNPM version to install | -| `node` | `22` | Version Spec of the version to use in SemVer notation.
It also emits such aliases as lts, latest, nightly and canary builds.
Examples: 12.x, 10.15.1, >=10.15.0, lts/Hydrogen, 16-nightly, latest, node | -| `node-file` | `''` | File containing the version Spec of the version to use.
Examples: .nvmrc, .node-version, .tool-versions.
If `node` and `node-file` are both provided the action will use version from `node-file`. | -| `cwd` | `.` | Changes pnpm-lock.yaml lookup location and the work directory of "pnpm install" if enabled | -| `install` | `false` | Runs "pnpm install" in working directory | -| `install-ignore-scripts` | `false` | Runs "pnpm install --ignore-scripts" in working directory. Enable "install" or "install-ignore-scripts" only once | +| Inputs | Default value | Description | +|--------------------------|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `pnpm` | | PNPM version to install | +| `node` | `22` | Version Spec of the version to use in SemVer notation.
It also emits such aliases as lts, latest, nightly and canary builds.
Examples: 12.x, 10.15.1, >=10.15.0, lts/Hydrogen, 16-nightly, latest, node | +| `node-file` | `''` | File containing the version Spec of the version to use.
Examples: .nvmrc, .node-version, .tool-versions.
If `node` and `node-file` are both provided the action will use the version from `node-file`. | +| `cwd` | `.` | Changes pnpm-lock.yaml lookup location and the work directory of "pnpm install" if enabled | +| `package_file` | `package.json` | File path to the package.json to read "packageManager" configuration (also supports package.yml). Works in conjunction with "cwd" input. | +| `install` | `false` | Runs "pnpm install" in working directory | +| `install-ignore-scripts` | `false` | Runs "pnpm install --ignore-scripts" in working directory. Enable "install" or "install-ignore-scripts" only once | Furthermore, see [action.yml](action.yml) diff --git a/action.yml b/action.yml index 8f61a1b..465fa48 100644 --- a/action.yml +++ b/action.yml @@ -9,19 +9,22 @@ inputs: pnpm: description: 'PNPM version' required: false - default: '9' node: description: 'Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0.' required: false default: '22' node-file: - description: 'File containing the version Spec of the version to use. Examples: .nvmrc, .node-version, .tool-versions.' + description: 'File containing the version Spec of the version to use. Examples: .nvmrc, .node-version, .tool-versions. If "node" and "node-file" are both provided the action will use the version from "node-file".' required: false default: '' cwd: description: 'Work directory' required: false default: '.' + package_file: + description: 'File path to the package.json to read "packageManager" configuration (also supports package.yml). Works in conjunction with "cwd"' + required: false + default: 'package.json' install: description: 'Runs pnpm install' required: false @@ -38,6 +41,7 @@ runs: uses: pnpm/action-setup@v4 with: version: ${{ inputs.pnpm }} + package_json_file: '${{ inputs.cwd }}/${{ inputs.package_file }}' - name: use Node.js ${{ inputs.node }} if: "${{ inputs.node-file == '' }}" diff --git a/test/test-package-version-manager/package.json b/test/test-package-version-manager/package.json new file mode 100644 index 0000000..4fa1332 --- /dev/null +++ b/test/test-package-version-manager/package.json @@ -0,0 +1,13 @@ +{ + "name": "test-package-version-manager", + "version": "1.0.0", + "packageManager": "pnpm@9.11.0", + "description": "", + "main": "index.js", + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@types/node": "latest" + } +} diff --git a/test/test-package-version-manager/pnpm-lock.yaml b/test/test-package-version-manager/pnpm-lock.yaml new file mode 100644 index 0000000..9125f5d --- /dev/null +++ b/test/test-package-version-manager/pnpm-lock.yaml @@ -0,0 +1,11 @@ +lockfileVersion: '6.0' + +devDependencies: + '@types/node': + specifier: latest + version: 18.15.11 + +packages: + /@types/node@18.15.11: + resolution: {integrity: sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==} + dev: true