Skip to content

Add a flag to allow skipping Github release creation#108

Closed
akphi wants to merge 1 commit intochangesets:mainfrom
akphi:skip-create-release
Closed

Add a flag to allow skipping Github release creation#108
akphi wants to merge 1 commit intochangesets:mainfrom
akphi:skip-create-release

Conversation

@akphi
Copy link
Copy Markdown

@akphi akphi commented Aug 30, 2021

Fixes #87

Added a flag called SKIP_CREATE_GITHUB_RELEASE to allow skipping publishing release to Github

@Andarist If you have other suggestions on the config name or the way I pass down the boolean please let me know I can fix it ASAP. Would be really appreciative if you could spare some time to look at this. Thank you so much!

Also, I thought about adding some documentation for this on the README.md file, but not sure how to organize that, do you have any suggestion here?

@Andarist
Copy link
Copy Markdown
Member

@akphi could you describe your use case that requires introducing this option?

@akphi
Copy link
Copy Markdown
Author

akphi commented Dec 21, 2021

@Andarist My use case is fairly similar to that of babel: I have a monorepo with many workspaces/packages. If I were to publish them, I would accumulate thousands of tags and releases on Github after a short period of time (I saw emotion doing this, but I would prefer not doing it that way). I would like to use the Github release page a little more sparingly. Ideally, I want to create an accumulated release note per release, but that's off the scope of this feature request.

I could temporarily workaround for now, by setting a post-release script to delete created tags and releases, but it's a hack 😅.

@akphi
Copy link
Copy Markdown
Author

akphi commented Dec 21, 2021

Btw, @Andarist I saw your change in changesets/changesets#701 to add --no-git-tag. It will help at least not creating the tags, but the releases are still being created by changesets/action right?

@Andarist
Copy link
Copy Markdown
Member

Would fixed packages and aggregated releases address your needs? Note that I'm planning to introduce those aggregated releases only for linked and fixed packages - at least for now. Introducing that for regular packages is quite problematic when it comes to changeset creation, sorting etc.

Btw, @Andarist I saw your change in changesets/changesets#701 to add --no-git-tag. It will help at least not creating the tags, but the releases are still being created by changesets/action right?

I think that releases should not be created with this flag (but I have not tested it). It's because releases are created based on the created tags:

action/src/run.ts

Lines 88 to 114 in 37c2edd

let newTagRegex = /New tag:\s+(@[^/]+\/[^@]+|[^/]+)@([^\s]+)/;
let packagesByName = new Map(packages.map((x) => [x.packageJson.name, x]));
for (let line of changesetPublishOutput.stdout.split("\n")) {
let match = line.match(newTagRegex);
if (match === null) {
continue;
}
let pkgName = match[1];
let pkg = packagesByName.get(pkgName);
if (pkg === undefined) {
throw new Error(
`Package "${pkgName}" not found.` +
"This is probably a bug in the action, please open an issue"
);
}
releasedPackages.push(pkg);
}
await Promise.all(
releasedPackages.map((pkg) =>
createRelease(octokit, {
pkg,
tagName: `${pkg.packageJson.name}@${pkg.packageJson.version}`,
})
)
);

That being said - the flag that you are asking for is still useful for the use case described in #87. The author of that issue would like to skip creating github releases for their prereleases.

Could you rebase this PR on top of the current main branch? In the process please remove the dist/index.js file - since it's no longer committed to the repo.

src/index.ts Outdated

(async () => {
let githubToken = process.env.GITHUB_TOKEN;
let skipCreateGithubRelease = Boolean(process.env.SKIP_CREATE_GITHUB_RELEASE);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think that the input option for the action would make more sense and I would call it createGithubReleases. It's default value would be true so you could disable it with false.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair point, I also figure this is a bit specific for this use case so polluting function param list with this boolean flag is not great, hence I wrapped it in options. If you think that's overkill, let me know.

src/run.ts Outdated
pkg,
tagName: `${pkg.packageJson.name}@${pkg.packageJson.version}`,
},
skipCreateGithubRelease
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It imho makes more sense to call createRelease conditionally, rather than to skip releasing within this function.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole content of the createRelease function is about creating the Github release, so I used a guarded if, but perhaps, putting the whole thing in an if block is a bit more future proof 😅

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Dec 26, 2021

⚠️ No Changeset found

Latest commit: cacfa37

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@akphi
Copy link
Copy Markdown
Author

akphi commented Dec 26, 2021

What about documentation, I would like to mention this somewhere if possible, but I don't know where you would want me to put it.

@akphi akphi changed the base branch from master to main December 26, 2021 15:33
@akphi akphi closed this Dec 26, 2021
@akphi
Copy link
Copy Markdown
Author

akphi commented Dec 26, 2021

Due to the change in base branch master -> main, I have to recreate the PR - #130

@Andarist
Copy link
Copy Markdown
Member

Due to the change in base branch master -> main, I have to recreate the PR - #130

Just a tip - the target branch can usually be changed after clicking Edit. You can change the PR's title there but also the target branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skip createRelease

2 participants