Files
cypress/scripts/semantic-commits/validate-binary-changelog.js
Matt Schile 896cca293a chore: use 0.0.0-development sentinel for root package version (#33604)
Removes the need to manually bump the root package.json version before
each release. The get-next-version.js script now always computes the
next version from commit history against the last npm release, using
the checked-in version only as an explicit override when it's a real
semver (not the sentinel).
2026-04-21 13:43:13 -06:00

58 lines
1.7 KiB
JavaScript

const fs = require('fs')
const path = require('path')
const { validateChangelog } = require('./validate-changelog')
const { getCurrentReleaseData } = require('./get-current-release-data')
const { getReleaseData } = require('./get-binary-release-data')
const checkedInBinaryVersion = require('../../package.json').version
const SENTINEL_VERSION = '0.0.0-development'
const changelog = async () => {
const latestReleaseInfo = await getCurrentReleaseData()
const hasVersionBump = checkedInBinaryVersion !== SENTINEL_VERSION &&
!latestReleaseInfo.versions.includes(checkedInBinaryVersion) // account for branches behind develop
if (process.env.CIRCLECI) {
console.log({ checkedInBinaryVersion })
if (process.env.CIRCLE_BRANCH !== 'develop' && process.env.CIRCLE_BRANCH !== 'add-skip-changelog-validation' && !/^release\/\d+\.\d+\.\d+$/.test(process.env.CIRCLE_BRANCH) && !hasVersionBump) {
console.log('Only verify the entire changelog for develop, a release branch or any branch that bumped to the Cypress version in the package.json.')
return
}
}
const releaseData = await getReleaseData(latestReleaseInfo)
const dirPath = path.join(path.sep, 'tmp', 'releaseData')
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath)
}
fs.writeFileSync(path.join(dirPath, 'releaseData.json'), JSON.stringify(releaseData, null, 2))
console.log('Release data saved to', path.join(dirPath, 'releaseData.json'))
const {
nextVersion,
changedFiles,
commits,
} = releaseData
return validateChangelog({
nextVersion,
changedFiles,
commits,
})
}
if (require.main !== module) {
module.exports.changelog = changelog
return
}
(async () => {
await changelog()
})()