Skip to content

Commit 27e1f41

Browse files
fix: Node release custom package path (#79)
* parametrized package path * parametrized package path * updated readme * Potential fix for code scanning alert no. 135: Code injection Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * Potential fix for code scanning alert no. 135: Code injection --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent e58cc1d commit 27e1f41

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

node-release/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The new version is saved in the output.
2424
skip_ci: true
2525
prerelease: false
2626
only_tag: false
27+
2728

2829
- run: echo "${{ steps.release.outputs.version }}"
2930
```
@@ -38,6 +39,7 @@ The new version is saved in the output.
3839
| skip_ci | True if you want skip CI workflows on commit release | false | `boolean` | true |
3940
| prerelease | True if it is a prerelease | false | `boolean` | false |
4041
| only_tag | True to create only the Tag without the Release | false | `boolean` | false |
42+
| package_path | Path leading to package.json file | false | `string` | ./ |
4143

4244
## Output
4345

node-release/action.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ inputs:
3535
type: boolean
3636
description: True to create only the Tag without the Release
3737
default: false
38+
package_path:
39+
required: false
40+
type: string
41+
description: Path leading to package.json file
42+
default: "./"
3843

3944

4045
outputs:
@@ -69,10 +74,12 @@ runs:
6974

7075
- id: get_version
7176
name: Get Version
77+
env:
78+
PACKAGE_PATH: ${{ inputs.package_path }}
7279
run: |
73-
PACKAGE_FILE="package.json"
80+
PACKAGE_FILE="${PACKAGE_PATH}package.json"
7481
if [[ -f "$PACKAGE_FILE" ]]; then
75-
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
82+
echo "version=$(node -p "require('${PACKAGE_PATH}package.json').version")" >> $GITHUB_ENV
7683
fi
7784
shell: bash
7885

@@ -100,9 +107,11 @@ runs:
100107
- name: Push New Version
101108
if: ${{ inputs.semver != 'skip' }}
102109
shell: bash
110+
env:
111+
PACKAGE_PATH: ${{ inputs.package_path }}
103112
run: |
104-
contents="$(jq '.version = "${{ steps.semver.outputs.new_version }}"' package.json)"
105-
echo -E "${contents}" > package.json
113+
contents="$(jq '.version = "${{ steps.semver.outputs.new_version }}"' ${PACKAGE_PATH}package.json)"
114+
echo -E "${contents}" > ${PACKAGE_PATH}package.json
106115
107116
git add .
108117
git config --global user.email "[email protected]"

0 commit comments

Comments
 (0)