Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions merge-release-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ const get = bent('json', process.env.NPM_REGISTRY_URL || 'https://registry.npmjs

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

let pkg = require(path.join(process.cwd(), 'package.json'))
const deployDir = path.join(process.cwd(), process.env.DEPLOY_DIR || './')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should also use path.normalize to remove the dangling ./ on the default case.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, it looks like .join does normalization now. i wonder why i thought it didn’t.

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);

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

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

const exec = str => process.stdout.write(execSync(str))
const exec = (str, cwd) => process.stdout.write(execSync(str, {cwd}))

let current = execSync(`npm view ${pkg.name} version`).toString()
exec(`npm version --allow-same-version=true --git-tag-version=false ${current} `)
console.log('current:', current, '/', 'version:', version)
let newVersion = execSync(`npm version --git-tag-version=false ${version}`).toString()
let currentVersion = execSync(`npm view ${pkg.name} version`, {cwd: srcPackageDir}).toString()
exec(`npm version --allow-same-version=true --git-tag-version=false ${currentVersion} `, srcPackageDir)
console.log('current:', currentVersion, '/', 'version:', version)
let newVersion = execSync(`npm version --git-tag-version=false ${version}`, srcPackageDir).toString()
exec(`npm version --allow-same-version=true --git-tag-version=false ${newVersion} `, deployDir)
console.log('new version:', newVersion)
exec(`npm publish`)
exec(`npm publish`, deployDir)
exec(`git checkout package.json`) // cleanup
exec(`git tag ${newVersion}`)
/*
Expand Down