Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create GitHub release and git tag with custom publishing #269

Open
mholta opened this issue Feb 28, 2023 · 5 comments
Open

Create GitHub release and git tag with custom publishing #269

mholta opened this issue Feb 28, 2023 · 5 comments

Comments

@mholta
Copy link

mholta commented Feb 28, 2023

Problem

We are using changesets/action@v1 for versioning and publishing of a non-npm application (one "root" application, no packages). In our workflow we have implemented custom publishing as referred to (https://github.com/changesets/action#custom-publishing). This works as expected, apart from GitHub releases and git tags not being created. In a (separate) monorepo publishing to NPM, this is working as expected.

According to https://github.com/changesets/changesets/blob/main/docs/versioning-apps.md, it seems like this should be possible.

We have tested that it works with changeset/cli.

As far as I can tell, after some investigation, createRelease is not called if publish: is not specified in the workflow.

Current workaround

After looking into the runPublish method, we found that putting publish: yarn dummy-publish in the workflow and "dummy-release": "echo \"New tag:" && exit 0" under scripts in package.json. This satisfies the condition.

action/src/run.ts

Lines 133 to 138 in 595655c

let newTagRegex = /New tag:/;
for (let line of changesetPublishOutput.stdout.split("\n")) {
let match = line.match(newTagRegex);
if (match) {

@mholta mholta changed the title Create GitHub tag/release with custom publishing Create GitHub release and git tag with custom publishing Feb 28, 2023
@Andarist
Copy link
Member

After looking into the runPublish method, we found that putting publish: yarn dummy-publish in the workflow and "dummy-release": "echo "New tag:" && exit 0" under scripts in package.json. This satisfies the condition.

This is basically what I was also doing. I think that nowadays you should be able to make private packages taggable and that should automatically resolve the issue - I agree that it's not exactly obvious but perhaps it's just a documentation issue. This requirement is vaguely mentioned here

@mholta
Copy link
Author

mholta commented Feb 28, 2023

I see! So having a "dummy" publish script that satisfies the /New tag:/ regex is the best solution for now? Would it be worth mentioning in versioning-apps.md? It took quite some time before I realised why this PR didn't fix it.

Note: Changesets only versions NPM package.json files, you can trigger releases for other package formats by creating workflows which trigger on tags/releases being created by changesets.

@Andarist
Copy link
Member

I see! So having a "dummy" publish script that satisfies the /New tag:/ regex is the best solution for now?

I'm not 100% sure but I think that with this privatePackages: { version: true, tag: true } your private package should get tagged and that in turn should output this New tag: into the stdout and thus the changesets/action should create a GitHub release for this. The main q is - how exactly you will kick off the actual publication of whatever you are publishing there? I usually do smth like "release": "changeset publish && node ./handle-custom-publishing.js"

Would it be worth mentioning in versioning-apps.md? It took quite some time before I realised why changesets/changesets#662 didn't fix it.

I'm definitely open for docs PRs 😉

@mholta
Copy link
Author

mholta commented Mar 1, 2023

After some investigation and testing we found that including changeset tag in the action release script suffice. Ref PR #271

@mholta
Copy link
Author

mholta commented Mar 8, 2023

Have you veen able to look into the PR @Andarist? I'll be more than happy to make changes or discuss the implementation.

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

No branches or pull requests

2 participants