Skip to content

Commit

Permalink
feat: Automate releases to GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
okwasniewski committed Jan 26, 2024
1 parent d8e4a0f commit 053d51f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 4 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@
"trigger-react-native-release": "node ./scripts/trigger-react-native-release.js",
"update-lock": "npx yarn-deduplicate"
},
"workspaces": [
"packages/*",
"tools/*"
],
"workspaces": ["packages/*", "tools/*"],
"peerDependencies": {
"react": "18.2.0"
},
Expand Down Expand Up @@ -106,6 +103,7 @@
"react-test-renderer": "18.2.0",
"rimraf": "^3.0.2",
"shelljs": "^0.8.5",
"release-it": "17.0.3",
"signedsource": "^1.0.0",
"supports-color": "^7.1.0",
"typescript": "5.0.4",
Expand Down
37 changes: 37 additions & 0 deletions scripts/new-github-release-url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function newGithubReleaseUrl(options = {}) {
let repoUrl;
if (options.repoUrl) {
repoUrl = options.repoUrl;
} else if (options.user && options.repo) {
repoUrl = `https://github.com/${options.user}/${options.repo}`;
} else {
throw new Error('You need to specify either the `repoUrl` option or both the `user` and `repo` options');
}

const url = new URL(`${repoUrl}/releases/new`);

const types = [
'tag',
'target',
'title',
'body',
'isPrerelease',
];

for (let type of types) {
const value = options[type];
if (value === undefined) {
continue;
}

if (type === 'isPrerelease') {
type = 'prerelease';
}

url.searchParams.set(type, value);
}

return url.toString();
}

module.exports = newGithubReleaseUrl;
24 changes: 24 additions & 0 deletions scripts/oot-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
const forEachPackage = require('./monorepo/for-each-package');
const {applyPackageVersions, publishPackage} = require('./npm-utils');
const updateTemplatePackage = require('./update-template-package');
const {failIfTagExists} = require('./release-utils');
const {execSync} = require('child_process');
const fs = require('fs');
const path = require('path');
const {cat, echo, exit} = require('shelljs');
const yargs = require('yargs');
const newGithubReleaseUrl = require('./new-github-release-url');

const REPO_ROOT = path.resolve(__dirname, '../');

Expand Down Expand Up @@ -129,6 +131,15 @@ function releaseOOT(
if (!oneTimePassword) {
return;
}

const gitTag = `v${newVersion}`;
failIfTagExists(tag, 'release');

// Create git tag
execSync(`git tag -a ${gitTag} -m "Release ${newVersion}"`, {
cwd: REPO_ROOT,
stdio: [process.stdin, process.stdout, process.stderr],
});

const results = visionOSPackages
.map(npmPackage => {
Expand All @@ -153,6 +164,19 @@ function releaseOOT(
', ',
)} to npm with version: ${newVersion}`,
);

const releaseURL = newGithubReleaseUrl({
tag: gitTag,
title: `Release ${newVersion}`,
repo: 'react-native-visionos',
user: 'callstack',
})

echo ('\n\n')
echo('-------------------------------------------\n')
echo(`Create a new release here: ${releaseURL}\n`);
echo('-------------------------------------------')

return exit(0);
}
}
Expand Down

0 comments on commit 053d51f

Please sign in to comment.