mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
76a2cf3569
Summary: Changelog: [Internal] * Refactor release automation so it doesn't use intermediate tags to trigger the release workflow. Now, we POST to CircleCI's ["trigger pipeline" API](https://circleci.com/docs/api/v2/#operation/triggerPipeline) * This does have the con of needing to give CircleCI project permission for whoever wants to run a release as you'll need a token to trigger * See related discussion: https://github.com/reactwg/react-native-releases/discussions/7#discussioncomment-1836420 Description of changes: * Changes to config.yml allow us to use our POST data to trigger a certain workflow. There is no direct API to trigger a workflow, CircleCI only has an API to trigger pipelines, so the suggestion is to leverage conditionals: https://support.circleci.com/hc/en-us/articles/360050351292-How-to-trigger-a-workflow-via-CircleCI-API-v2 * Update `bump-oss-version` to make the api call -- the instructions for running a release are still the same: https://github.com/facebook/react-native/wiki/Release-Process#creating-0minor0-rc0 * Would be good to make this a yarn script as tido64 mentioned * Remove unused utilities now that we don't use intermediate tags like `publish-...` Pull Request resolved: https://github.com/facebook/react-native/pull/32937 Test Plan: Have this on a Github branch and tried this out locally: ## Running release script Running the bump-oss script (I had to hack it locally to be allowed to run on a non-release branch): {F694804729} * Link to resulting workflow: https://app.circleci.com/pipelines/github/facebook/react-native/11836 -- you can [verify that the parameters are the same as I passed](https://app.circleci.com/pipelines/github/facebook/react-native/11836/workflows/59ac0c86-5fe3-4d7a-80e9-c61129d49e9f/jobs/232388?invite=true#step-106-2) ## Other attempts triggering this workflow Notice that when I tried to run it on an actual release-branch (0.67-stable) but because the `config.yml` changes aren't on that branch, the job faisl | {F694804321} | ## Verifying the right workflows trigger on a regular push * Notice that the workflows "analysis" and "test" are still triggered on push (ie, the `unless:` clause isn't messing things up) {F694804320} Reviewed By: sota000 Differential Revision: D33715336 Pulled By: lunaleaps fbshipit-source-id: 82672d6d50768015bdfc9f4ea4d22aa801b84f06
55 lines
1.1 KiB
JavaScript
55 lines
1.1 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and 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 getBranchName() {
|
|
return exec('git rev-parse --abbrev-ref HEAD', {
|
|
silent: true,
|
|
}).stdout.trim();
|
|
}
|
|
|
|
function isTaggedLatest(commitSha) {
|
|
return (
|
|
exec(`git rev-list -1 latest | grep ${commitSha}`, {
|
|
silent: true,
|
|
}).stdout.trim() === commitSha
|
|
);
|
|
}
|
|
|
|
module.exports = {
|
|
getBranchName,
|
|
isTaggedLatest,
|
|
parseVersion,
|
|
isReleaseBranch,
|
|
};
|