mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
fcf3fd84ec
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/32757 Changelog: [Internal] - Update release automation to still be manually triggered as from discussion: https://github.com/reactwg/react-native-releases/discussions/7 A releaser needs to do the following on a release branch like `0.99-stable`: * For an initial release branch cut: * Tag the head of the branch `git tag publish-v0.99.0-rc.0` * `git push origin 0.99-stable --follow-tags` * For cherry-picks on the pre-release: * Make the picks on `0.99-stable` * Tag the head of the branch `git tag publish-v0.99.0-rc.1` * `git push origin 0.99-stable --follow-tags` * For promoting pre-release to stable with intention of making this the `latest` npm version: * Tag the head of the branch `git tag publish-v0.99.0` * Tag the head of the branch `git tag latest` * `git push origin 0.99-stable --follow-tags` Follow-up diff to make this codified via a script Reviewed By: sota000 Differential Revision: D33101594 fbshipit-source-id: 74b065229a3705fccbe1a25ed7ece4a28d9aa76d
67 lines
1.4 KiB
JavaScript
67 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
const {exec} = require('shelljs');
|
|
|
|
const VERSION_REGEX = /^v?((\d+)\.(\d+)\.(\d+)(?:-(.+))?)$/;
|
|
|
|
function parseVersion(versionStr) {
|
|
const match = versionStr.match(VERSION_REGEX);
|
|
if (!match) {
|
|
throw new Error(
|
|
`You must pass a correctly formatted version; couldn't parse ${versionStr}`,
|
|
);
|
|
}
|
|
const [, version, major, minor, patch, prerelease] = match;
|
|
return {
|
|
version,
|
|
major,
|
|
minor,
|
|
patch,
|
|
prerelease,
|
|
};
|
|
}
|
|
|
|
function isReleaseBranch(branch) {
|
|
return branch.endsWith('-stable');
|
|
}
|
|
|
|
function getPublishVersion(tag) {
|
|
if (!tag.startsWith('publish-')) {
|
|
return null;
|
|
}
|
|
|
|
const versionStr = tag.replace('publish-', '');
|
|
return parseVersion(versionStr);
|
|
}
|
|
|
|
function isTaggedLatest(commitSha) {
|
|
return (
|
|
exec(`git rev-list -1 latest | grep ${commitSha}`, {
|
|
silent: true,
|
|
}).stdout.trim() === commitSha
|
|
);
|
|
}
|
|
|
|
function getPublishTag() {
|
|
// Assumes we only ever have one tag with the prefix `publish-v`
|
|
const tag = exec("git tag --points-at HEAD | grep 'publish-v'", {
|
|
silent: true,
|
|
}).stdout.trim();
|
|
return tag ? tag : null;
|
|
}
|
|
|
|
module.exports = {
|
|
isTaggedLatest,
|
|
getPublishTag,
|
|
getPublishVersion,
|
|
parseVersion,
|
|
isReleaseBranch,
|
|
};
|