Skip to content

Commit

Permalink
search for latest semver tag - fixes #30
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed Aug 22, 2023
1 parent 66e13ee commit 6e08179
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,19 @@ async function main() {
if (args.gitless) return exit(new Error(`--gitless requires --base to be set`));
let stdout, exitCode;
try {
({stdout, exitCode} = await run(["git", "describe", "--abbrev=0", "--tags"], {silent: true}));
({stdout, exitCode} = await run(["git", "tag", "--list", "--sort=-creatordate"], {silent: true}));
} catch {}
if (exitCode !== 0) {

if (exitCode === 0) {
for (const tag of stdout.split("\r?\n").map(v => v.trim()).filter(Boolean)) {
if (isSemver(tag)) {
baseVersion = tag.replace(/^v/, "");
break;
}
}
}
if (!baseVersion) {
baseVersion = "0.0.0";
} else {
baseVersion = stdout;
}
} else {
baseVersion = args.base;
Expand Down

0 comments on commit 6e08179

Please sign in to comment.