-
-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
override current package.json version with the next version using semantic-release
- Loading branch information
1 parent
0b37ea2
commit a0c7c87
Showing
4 changed files
with
103 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const semanticRelease = require('semantic-release'); | ||
const releaserc = require('./.releaserc.json') | ||
const pkg = require('./package.json') | ||
|
||
const getNextVersion = async (): Promise<string> => { | ||
try { | ||
const result = await semanticRelease({ | ||
// Core options | ||
branches: releaserc.branches, | ||
repositoryUrl: pkg.repository.url, | ||
dryRun: true, | ||
ci: false, | ||
plugins: ['@semantic-release/commit-analyzer'] | ||
}); | ||
|
||
console.log("PROCESS_ENV_CI ---->>>>>>>>>>", process.env.CI); | ||
|
||
if (result) { | ||
const { lastRelease, commits, nextRelease } = result; | ||
console.log(`Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`); | ||
if (lastRelease.version) console.log(`The last release was "${lastRelease.version}".`); | ||
return nextRelease.version | ||
} else { | ||
console.log('No release published.'); | ||
} | ||
} catch (err) { | ||
console.error('The automated release failed with %O', err) | ||
} | ||
return "" | ||
} | ||
|
||
const fs = require('fs'); | ||
const csso = require('csso'); | ||
const packageConfigs = async () => { | ||
return { | ||
version: await getNextVersion() | ||
} | ||
} | ||
|
||
const prebuildPkg = 'temp/prebuild-package.json' | ||
if (!fs.existsSync("temp")) fs.mkdirSync("temp"); | ||
packageConfigs().then((config) => { | ||
const content = JSON.stringify(config) | ||
fs.writeFile(prebuildPkg, content, (err: any) => { | ||
if (err) throw err; | ||
console.log('empty.js created'); | ||
}) | ||
}) |
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