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

Setting up a changesets based release workflow #681

Merged
merged 28 commits into from
Oct 22, 2021

Conversation

jonrohan
Copy link
Member

This PR creates a Changesets based release workflow for octicons. We're already using this workflow in primer/css, primer/primitives, primer/react, ... but we weren't using here because of the mixed language nature of primer/octicons it made this difficult.

Strategy

Changesets is built around npm, and if this repo was only that it wouldn't be a problem. What we had to overcome was publishing 3 npm packages and 3 rubygems packages when releases were created.

I had a breakthrough recently when I realized all I need changesets to do is manage the changelog and create the GitHub release. From that GitHub release we can trigger the normal build action that we're running today.

This allows us to use changesets here. To get this workflow right I did testing in this private fork octicons-test repo. I was able to get changesets to create the release PR https://github.com/primer/octicons-test/pull/2 versioning all the packages then when that was merged it created the GitHub release https://github.com/primer/octicons-test/releases/tag/v16.0.1. The trick here was making changesets think we published to npm https://github.com/primer/octicons/blob/setup_changesets_workflow/.github/workflows/release.yml#L43

@jonrohan jonrohan marked this pull request as ready for review October 22, 2021 17:19
@jonrohan
Copy link
Member Author

I believe this pull request is ready. But with most actions based things, we won't really be sure it's working until we run through the workflow once

@@ -1,21 +1,28 @@
{
"private": true,
Copy link
Member Author

Choose a reason for hiding this comment

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

I'd rather keep this private, but changesets will skip if they find private true here, so I'm trying to avoid publishing main package.json file by adding

+  "publishConfig": {
+    "registry": "http://localhost:4873"
+  },

Copy link
Contributor

Choose a reason for hiding this comment

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

Where does that port number come from?

Copy link
Member Author

@jonrohan jonrohan Oct 22, 2021

Choose a reason for hiding this comment

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

I was wanting to point to anything other than npm and co-pilot suggested this 😆 The point is to fail it out so people don't npm publish from their terminal.

I'll accept whatever you think here.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, should we just say like "no registry" or something to make it clear that this is a noop?

Using http://localhost:4873 feels like it's pointing to something real

Copy link
Member Author

Choose a reason for hiding this comment

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

"publishConfig": {
    "registry": "no registry, don't publish from this package.json."
},

branches-ignore:
- 'dependabot/**'
release:
types: [published]
name: Octicons Build
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we rename this workflow to "publish"?


Once maintainers have agreed and are satisifed with the release. Merge the Release pull request. Changesets will then publish a new GitHub release to the repository with the changelog and new version number. A second action will be triggered by this release and publish the new versions to npm and rubygems.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a link to this document in here somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice I didn't realize we had these docs 👍🏻

gem "rake"
gem "rubocop", "0.59"
gem "rubocop-github", "0.12.0"
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Not too familiar with how Gemfiles work. What does this do?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a bit like package.json, I needed to pull these dev dependencies up to the root so I could run bundle rake in each of the folders.

Copy link
Contributor

@colebemis colebemis left a comment

Choose a reason for hiding this comment

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

This is genius 🤯 Excellent work, @jonrohan! This will save us so much time.

@changeset-bot
Copy link

changeset-bot bot commented Oct 22, 2021

🦋 Changeset detected

Latest commit: c394d9a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/octicons Patch

Not sure what this means? Click here to learn what changesets are.

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

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.

2 participants