set-changesets-pr-title.js 768 B

1234567891011121314151617
  1. const { coerce, inc, rsort } = require('semver');
  2. const { join } = require('path');
  3. const { version } = require(join(__dirname, '../../../package.json'));
  4. module.exports = async ({ core }) => {
  5. // Variables not in the context
  6. const refName = process.env.GITHUB_REF_NAME;
  7. // Compare package.json version's next patch vs. first version patch
  8. // A recently opened branch will give the next patch for the previous minor
  9. // So, we get the max against the patch 0 of the release branch's version
  10. const branchPatch0 = coerce(refName.replace('release-v', '')).version;
  11. const packageJsonNextPatch = inc(version, 'patch');
  12. const [nextVersion] = rsort([branchPatch0, packageJsonNextPatch], false);
  13. core.exportVariable('TITLE', `Release v${nextVersion}`);
  14. };