Skip to content

Release tooling: Support canary releases#23508

Merged
JReinhold merged 20 commits intonextfrom
canary-release-workflow
Jul 24, 2023
Merged

Release tooling: Support canary releases#23508
JReinhold merged 20 commits intonextfrom
canary-release-workflow

Conversation

@JReinhold
Copy link
Contributor

@JReinhold JReinhold commented Jul 19, 2023

What I did

This PR adds support for canary releases.

  • Anyone with admin privileges can manually trigger a workflow run and specifying the PR number to create a release for.
  • contributors and maintainers are instructed to ask the core team if they would like a canary release of their PR
  • the workflow must always be triggered from the default branch next, and not the actual branch you want the release for. This is for security reasons.
  • If a canary release succeeds, the PR description will be updated with the release information (see at the bottom of this PR body)
  • If a release fails, a comment will be made tagging the triggering actor, see Core: Fix useStoryPrepared hook failing with undefined data #22631 (comment)
  • The canary will have the following version format: <CURRENT_VERSION>-canary-<PR_NUMBER>-<TIMESTAMP>-<COMMIT_SHA>.0, eg. 7.1.1-pr-23508-1689802571-5ec8c1c3.0. It's a bit verbose.
    • The current version has no meaning, it just softly indicates which version the PR is based on. eg. this PR is based on 7.1.0, so it will get released as a canary version of 7.1.1.
    • The timestamp ensures that any subsequent releases are always considered newer.
    • The commit hash is not strictly necessary, but it's a good way to indicate which exact code has been released.

How to test

You can test this out by reading the documentation in this PR, and then using this branch as a ref when running the workflow, instead of next. So in the UI you'd choose canary-release-workflow instead of next, and with the CLI it would be:

gh workflow run --repo storybookjs/storybook --ref canary-release-workflow canary-release-pr.yml --field pr=<PR_NUMBER>

To test the updating of the PR description you need to add the following to the bottom of your description before triggering the workflow:

### 🦋 Canary release

<!-- CANARY_RELEASE_SECTION -->
This pull request has been released as version [`7.1.1-canary-23508-1690059187-2dbf6e38.0`](https://npmjs.com/package/@storybook/cli/v/7.1.1-canary-23508-1690059187-2dbf6e38.0). Install it by pinning all your Storybook dependencies to that version.
<details>
<summary>More information</summary>

| | |
| --- | --- |
| **Published version** | [`7.1.1-canary-23508-1690059187-2dbf6e38.0`](https://npmjs.com/package/@storybook/cli/v/7.1.1-canary-23508-1690059187-2dbf6e38.0) |
| **Triggered by** | @JReinhold |
| **Repository** | [storybookjs/storybook](https://github.com/storybookjs/storybook) |
| **Branch** | [`canary-release-workflow`](https://github.com/storybookjs/storybook/tree/canary-release-workflow) |
| **Commit** | [`2dbf6e38`](https://github.com/storybookjs/storybook/commit/2dbf6e38cca59573408cf9d58d245a3125c980d7) |
| **Datetime** | Sat Jul 22 20:53:07 UTC 2023 (`1690059187`) |
| **Workflow run** | [5632680651](https://github.com/storybookjs/storybook/actions/runs/5632680651) |

To request a new release of this pull request, mention the `@storybookjs/core` team.

_core team members can create a new canary release [here](https://github.com/storybookjs/storybook/actions/workflows/canary-release-pr.yml) or locally with `gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=23508`_
</details>
<!-- CANARY_RELEASE_SECTION -->

@JReinhold JReinhold self-assigned this Jul 19, 2023
@JReinhold JReinhold added ci: do not merge patch:yes Bugfix & documentation PR that need to be picked to main branch build Internal-facing build tooling & test updates labels Jul 19, 2023
@JReinhold JReinhold temporarily deployed to release July 19, 2023 09:35 — with GitHub Actions Inactive
@JReinhold JReinhold marked this pull request as ready for review July 19, 2023 22:57
@JReinhold JReinhold requested review from a team July 20, 2023 07:26
@ndelangen
Copy link
Member

@JReinhold this seems a bit annoying to remember & have to do. Is this something you could append if not detected?
Screenshot 2023-07-21 at 10 31 19

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

@JReinhold Doesn't this mean that each package is going to have a million dist tags? Can we not do that please?

@JReinhold
Copy link
Contributor Author

JReinhold commented Jul 22, 2023

@JReinhold this seems a bit annoying to remember & have to do. Is this something you could append if not detected?

@ndelangen this is only something you have to manually add now because this PR isn't merged. This PR also changes the default PR template to include this section, so any future PRs will have this section per default. Any existing PRs will not, but I'm thinking that's okay? If you think it's common to create PRs that doesn't use the template, then I'm fine with adding in additional measures to handle it.

@JReinhold Doesn't this mean that each package is going to have a million dist tags? Can we not do that please?

@shilman actually it's not possible to publish a package without tag, it will default to latest of nothing is provided. We can publish all canaries to the same canary tag, but we'd have to be explicit to users about never using it, because it wouldn't make sense. I'm okay with it, this looks like this is what React and Auto does.

@JReinhold JReinhold temporarily deployed to release July 22, 2023 20:52 — with GitHub Actions Inactive
@shilman
Copy link
Member

shilman commented Jul 23, 2023

We can publish all canaries to the same canary tag, but we'd have to be explicit to users about never using it, because it wouldn't make sense. I'm okay with it, this looks like this is what React and Auto does.

Yes please!

@JReinhold
Copy link
Contributor Author

@shilman I've made the changes so all releases use the same canary tag.

We can remove the two dist tags I've created with this work manually: yarn npm tag remove @storybook/cli pr-23508, or maybe with something smarter:

yarn workspaces foreach --no-private --parallel exec "cat package.json | jq .name" | xargs -L1 yarn npm tag remove $@ pr-23508

I can do it or you can, I'll need the npm token though.

@JReinhold JReinhold requested a review from shilman July 24, 2023 08:44
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the dist tag!

run: yarn release:publish --tag canary --verbose

- name: Replace Pull Request Body
# TODO: replace with ivangabriele/find-and-replace-pull-request-body@vX when https://github.com/ivangabriele/find-and-replace-pull-request-body/pull/11 has been released
Copy link
Member

Choose a reason for hiding this comment

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

This has been released, can you replace and test it out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's been merged, but not released. :( I think they want to write some tests first, before releasing a new version. I'm keeping an eye on it.

Copy link
Contributor

@kylegach kylegach left a comment

Choose a reason for hiding this comment

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

Docs look good!

@JReinhold JReinhold merged commit eab73cf into next Jul 24, 2023
@JReinhold JReinhold deleted the canary-release-workflow branch July 24, 2023 21:19
@github-actions github-actions bot mentioned this pull request Aug 3, 2023
32 tasks
@kasperpeulen kasperpeulen removed the patch:yes Bugfix & documentation PR that need to be picked to main branch label Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Internal-facing build tooling & test updates ci:normal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants