Skip to content

Commit 6c9f963

Browse files
committed
Add support for publishing a package that isn't at repo root
1 parent c05919e commit 6c9f963

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,15 @@ you'll need to configure that workflow yourself. You can look to the
2020
* All other changes will increment the patch version.
2121
* Publish to npm using the configured token.
2222
* Push a tag for the new version to GitHub.
23+
24+
### Additional Configuration
25+
26+
* If your `package.json` is not in the repo's root directory, set `PACKAGE_PATH` env variable and the publish commands will be run from that package directory.
27+
```
28+
- name: Publish
29+
uses: mikeal/merge-release@master
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
33+
PACKAGE_PATH: ./packages/my-package
34+
```

merge-release-run.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const get = bent('json', process.env.NPM_REGISTRY_URL || 'https://registry.npmjs
1212

1313
const event = JSON.parse(fs.readFileSync('/github/workflow/event.json').toString())
1414

15-
let pkg = require(path.join(process.cwd(), 'package.json'))
15+
let packagePath = process.env.PACKAGE_PATH || process.cwd()
16+
let pkg = require(path.join(packagePath, 'package.json'))
1617

1718
const run = async () => {
1819
if (!process.env.NPM_AUTH_TOKEN) throw new Error('Merge-release requires NPM_AUTH_TOKEN')
@@ -52,6 +53,7 @@ const run = async () => {
5253

5354
const exec = str => process.stdout.write(execSync(str))
5455

56+
exec(`cd ${packagePath}`)
5557
let current = execSync(`npm view ${pkg.name} version`).toString()
5658
exec(`npm version --allow-same-version=true --git-tag-version=false ${current} `)
5759
console.log('current:', current, '/', 'version:', version)

0 commit comments

Comments
 (0)