diff --git a/packages/core/src/auto.ts b/packages/core/src/auto.ts index b52a3905b..c7253ebca 100644 --- a/packages/core/src/auto.ts +++ b/packages/core/src/auto.ts @@ -1310,9 +1310,14 @@ export default class Auto { } if (!pr || !build) { - canaryIdentifier = `${canaryIdentifier}.${( - await this.git.getSha(true) - ).slice(0, 7)}`; + const sha = await this.git.getSha(); + // If the commit sha is a 7 digit number starting with zero + // SemVer will reject the version. Include enough of the sha + // to include at least one letter in that case. + const endIndex = /^0\d{6}/.test(sha) ? + sha.search(/[a-zA-Z]/) + 1 + : 7; + canaryIdentifier = `${canaryIdentifier}.${sha.slice(0, endIndex)}`; } canaryIdentifier = `-canary${canaryIdentifier}`;