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

build: semantic release #746

Merged
merged 55 commits into from
Feb 15, 2023
Merged

build: semantic release #746

merged 55 commits into from
Feb 15, 2023

Conversation

kanadgupta
Copy link
Member

@kanadgupta kanadgupta commented Feb 10, 2023

🧰 Changes

This PR brings semantic-release into the mix so we can have a proper pre-release tagging/release process for some of the upcoming Docker build stuff we're doing.

Here's an overview of the changes:

  • Changes our default branch in this repository from main to next (already done)
  • Set up husky commit linting to make sure all commits conform to angular commit conventions
  • Sets up a prelease process tied to the next branch and a proper release process tied to the next branch
  • Set up a semantic-release plugin setup that publishes releases to GitHub and npm (see MAINTAINERS.md in this PR for more information)
Outstanding Tasks
  • Make sure major version tagging script in bin/set-major-version-tag.js tags the right commit
  • See if we can get rid of the duplicative tag thing (i.e. v8.0 vs 8.0) (update: removed it for now, I think it should be fine? got it working again)
  • See if GitHub release text can be easily formatted (update: got something better going but it's not super pretty gonna create draft releases with gh instead)
  • (Maybe further down the line) see if we can add a semantic-release plugin for publishing to GitHub's container registry (edit: this should actually work)
  • Make sure release flow has permissions to commit to protected branch (edit I think this is working, but we won't know until it's in next 😬)
  • See if I need to generate a GitHub token with more permissions in order to trigger a released event (further reading) (edit: don't think I actually need this)
  • Update MAINTAINERS.md with the new guidance
  • Make sure I revert all the temporary configuration specific to the semantic-release branch
  • Figure out how the whole process of merging main back into next will work (we won't know until all of this is live 😬)

🧬 QA & Testing

I ran a bunch of test workflows against this branch. Here are a few artifacts for 8.6.0-next.8 to confirm this is working as expected1:

The main files that actually necessitate your review are .releaserc.yml and MAINTAINERS.md 🥺

Footnotes

  1. (and let me know if I missed anything! lots of moving parts 😮‍💨)

kanadgupta and others added 30 commits February 10, 2023 13:43
apparently semantic-release likes this better I don't know
technically a chore but making it a feat to see what semantic-release does with it
# [8.6.0-next.2](v8.6.0-next.1...v8.6.0-next.2) (2023-02-10)

### Features

* add git + changelog plugins ([85e4bfd](85e4bfd))

[skip ci]
## What's Changed in 8.6.0-next.3

### Bug Fixes

* rebuild prior to npm publish ([29b9ec6](29b9ec6))
* reformat github release header ([38c5625](38c5625))

[skip ci]
## What's Changed

### Bug Fixes

* reformat header again ([bd2e1a2](bd2e1a2))

### Features

* drop duplicative tag ([4c34207](4c34207))

[skip ci]
hopefully this will put the extra tag on the correct commit?
## What's Changed

### Bug Fixes

* try rearranging steps like this ([cac0c1d](cac0c1d))

### Reverts

* Revert "feat: drop duplicative tag" ([f9fe6c6](f9fe6c6))

[skip ci]
.releaserc.yml Outdated
# in the `postversion` npm hook
- '@semantic-release/npm'
# Lightweight alternative to `@semantic-release/github` that creates a draft release
- ['@semantic-release/exec', { 'publishCmd': 'gh release create ${nextRelease.version} --draft --generate-notes' }]
Copy link
Member Author

@kanadgupta kanadgupta Feb 13, 2023

Choose a reason for hiding this comment

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

TIL that the GitHub CLI is pre-installed on GitHub Actions runners: https://docs.github.com/en/actions/using-workflows/using-github-cli-in-workflows

@@ -29,7 +29,7 @@
],
"repository": {
"type": "git",
"url": "git://github.com/readmeio/rdme.git"
"url": "https://github.com/readmeio/rdme.git"
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 guess semantic-release actually uses this field and likes this better 🤷🏽‍♂️

@@ -1,3 +1,66 @@
# [8.6.0-next.7](https://github.com/readmeio/rdme/compare/v8.6.0-next.6...v8.6.0-next.7) (2023-02-13)
Copy link
Member Author

Choose a reason for hiding this comment

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

there are a few formatting discrepancies in this file now but I really care to be honest

# since we're also updating the action.yml file with every release!
# Uncomment this line below once those changes are live:
# assets: ['action.yml', 'CHANGELOG.md', 'package.json', 'package-lock.json'],
message: "build(release): 🚀 v${nextRelease.version} 🦉\n\n${nextRelease.notes}\n[skip ci]",
Copy link
Member Author

Choose a reason for hiding this comment

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

@kanadgupta kanadgupta marked this pull request as ready for review February 13, 2023 23:37
@kanadgupta kanadgupta added enhancement New feature or request refactor Issues about tackling technical debt labels Feb 13, 2023
Copy link
Member

@erunion erunion left a comment

Choose a reason for hiding this comment

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

nice

@RyanGWU82
Copy link
Contributor

RyanGWU82 commented Feb 13, 2023

A couple of general questions:

  1. What's the value of having a prerelease process on the next branch?
  2. Have we confirmed that the code pushes from semantic-release don't themselves trigger new runs of semantic-release? (Let's make sure this won't cause an infinite loop 😭) (oops, forgot about [skip ci])
  3. Have you confirmed this actually works as a GitHub Action? We weren't able to get that working on readme because GitHub doesn't allow code pushes from inside GitHub Actions, even if the GITHUB_TOKEN would otherwise have access privileges to do this. If it does work, do you know how/why it works since it didn't on readme? (Could we apply the same "fix" to readme? 🤔)

Copy link
Contributor

@RyanGWU82 RyanGWU82 left a comment

Choose a reason for hiding this comment

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

Great documentation! 🙇🏼

@kanadgupta
Copy link
Member Author

  1. What's the value of having a prerelease process on the next branch?

A couple of reasons!

  1. We can actually do a global install (i.e., npm i -g rdme) locally and play around with prerelease version in a variety of different directories to confirm that changes work as expected (this is something I've wanted for a while)
  2. Since we're going to publish every Docker build to the GitHub container registry (inspired by this repo), we need an end-to-end technique to test out the GitHub Action before tagging official releases... in other words, we need to use a tagged Docker container release to properly test GitHub Actions 😬 not ideal but the pros should hopefully outweigh the cons 🤞🏽
  1. Have you confirmed this actually works as a GitHub Action? We weren't able to get that working on readme because GitHub doesn't allow code pushes from inside GitHub Actions, even if the GITHUB_TOKEN would otherwise have access privileges to do this. If it does work, do you know how/why it works since it didn't on readme? (Could we apply the same "fix" to readme? 🤔)

Yeah I remember those issues... will report back once this workflow actually runs in next and main, but I've tried basically everything I can think of on this branch (protecting this branch, actually tagging releases, etc.) and the GITHUB_TOKEN appears to be working fine? Maybe GitHub has since made some fixes to their Actions permissioning so we can finally do this now 🧐

@RyanGWU82

@RyanGWU82
Copy link
Contributor

Thanks @kanadgupta. The issue with GHA permissions was that you couldn't use GHA to actually make commits on a git branch. You could interact with the API as much as you wanted (for tagging, replying to issues, etc) but you couldn't actually save the commit to update the version number or the changelog. Were you able to test it on a branch and have it actually make a commit on that branch?

It's been over a year since I looked at that, so maybe they got it working in a newer version of semantic-release?

@kanadgupta
Copy link
Member Author

kanadgupta commented Feb 14, 2023

@RyanGWU82 yeah there are a few examples on this branch if you want to look, like this one: 05af285

I also tried adding protections to this branch and it still appeared to work 🧐

@kanadgupta kanadgupta mentioned this pull request Feb 15, 2023
@kanadgupta kanadgupta merged commit 621b966 into next Feb 15, 2023
@kanadgupta kanadgupta deleted the semantic-release branch February 15, 2023 15:28
@kanadgupta kanadgupta restored the semantic-release branch February 15, 2023 17:03
kanadgupta added a commit that referenced this pull request Feb 15, 2023
* chore: initial commit

* chore: how about this?

* chore: what about this

* fix: try this instead

* chore: see if warnings are surfaced properly

* Revert "chore: see if warnings are surfaced properly"

This reverts commit edaf715.

* revert: restore simple.yml

* chore: update dockerfile path

* build: semantic release (#746)

* chore: shorten docker path

* perf: try using alpine
github-actions bot pushed a commit that referenced this pull request Feb 15, 2023
# [8.6.0-next.10](v8.6.0-next.9...v8.6.0-next.10) (2023-02-15)

### Features

* docker (again) ([#763](#763)) ([2144572](2144572)), closes [#746](#746)

[skip ci]
@kanadgupta kanadgupta deleted the semantic-release branch February 15, 2023 18:15
kanadgupta pushed a commit that referenced this pull request Mar 29, 2023
# [8.6.0](v8.5.0...v8.6.0) (2023-03-29)

### Bug Fixes

* bad merge ([e15c574](e15c574))
* bump node version in release workflow ([7f3158f](7f3158f))
* does this work? ([c81e432](c81e432))
* memory leak in large file handling within openapi-parser ([#784](#784)) ([1b1cc00](1b1cc00))
* next channel ([ce4e494](ce4e494))
* **openapi:** yaml strings would be improperly parsed as Date objects ([#779](#779)) ([72e75cb](72e75cb))
* rebuild prior to npm publish ([29b9ec6](29b9ec6))
* reformat github release header ([38c5625](38c5625))
* reformat header again ([bd2e1a2](bd2e1a2))
* remove some of the package scripts ([3eb52fd](3eb52fd))
* remove unnecessary config ([c22889c](c22889c))
* run tests but NOT release workflow on release commits ([24f885e](24f885e))
* temporarily disable release workflow ([a935268](a935268))
* try rearranging steps like this ([cac0c1d](cac0c1d))
* try this approach to lifecycle events ([4e5ecff](4e5ecff))
* try this as an alternative to @semantic-release/github ([8c343a0](8c343a0))
* try this to see if branch protections work ([f314c3f](f314c3f))
* turns out these rules weren't redundant ([f9f82f1](f9f82f1))
* upgrading `oas-normalize` to move to our `postman-to-openapi` fork ([#776](#776)) ([ee8ce0a](ee8ce0a))

### Features

* add git + changelog plugins ([85e4bfd](85e4bfd))
* container registry ([#777](#777)) ([d193416](d193416)), closes [/github.com//pull/777#discussion_r1145516673](https://github.com//github.com/readmeio/rdme/pull/777/issues/discussion_r1145516673) [/github.com//pull/777#discussion_r1145528308](https://github.com//github.com/readmeio/rdme/pull/777/issues/discussion_r1145528308)
* docker (again) ([#763](#763)) ([2144572](2144572)), closes [#746](#746)
* empty commit to trigger release ([3e3c112](3e3c112))
* fix comment ([076cfbf](076cfbf))

### Performance Improvements

* **docker:** build executable ([#764](#764)) ([af2dbce](af2dbce))

### Reverts

* Revert "feat: drop duplicative tag" ([f9fe6c6](f9fe6c6))
* bring workflow name back ([c07495a](c07495a))
* don't set header for changelog ([194489e](194489e))
* restore release workflow ([9f6bbc9](9f6bbc9))
* ugh here we go again ([0b1e429](0b1e429))

[skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor Issues about tackling technical debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants