Skip to content

Commit

Permalink
support private package deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvaro Jose committed Aug 14, 2023
1 parent 12b05f7 commit 55aa1e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ You can configure some aspects of merge-release action by passing some environme
* The path where the src package.json is found. Defaults to the root dir.
* **NPM_REGISTRY_URL**
* NPM Registry URL to use. defaults to: `https://registry.npmjs.org/`
* **NPM_PRIVATE**
* If you wish privately publish your package please ensure you have set this to `true`

`merge-release` will use `npm publish` unless you've defined a `publish` script in your `package.json`.

Expand Down
3 changes: 3 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ inputs:
NPM_AUTH_TOKEN:
description: 'NPM_AUTH_TOKEN'
required: true
NPM_PRIVATE:
description: 'NPM_PRIVATE'
required: false
DEPLOY_DIR:
description: 'DEPLOY_DIR'
required: false
Expand Down
6 changes: 5 additions & 1 deletion src/merge-release-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const srcPackageDir = path.join(process.cwd(), process.env.SRC_PACKAGE_DIR || '.
console.log(' using deploy directory : ' + deployDir)
console.log('using src directory (package.json) : ' + srcPackageDir)

const access = process.env.NPM_PRIVATE==='true' ? 'restricted' : 'public'

console.log('deploy to NPM with access : ' + access)

let pkg = require(path.join(deployDir, 'package.json'))

const run = async () => {
Expand Down Expand Up @@ -88,7 +92,7 @@ const run = async () => {
if (pkg.scripts && pkg.scripts.publish) {
exec(`npm run publish`, deployDir)
} else {
exec(`npm publish`, deployDir)
exec(`npm publish --access=${access}`, deployDir)
}
exec(`git checkout package.json`) // cleanup
exec(`git tag ${newVersion}`)
Expand Down

0 comments on commit 55aa1e7

Please sign in to comment.