Skip to content

Commit 14c90d7

Browse files
authored
Added functionality for mono-repos (different src and dist folders) (#19)
* Add DEPLOY_DIR and SRC_PACKAGE_DIR variables * Fix for incorrect cwd
1 parent e81a028 commit 14c90d7

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

merge-release-run.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ 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+
const deployDir = path.join(process.cwd(), process.env.DEPLOY_DIR || './')
16+
const srcPackageDir = path.join(process.cwd(), process.env.SRC_PACKAGE_DIR || './')
17+
18+
console.log(' using deploy directory : ' + deployDir);
19+
console.log('using src directory (package.json) : ' + srcPackageDir);
20+
21+
let pkg = require(path.join(deployDir, 'package.json'))
1622

1723
const run = async () => {
1824
if (!process.env.NPM_AUTH_TOKEN) throw new Error('Merge-release requires NPM_AUTH_TOKEN')
@@ -50,14 +56,15 @@ const run = async () => {
5056
version = 'minor'
5157
}
5258

53-
const exec = str => process.stdout.write(execSync(str))
59+
const exec = (str, cwd) => process.stdout.write(execSync(str, {cwd}))
5460

55-
let current = execSync(`npm view ${pkg.name} version`).toString()
56-
exec(`npm version --allow-same-version=true --git-tag-version=false ${current} `)
57-
console.log('current:', current, '/', 'version:', version)
58-
let newVersion = execSync(`npm version --git-tag-version=false ${version}`).toString()
61+
let currentVersion = execSync(`npm view ${pkg.name} version`, {cwd: srcPackageDir}).toString()
62+
exec(`npm version --allow-same-version=true --git-tag-version=false ${currentVersion} `, srcPackageDir)
63+
console.log('current:', currentVersion, '/', 'version:', version)
64+
let newVersion = execSync(`npm version --git-tag-version=false ${version}`, {cwd: srcPackageDir}).toString()
65+
exec(`npm version --allow-same-version=true --git-tag-version=false ${newVersion} `, deployDir)
5966
console.log('new version:', newVersion)
60-
exec(`npm publish`)
67+
exec(`npm publish`, deployDir)
6168
exec(`git checkout package.json`) // cleanup
6269
exec(`git tag ${newVersion}`)
6370
exec(`echo "::set-output name=version::${newVersion}"`) // set action event.{STEP_ID}.output.version

0 commit comments

Comments
 (0)