Skip to content

Commit

Permalink
fix(docs): publish github pages (#5411)
Browse files Browse the repository at this point in the history
  • Loading branch information
droshev authored May 30, 2024
1 parent 002b6f1 commit 0926feb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/actions/bump-version/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const recommendedVersion = require('conventional-recommended-bump');
const semver = require('semver');
const fs = require('fs');
const core = require('@actions/core');
const isHotfix = getInput('isHotfix') !== 'false';
const lernaJson = JSON.parse(fs.readFileSync('./lerna.json', 'utf8'));
const releaseType = core.getInput('isPrerelease') !== 'false' ? 'prerelease' : 'release';
const currentVersion = lernaJson.version;
Expand Down Expand Up @@ -66,9 +67,12 @@ const run = async() => {
core.info(`${release.reason}, therefore release type should be ${release.releaseType}`);

const newVersion = getNewVersion(release, currentVersion, prereleaseRequested);
const isPrerelease = !!semver.prerelease(newVersion, undefined);
const releaseTag = await getReleaseTag(isHotfix, isPrerelease, newVersion);
core.info(`new version is ${newVersion}`);

core.setOutput('newVersion', newVersion);
core.setOutput('releaseTag', releaseTag);
core.setOutput('isPrerelease', semver.prerelease(newVersion) ? 'true' : 'false');
};

Expand Down
28 changes: 28 additions & 0 deletions .github/actions/helpers/get-release-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const semver = require('semver');
const getVersion = require('./get-version');
/**
* Get the release tag for the current release
* @param isHotfix {boolean}
* @param isPrerelease {boolean}
* @param currentVersion {string}
* @returns {Promise<'latest' | 'hotfix' | 'prerelease'>}
*/
module.exports = async (isHotfix, isPrerelease, currentVersion) => {
const getTag = (isHotfixCheck, prereleaseCheck) =>
isHotfix && isHotfixCheck(currentVersion)
? 'hotfix'
: isPrerelease && prereleaseCheck
? 'prerelease'
: 'latest';

if (isHotfix && isPrerelease) {
throw new Error('Cannot be both hotfix and a prerelease');
}

const isHotfixMatch = async () => {
const latestVersion = await getVersion('origin/main');
return !semver.lt(latestVersion, currentVersion);
}

return getTag(isHotfixMatch, () => true);
};

0 comments on commit 0926feb

Please sign in to comment.