Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/configurations/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1315,4 +1315,4 @@ jobs:
command: echo "//registry.npmjs.org/:_authToken=${CIRCLE_NPM_TOKEN}" > ~/.npmrc
- run:
name: Find and publish all bumped packages
command: node ./scripts/monorepo/find-and-publish-all-bumped-packages.js
command: node ./scripts/releases-ci/publish-updated-packages.js
8 changes: 6 additions & 2 deletions scripts/releases-ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ CI-only release scripts — intended to run from a CI workflow (CircleCI or GitH

For information on command arguments, run `node <command> --help`.

### `prepare-package-for-release.js`
### `prepare-package-for-release`

Prepares files within the `react-native` package and template for the target release version. Writes a new commit and tag, which will trigger `publish-npm.js` in a new workflow.

### `publish-npm.js`
### `publish-npm`

Prepares release artifacts and publishes the `react-native` package to npm.

### `publish-updated-packages`

Publishes all updated packages (excluding `react-native`) to npm. Triggered when a commit on a release branch contains `#publish-packages-to-npm`.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*/

const {
findAndPublishAllBumpedPackages,
getTagsFromCommitMessage,
} = require('../find-and-publish-all-bumped-packages');
publishUpdatedPackages,
} = require('../publish-updated-packages');

const getPackagesMock = jest.fn();
const execSync = jest.fn();
Expand All @@ -30,7 +30,7 @@ global.fetch = fetchMock;
const BUMP_COMMIT_MESSAGE =
'bumped packages versions\n\n#publish-packages-to-npm';

describe('findAndPublishAllBumpedPackages', () => {
describe('publishUpdatedPackages', () => {
beforeEach(() => {
jest.spyOn(console, 'log').mockImplementation(() => {});
jest.resetAllMocks();
Expand All @@ -47,7 +47,7 @@ describe('findAndPublishAllBumpedPackages', () => {
.spyOn(console, 'error')
.mockImplementation(() => {});

await findAndPublishAllBumpedPackages();
await publishUpdatedPackages();

expect(consoleError.mock.calls).toMatchInlineSnapshot(`
Array [
Expand All @@ -67,7 +67,7 @@ describe('findAndPublishAllBumpedPackages', () => {
});
const consoleLog = jest.spyOn(console, 'log').mockImplementation(() => {});

await findAndPublishAllBumpedPackages();
await publishUpdatedPackages();

expect(consoleLog.mock.calls).toMatchInlineSnapshot(`
Array [
Expand Down Expand Up @@ -99,7 +99,7 @@ describe('findAndPublishAllBumpedPackages', () => {
json: () => Promise.resolve({versions: {}}),
});

await expect(findAndPublishAllBumpedPackages()).rejects.toThrow(
await expect(publishUpdatedPackages()).rejects.toThrow(
`Package version expected to be 0.x.x, but received ${mockedPackageNewVersion}`,
);
});
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('findAndPublishAllBumpedPackages', () => {

const consoleLog = jest.spyOn(console, 'log').mockImplementation(() => {});

await findAndPublishAllBumpedPackages();
await publishUpdatedPackages();

expect(consoleLog.mock.calls.flat().join('\n')).toMatchInlineSnapshot(`
"Discovering updated packages
Expand Down Expand Up @@ -217,7 +217,7 @@ describe('findAndPublishAllBumpedPackages', () => {
.spyOn(console, 'error')
.mockImplementation(() => {});

await findAndPublishAllBumpedPackages();
await publishUpdatedPackages();

expect(consoleError.mock.calls.flat().join('\n')).toMatchInlineSnapshot(`
"Failed to publish @react-native/package-b. npm publish exited with code 1:
Expand Down Expand Up @@ -258,7 +258,7 @@ describe('findAndPublishAllBumpedPackages', () => {
.spyOn(console, 'log')
.mockImplementation(() => {});

await findAndPublishAllBumpedPackages();
await publishUpdatedPackages();

expect(consoleLog).toHaveBeenLastCalledWith('--- Retrying once! ---');
expect(process.exitCode).toBe(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,39 @@
* @oncall react_native
*/

const {PUBLISH_PACKAGES_TAG} = require('../monorepo/constants');
const {publishPackage} = require('../npm-utils');
const {getPackages} = require('../releases/utils/monorepo');
const {PUBLISH_PACKAGES_TAG} = require('./constants');
const {parseArgs} = require('@pkgjs/parseargs');
const {execSync} = require('child_process');

const NPM_CONFIG_OTP = process.env.NPM_CONFIG_OTP;

async function findAndPublishAllBumpedPackages() {
const config = {
options: {
help: {type: 'boolean'},
},
};

async function main() {
const {
values: {help},
} = parseArgs(config);

if (help) {
console.log(`
Usage: node ./scripts/releases/publish-updated-packages.js

Publishes all updated packages (excluding react-native) to npm. This script
is intended to run from a CI workflow.
`);
return;
}

await publishUpdatedPackages();
}

async function publishUpdatedPackages() {
let commitMessage;

try {
Expand Down Expand Up @@ -130,10 +155,10 @@ function runPublish(

if (require.main === module) {
// eslint-disable-next-line no-void
void findAndPublishAllBumpedPackages();
void main();
}

module.exports = {
findAndPublishAllBumpedPackages,
getTagsFromCommitMessage,
publishUpdatedPackages,
};