Skip to content

Commit ffcf36d

Browse files
committed
feat: Automate releases to GitHub
1 parent d8e4a0f commit ffcf36d

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

scripts/new-github-release-url.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
function newGithubReleaseUrl(options = {}) {
2+
let repoUrl;
3+
if (options.repoUrl) {
4+
repoUrl = options.repoUrl;
5+
} else if (options.user && options.repo) {
6+
repoUrl = `https://github.com/${options.user}/${options.repo}`;
7+
} else {
8+
throw new Error('You need to specify either the `repoUrl` option or both the `user` and `repo` options');
9+
}
10+
11+
const url = new URL(`${repoUrl}/releases/new`);
12+
13+
const types = [
14+
'tag',
15+
'target',
16+
'title',
17+
'body',
18+
'isPrerelease',
19+
];
20+
21+
for (let type of types) {
22+
const value = options[type];
23+
if (value === undefined) {
24+
continue;
25+
}
26+
27+
if (type === 'isPrerelease') {
28+
type = 'prerelease';
29+
}
30+
31+
url.searchParams.set(type, value);
32+
}
33+
34+
return url.toString();
35+
}
36+
37+
module.exports = newGithubReleaseUrl;

scripts/oot-release.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
const forEachPackage = require('./monorepo/for-each-package');
1010
const {applyPackageVersions, publishPackage} = require('./npm-utils');
1111
const updateTemplatePackage = require('./update-template-package');
12+
const {failIfTagExists} = require('./release-utils');
1213
const {execSync} = require('child_process');
1314
const fs = require('fs');
1415
const path = require('path');
1516
const {cat, echo, exit} = require('shelljs');
1617
const yargs = require('yargs');
18+
const newGithubReleaseUrl = require('./new-github-release-url');
1719

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

@@ -130,6 +132,15 @@ function releaseOOT(
130132
return;
131133
}
132134

135+
const gitTag = `v${newVersion}`;
136+
failIfTagExists(tag, 'release');
137+
138+
// Create git tag
139+
execSync(`git tag -a ${gitTag} -m "Release ${newVersion}"`, {
140+
cwd: REPO_ROOT,
141+
stdio: [process.stdin, process.stdout, process.stderr],
142+
});
143+
133144
const results = visionOSPackages
134145
.map(npmPackage => {
135146
return path.join(__dirname, '..', allPackages[npmPackage]);
@@ -153,6 +164,19 @@ function releaseOOT(
153164
', ',
154165
)} to npm with version: ${newVersion}`,
155166
);
167+
168+
const releaseURL = newGithubReleaseUrl({
169+
tag: gitTag,
170+
title: `Release ${newVersion}`,
171+
repo: 'react-native-visionos',
172+
user: 'callstack',
173+
});
174+
175+
echo('\n\n');
176+
echo('-------------------------------------------\n');
177+
echo(`Create a new release here: ${releaseURL}\n`);
178+
echo('-------------------------------------------');
179+
156180
return exit(0);
157181
}
158182
}

0 commit comments

Comments
 (0)