Skip to content

Commit

Permalink
fix(create-release-branch): define releaseBranch also on `.release.br…
Browse files Browse the repository at this point in the history
…anches.[].channel` as that is used to tag on npm
  • Loading branch information
JordiVM committed Oct 30, 2024
1 parent b8df781 commit 5c46228
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ When you want to manage a product with different releases and support old versio
npm test
```

## Test the release tools locally
Change the directory to a repository you want to test the release tools with (e.g. livingdocs-server), the release tools will be executed in the context of the repository you are in. Both repositories should be in the same parent directory. Then run the following command:
```bash
node ../release-tools/bin/cmd.js create-release-branch \
--repo=repoName \
--base-tag=validVersion \
--release-branch-name=test-release \
--npm-token=validNPMToken
```
A validVersion is a tag that exists in the repository you are in and fulfils semver constraints:
- latest version of minor bump (e.g. 1.2.latest)
- newer minor or major version exist (e.g. 1.3.0 or 2.0.0 exist)

## Copyright

Expand Down
19 changes: 13 additions & 6 deletions lib/shell/sh-update-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,22 @@ module.exports = function (dep) {
// eslint-disable-next-line no-extra-boolean-cast
const result = exec(`jq '.release.branches != null' package.json`)
if (result.stdout === 'true') {
propertyName = 'release.branches.[0].name'
exec(`cat package.json \
| jq ".release.branches.[0].name=\\"${argv.releaseBranchName}\\" \
| .release.branches.[0].channel=\\"${argv.releaseBranchName}\\" \
| .publishConfig.tag=\\"${argv.releaseBranchName}\\"" \
| cat > package.json.tmp && mv package.json.tmp package.json`
)
propertyName = 'release.branches'
} else {
exec(`cat package.json \
| jq ".release.branch=\\"${argv.releaseBranchName}\\" \
| .publishConfig.tag=\\"${argv.releaseBranchName}\\"" \
| cat > package.json.tmp && mv package.json.tmp package.json`
)
propertyName = 'release.branch'
}
exec(`cat package.json \
| jq ".${propertyName}=\\"${argv.releaseBranchName}\\" \
| .publishConfig.tag=\\"${argv.releaseBranchName}\\"" \
| cat > package.json.tmp && mv package.json.tmp package.json`
)

logYellow(`Updated ${propertyName} in package.json`)
}
}

0 comments on commit 5c46228

Please sign in to comment.