Skip to content

Commit

Permalink
fix: fix release script
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean committed Oct 16, 2023
1 parent 87fd33d commit d0e57b1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,9 @@ $.env = {
GIT_TERMINAL_PROMPT: '0'
}

function escapeRegExp (string: string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
}

const vscodeVersion = process.argv[process.argv.length - 1]!
const minorVscodeVersion = `${semver.major(vscodeVersion)}.${semver.minor(vscodeVersion)}`
const tagPattern = new RegExp(`^v?(${escapeRegExp(minorVscodeVersion)}\\.\\d+)$`)
const tagPattern = /^v?(\\d+\\.\\d+\\.\\d+)$/

async function getLastTag () {
const tags = (await $`git tag -l --sort=-v:refname`).toString().split('\n').map(tag => tag.trim())
Expand All @@ -54,7 +50,12 @@ async function getLastTag () {
}

async function getNextVersion (lastTag?: string) {
return lastTag != null ? semver.inc(tagPattern.exec(lastTag)![1]!, 'patch')! : `${minorVscodeVersion}.0`
if (lastTag == null || !semver.satisfies(lastTag, `=${minorVscodeVersion}.x`)) {
// There is no last tag OR the tag is from an older minor version
return `${minorVscodeVersion}.0`
}

return semver.inc(tagPattern.exec(lastTag)![1]!, 'patch')!
}

function parseGithubUrl (repositoryUrl: string) {
Expand Down

0 comments on commit d0e57b1

Please sign in to comment.