Skip to content

Commit

Permalink
ci: Use current version as base for release PR builds
Browse files Browse the repository at this point in the history
  • Loading branch information
dvanoni committed Sep 1, 2024
1 parent 76942cb commit 0be3e9b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions scripts/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@ const versionJsPath = path.join(genDir, 'version.js');
export let version: string;

function getVersion(): string {
const isGitHubActions = Boolean(process.env.GITHUB_ACTIONS);
const isPublish = process.env.GITHUB_JOB === 'publish-artifacts';
const { GITHUB_ACTIONS, GITHUB_HEAD_REF, GITHUB_JOB } = process.env;

if (!isGitHubActions) return getLocalVersion();
if (!GITHUB_ACTIONS) return getLocalVersion();

if (!isPublish) return getPrereleaseVersion();
const isPublish = GITHUB_JOB === 'publish-artifacts';
if (isPublish) return pkg.version;

return pkg.version;
const isReleasePR = Boolean(GITHUB_HEAD_REF?.startsWith('release-please'));
const baseVersion = isReleasePR ? pkg.version : getPatchBumpVersion();
return getPrereleaseVersion(baseVersion);
}

function getLocalVersion(): string {
return `${getPatchBumpVersion()}-${os.userInfo().username}.${os.hostname()}`;
}

function getPrereleaseVersion(): string {
return `${getPatchBumpVersion()}-${process.env.GITHUB_RUN_NUMBER}`;
function getPrereleaseVersion(baseVersion: string): string {
return `${baseVersion}-${process.env.GITHUB_RUN_NUMBER}`;
}

function getPatchBumpVersion(): string {
Expand Down

0 comments on commit 0be3e9b

Please sign in to comment.