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

CircleCI: Don't tag hotfix releases with latest during publish job, allow prerelease tags #1086

Closed
wants to merge 2 commits into from

Conversation

robhogan
Copy link
Contributor

@robhogan robhogan commented Sep 20, 2023

Summary

Currently, when we npm publish --workspaces on tag creation, NPM implicitly tags with "latest". This is fine in the regular release flow, but when we release a hotfix (a patch release on an old minor, from a release branch) the tag is incorrect.

This causes issues that some folks notice within minutes: #931, #1057. Currently, it has to be manually corrected using dist-tag on each package after publishing.

This adds some logic in CircleCI to automatically tag with latest explicitly only if the tag is present on main, and not on any release branch (of the form 0.79.x). OTOH, if the release looks like a hotfix (present on a release branch but not on main) we tag with the release branch name. There is no way in NPM not to have any dist-tag, so specifying something is the only way to prevent it assuming latest.

If the release is ambiguous (edge case: we go back and tag a common ancestor of main and 0.123.x with v0.123.0-alpha, or the tag is on neither branch) the publish aborts.

We also update the filter regex to allow semver prerelease tags eg v0.80.0-alpha.0 - this would be handy for testing a built, published set of packages without actually releasing a new version.

Test plan

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 20, 2023
@robhogan robhogan changed the title CircleCI: Don't tag hotfix releases with latest during publish job CircleCI: Don't tag hotfix releases with latest during publish job, allow prerelease tags Sep 20, 2023
@facebook-github-bot
Copy link
Contributor

@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (main@7bedd65). Click here to learn what that means.
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1086   +/-   ##
=======================================
  Coverage        ?   83.38%           
=======================================
  Files           ?      209           
  Lines           ?    10839           
  Branches        ?     2726           
=======================================
  Hits            ?     9038           
  Misses          ?     1801           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@facebook-github-bot
Copy link
Contributor

@robhogan merged this pull request in d36056d.

robhogan added a commit that referenced this pull request Jan 29, 2024
… allow prerelease tags (#1086)

Summary:
Currently, when we `npm publish --workspaces` on tag creation, NPM implicitly tags with "latest". This is fine in the regular release flow, but when we release a hotfix (a patch release on an old minor, from a release branch) the tag is incorrect.

This causes issues that some folks notice within minutes: #931, #1057. Currently, it has to be manually corrected using `dist-tag` on each package after publishing.

This adds some logic in CircleCI to automatically tag with `latest` explicitly *only if* the tag is present on `main`, and not on any release branch (of the form `0.79.x`). OTOH, if the release looks like a hotfix (present on a release branch but *not* on `main`) we tag with the release branch name. There is no way in NPM not to have any dist-tag, so specifying *something* is the only way to prevent it assuming `latest`.

If the release is ambiguous (edge case: we go back and tag a common ancestor of `main` and `0.123.x` with `v0.123.0-alpha`) the publish aborts.

Pull Request resolved: #1086

Test Plan:
- Tested (after many iterations!) at my fork https://github.com/robhogan/metro, eg https://app.circleci.com/pipelines/github/robhogan/metro/74/workflows/5a375202-5863-43fd-b633-4a983b0ed4b8/jobs/264
 - I'm about to run a hotfix release to pull some bug fixes back for RN 0.72, so that'll be the first "live" test.

Reviewed By: huntie

Differential Revision: D49461403

Pulled By: robhogan

fbshipit-source-id: 26fd37d90ccae9d2125e9ef1cc8ba538ee6beb85
robhogan added a commit that referenced this pull request Jan 30, 2024
… allow prerelease tags (#1086)

Summary:
Currently, when we `npm publish --workspaces` on tag creation, NPM implicitly tags with "latest". This is fine in the regular release flow, but when we release a hotfix (a patch release on an old minor, from a release branch) the tag is incorrect.

This causes issues that some folks notice within minutes: #931, #1057. Currently, it has to be manually corrected using `dist-tag` on each package after publishing.

This adds some logic in CircleCI to automatically tag with `latest` explicitly *only if* the tag is present on `main`, and not on any release branch (of the form `0.79.x`). OTOH, if the release looks like a hotfix (present on a release branch but *not* on `main`) we tag with the release branch name. There is no way in NPM not to have any dist-tag, so specifying *something* is the only way to prevent it assuming `latest`.

If the release is ambiguous (edge case: we go back and tag a common ancestor of `main` and `0.123.x` with `v0.123.0-alpha`) the publish aborts.

Pull Request resolved: #1086

Test Plan:
- Tested (after many iterations!) at my fork https://github.com/robhogan/metro, eg https://app.circleci.com/pipelines/github/robhogan/metro/74/workflows/5a375202-5863-43fd-b633-4a983b0ed4b8/jobs/264
 - I'm about to run a hotfix release to pull some bug fixes back for RN 0.72, so that'll be the first "live" test.

Reviewed By: huntie

Differential Revision: D49461403

Pulled By: robhogan

fbshipit-source-id: 26fd37d90ccae9d2125e9ef1cc8ba538ee6beb85
robhogan added a commit that referenced this pull request Jan 30, 2024
… allow prerelease tags (#1086)

Summary:
Currently, when we `npm publish --workspaces` on tag creation, NPM implicitly tags with "latest". This is fine in the regular release flow, but when we release a hotfix (a patch release on an old minor, from a release branch) the tag is incorrect.

This causes issues that some folks notice within minutes: #931, #1057. Currently, it has to be manually corrected using `dist-tag` on each package after publishing.

This adds some logic in CircleCI to automatically tag with `latest` explicitly *only if* the tag is present on `main`, and not on any release branch (of the form `0.79.x`). OTOH, if the release looks like a hotfix (present on a release branch but *not* on `main`) we tag with the release branch name. There is no way in NPM not to have any dist-tag, so specifying *something* is the only way to prevent it assuming `latest`.

If the release is ambiguous (edge case: we go back and tag a common ancestor of `main` and `0.123.x` with `v0.123.0-alpha`) the publish aborts.

Pull Request resolved: #1086

Test Plan:
- Tested (after many iterations!) at my fork https://github.com/robhogan/metro, eg https://app.circleci.com/pipelines/github/robhogan/metro/74/workflows/5a375202-5863-43fd-b633-4a983b0ed4b8/jobs/264
 - I'm about to run a hotfix release to pull some bug fixes back for RN 0.72, so that'll be the first "live" test.

Reviewed By: huntie

Differential Revision: D49461403

Pulled By: robhogan

fbshipit-source-id: 26fd37d90ccae9d2125e9ef1cc8ba538ee6beb85
facebook-github-bot pushed a commit that referenced this pull request Feb 1, 2024
Summary:
Previously hotfix releases on old stable branches used to automatically publish with `latest`, which overwrote the tag for the actual latest release.

#1086 attempted to fix that, and *mostly* works, but npm does not allow dist tags that pass `semver.isValid()`, because that would conflict with semver specifiers in `package@[tagorsemver]`. Our stable branch naming convention `0.76.x` happens to be valid semver, and is rejected as a tag name.

This uses `0.76-stable` instead via shell substitution, [consistent with `react-native`](https://www.npmjs.com/package/react-native?activeTab=versions). I've just used it to semi-manually successfully publish 0.76.9.

Pull Request resolved: #1202

Test Plan:
- SSH into publish job in CircleCI
- Patch .circleci/scripts/publish.sh and run
- Published 0.76.9 with tag `0.76-stable`

Reviewed By: huntie

Differential Revision: D53232940

Pulled By: robhogan

fbshipit-source-id: f00e32285358d8418acb26b549e8e544304b0528
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants