Skip to content

Commit dd6b4c6

Browse files
authored
chore: disable the RC releases (#167)
* chore: disable rc releases * chore: add temp test changes * chore: add temp test changes * chore: add temp test changes * chore: clean up test changes * chore: clean up test changes * chore: clean up test changes * chore: clean up the start script
1 parent 2a2f2dd commit dd6b4c6

File tree

6 files changed

+27
-14
lines changed

6 files changed

+27
-14
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ jobs:
251251
needs: [state, provenance]
252252
name: Publish package to npm
253253
environment: npm
254-
if: needs.state.outputs.publish == 'true'
254+
if: needs.state.outputs.publish == 'true' && needs.state.outputs.is_prerelease == 'false'
255255
runs-on: ubuntu-latest
256256
steps:
257257
- name: Harden the runner (Audit all outbound calls)

scripts/changelog.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const formatted = changelog
2727
.replace(RELEASE_LINE_REGEX, (_, pr, entry) => (pr ? `- ${entry} (${pr})` : `- ${entry}`))
2828
// Add date to new version
2929
.replace(VERSION_TITLE_REGEX, `\n## $1 (${new Date().toISOString().split('T')[0]})`)
30-
// Conditionally allow vX.Y.Z-rc.W sections only in prerelease
31-
.replace(/^## \d\.\d\.\d-rc\S+[^]+?(?=^#)/gm, (section) => (isPrerelease ? section : ''));
30+
// Ensure RC or prereleases are not included
31+
.replace(/^## \d\.\d\.\d-rc\S+[^]+?(?=^#)/gm, (section) => (isPrerelease ? '' : section));
3232

3333
fs.writeFileSync('CHANGELOG.md', formatted);
34+

scripts/start.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,3 @@ git push origin "$RELEASE_BRANCH"
1515

1616
# Output branch
1717
echo "branch=$RELEASE_BRANCH" >> $GITHUB_OUTPUT
18-
19-
# Enter in prerelease state
20-
npx changeset pre enter rc

scripts/state.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,33 @@ module.exports = async ({ github, context, core }) => {
2323
setOutput('is_prerelease', state.prerelease);
2424
};
2525

26+
// Checks if the package has already been published on npm
27+
async function isPublishedOnNpm(packageName, version) {
28+
const res = await fetch(`https://registry.npmjs.com/${packageName}/${version}`);
29+
return res.ok;
30+
}
31+
32+
// Determines if the 'start' job should run
2633
function shouldRunStart({ isMain, isWorkflowDispatch, botRun }) {
2734
return isMain && isWorkflowDispatch && !botRun;
2835
}
2936

37+
// Determines if the 'promote' job should run
3038
function shouldRunPromote({ isReleaseBranch, isWorkflowDispatch, botRun }) {
3139
return isReleaseBranch && isWorkflowDispatch && !botRun;
3240
}
3341

42+
// Determines if the 'changesets' job should run
3443
function shouldRunChangesets({ isReleaseBranch, isPush, isWorkflowDispatch, botRun }) {
3544
return (isReleaseBranch && isPush) || (isReleaseBranch && isWorkflowDispatch && botRun);
3645
}
3746

38-
function shouldRunPublish({ isReleaseBranch, isPush, hasPendingChangesets, isPublishedOnNpm }) {
39-
return isReleaseBranch && isPush && !hasPendingChangesets && !isPublishedOnNpm;
47+
// Determines if the 'publish' job should run
48+
function shouldRunPublish({ isReleaseBranch, isPush, hasPendingChangesets, isPublishedOnNpm, prerelease }) {
49+
return isReleaseBranch && isPush && !hasPendingChangesets && !isPublishedOnNpm && !prerelease;
4050
}
4151

52+
// Determines if the 'merge' job should run
4253
function shouldRunMerge({
4354
isReleaseBranch,
4455
isPush,
@@ -50,6 +61,7 @@ function shouldRunMerge({
5061
return isReleaseBranch && isPush && !prerelease && isCurrentFinalVersion && !hasPendingChangesets && !prBackExists;
5162
}
5263

64+
// Gets the state of the repository, including various conditions like release status, branch, etc.
5365
async function getState({ github, context, core }) {
5466
// Variables not in the context
5567
const refName = process.env.GITHUB_REF_NAME;
@@ -105,8 +117,3 @@ async function readChangesetState(cwd = process.cwd()) {
105117
changesets,
106118
};
107119
}
108-
109-
async function isPublishedOnNpm(packageName, version) {
110-
const res = await fetch(`https://registry.npmjs.com/${packageName}/${version}`);
111-
return res.ok;
112-
}

scripts/tag.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ dist_tag() {
88
PACKAGE_JSON_VERSION="$(jq -r .version ./package.json)"
99

1010
if [ "$PRERELEASE" = "true" ]; then
11-
echo "next"
11+
echo "Skipping prerelease tag"
12+
exit 0
1213
elif npx semver -r ">$LATEST_NPM_VERSION" "$PACKAGE_JSON_VERSION" > /dev/null; then
1314
echo "latest"
1415
else

scripts/version.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
set -euo pipefail
44

5+
# Skip versioning for prereleases
6+
if [ "$PRERELEASE" = "true" ]; then
7+
echo "Skipping versioning for prerelease"
8+
exit 0
9+
fi
10+
511
pnpm changeset version
612

13+
echo "Updating changelog..."
714
scripts/changelog.js

0 commit comments

Comments
 (0)