-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0172eb7
commit 22704b2
Showing
2 changed files
with
8 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
"repository": "github:CartoDB/carto-api-client", | ||
"author": "Don McCurdy <[email protected]>", | ||
"packageManager": "[email protected]", | ||
"version": "0.2.1-alpha.4", | ||
"version": "0.2.1-alpha.5", | ||
"license": "MIT", | ||
"publishConfig": { | ||
"access": "public", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
import {execSync} from 'node:child_process'; | ||
import {readFile} from 'node:fs/promises'; | ||
import {resolve} from 'node:path'; | ||
import {valid} from 'semver'; | ||
|
||
/** | ||
* Utility for committing and tagging a release commit in | ||
* git, called as part of the `yarn postversion` script. | ||
*/ | ||
|
||
const {version} = await import('../package.json', {assert: {type: 'json'}}); | ||
// Read and validate pkg.version. | ||
const pkgJSON = await readFile(resolve('./package.json'), 'utf-8'); | ||
const {version} = JSON.parse(pkgJSON); | ||
if (!valid(version)) { | ||
throw new Error(`Invalid version, "${version}"`); | ||
} | ||
|
||
// Check out a branch if cutting a version from 'main'. | ||
const branch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim(); | ||
if (branch === 'main') { | ||
execSync(`git checkout -b 'release/${version}'`); | ||
} | ||
|
||
// Commit and tag. | ||
execSync('git add -u'); | ||
execSync(`git commit -m 'chore(release): ${version}'`); | ||
execSync(`git tag -a ${version} -m ${version}`); |