1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-12-19 14:52:21 +03:00
leon/scripts/release/prepare-release.js
2022-09-26 21:29:56 +08:00

37 lines
1.0 KiB
JavaScript

import { LogHelper } from '@/helpers/log-helper'
import { LoaderHelper } from '@/helpers/loader-helper'
import updateVersion from './update-version'
import generateChangelog from './generate-changelog'
/**
* Main entry of the release preparation
*/
;(async () => {
LoaderHelper.start()
LogHelper.info('Preparing for release...')
const { argv } = process
const version = argv[2].toLowerCase()
const semverRegex =
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$/
if (version.match(semverRegex) !== null) {
try {
await updateVersion(version)
await generateChangelog(version)
LogHelper.success('Hooray! Leon is ready to be released!')
LoaderHelper.stop()
} catch (e) {
LogHelper.error(e)
LoaderHelper.stop()
}
} else {
LogHelper.error(
'The version number does match the Semantic Versioning rules (https://semver.org)'
)
LoaderHelper.stop()
}
})()