CircleCI: Don't tag hotfix releases with latest during publish job, allow prerelease tags#1086
Closed
CircleCI: Don't tag hotfix releases with latest during publish job, allow prerelease tags#1086
latest during publish job, allow prerelease tags#1086Conversation
latest during publish joblatest during publish job, allow prerelease tags
Contributor
|
@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Codecov Report
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. |
Contributor
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
This was referenced Jan 30, 2024
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Currently, when we
npm publish --workspaceson 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-tagon each package after publishing.This adds some logic in CircleCI to automatically tag with
latestexplicitly only if the tag is present onmain, and not on any release branch (of the form0.79.x). OTOH, if the release looks like a hotfix (present on a release branch but not onmain) 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 assuminglatest.If the release is ambiguous (edge case: we go back and tag a common ancestor of
mainand0.123.xwithv0.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