diff --git a/README.md b/README.md index 3bb04f6..b95ff0c 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ jobs: | `publish-npm` | Publish the package to an npm registry when the release PR is merged | No | `false` | | `npm-token` | Auth token for the npm registry (required when `publish-npm` is `true`) | No | — | | `npm-registry` | npm registry URL (set to `https://npm.pkg.github.com` for GitHub Packages) | No | `https://registry.npmjs.org` | +| `npm-build-command` | Build command to run before `npm publish` (e.g., `npm run build`) | No | — | ## Outputs @@ -178,6 +179,7 @@ Commits that can't be linked to a PR will reference the commit SHA instead. github-token: ${{ secrets.GITHUB_TOKEN }} publish-npm: true npm-token: ${{ secrets.NPM_TOKEN }} + npm-build-command: 'npm run build' ``` ### Publish to GitHub Packages @@ -189,6 +191,7 @@ Commits that can't be linked to a PR will reference the commit SHA instead. publish-npm: true npm-token: ${{ secrets.GITHUB_TOKEN }} npm-registry: 'https://npm.pkg.github.com' + npm-build-command: 'npm run build' ``` ### Tag only, no GitHub release diff --git a/action.yml b/action.yml index f6638ec..9625e94 100644 --- a/action.yml +++ b/action.yml @@ -47,6 +47,9 @@ inputs: description: 'npm registry URL (e.g., https://npm.pkg.github.com for GitHub Packages)' required: false default: 'https://registry.npmjs.org' + npm-build-command: + description: 'Build command to run before npm publish (e.g., npm run build)' + required: false outputs: version: @@ -80,6 +83,7 @@ runs: INPUT_PUBLISH_NPM: ${{ inputs.publish-npm }} INPUT_NPM_TOKEN: ${{ inputs.npm-token }} INPUT_NPM_REGISTRY: ${{ inputs.npm-registry }} + INPUT_NPM_BUILD_COMMAND: ${{ inputs.npm-build-command }} PR_NUMBER: ${{ github.event.pull_request.number }} PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} PR_MERGED: ${{ github.event.pull_request.merged }} diff --git a/scripts/finalize-release.sh b/scripts/finalize-release.sh index e2782c1..f9598be 100755 --- a/scripts/finalize-release.sh +++ b/scripts/finalize-release.sh @@ -79,6 +79,12 @@ main() { echo "${registry_host}/:_authToken=${INPUT_NPM_TOKEN}" > .npmrc echo "registry=${registry}" >> .npmrc + if [[ -n "${INPUT_NPM_BUILD_COMMAND:-}" ]]; then + echo "Running build: ${INPUT_NPM_BUILD_COMMAND}" + npm install + eval "$INPUT_NPM_BUILD_COMMAND" + fi + npm publish rm -f .npmrc