fix: switch from secrets to inputs in npm-publish

This commit is contained in:
2025-02-09 03:08:12 +02:00
parent a44f1431dd
commit e4301e4e3c
2 changed files with 36 additions and 2 deletions

View File

@@ -13,6 +13,16 @@ Publishes the package to the NPM registry with configurable scope and registry U
| `registry-url` | <p>Registry URL for publishing.</p> | `false` | `https://registry.npmjs.org/` | | `registry-url` | <p>Registry URL for publishing.</p> | `false` | `https://registry.npmjs.org/` |
| `scope` | <p>Package scope to use.</p> | `false` | `@ivuorinen` | | `scope` | <p>Package scope to use.</p> | `false` | `@ivuorinen` |
| `package-version` | <p>The version to publish.</p> | `false` | `${{ github.event.release.tag_name }}` | | `package-version` | <p>The version to publish.</p> | `false` | `${{ github.event.release.tag_name }}` |
| `npm_token` | <p>NPM token.</p> | `true` | `""` |
### Outputs
| name | description |
|-------------------|-------------------------------------|
| `registry-url` | <p>Registry URL for publishing.</p> |
| `scope` | <p>Package scope to use.</p> |
| `package-version` | <p>The version to publish.</p> |
| `npm_token` | <p>NPM token.</p> |
### Runs ### Runs
@@ -40,4 +50,10 @@ This action is a `composite` action.
# #
# Required: false # Required: false
# Default: ${{ github.event.release.tag_name }} # Default: ${{ github.event.release.tag_name }}
npm_token:
# NPM token.
#
# Required: true
# Default: ""
``` ```

View File

@@ -21,6 +21,24 @@ inputs:
description: 'The version to publish.' description: 'The version to publish.'
required: false required: false
default: ${{ github.event.release.tag_name }} default: ${{ github.event.release.tag_name }}
npm_token:
description: 'NPM token.'
required: true
default: ''
outputs:
registry-url:
description: 'Registry URL for publishing.'
value: ${{ inputs.registry-url }}
scope:
description: 'Package scope to use.'
value: ${{ inputs.scope }}
package-version:
description: 'The version to publish.'
value: ${{ inputs.package-version }}
npm_token:
description: 'NPM token.'
value: ${{ inputs.token }}
runs: runs:
using: composite using: composite
@@ -31,12 +49,12 @@ runs:
- name: Authenticate NPM - name: Authenticate NPM
shell: bash shell: bash
run: | run: |
echo "//${{ inputs.registry-url }}/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc echo "//${{ inputs.registry-url }}/:_authToken=${{ inputs.npm_token }}" > ~/.npmrc
- name: Publish Package - name: Publish Package
shell: bash shell: bash
env: env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ inputs.npm_token }}
run: | run: |
pkg_version=$(node -p "require('./package.json').version") pkg_version=$(node -p "require('./package.json').version")
if [ "$pkg_version" != "${{ inputs.package-version }}" ]; then if [ "$pkg_version" != "${{ inputs.package-version }}" ]; then