Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add release scripts for GitHub releases #83

Merged
merged 1 commit into from
Jan 29, 2024
Merged
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
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 @@ -130,6 +132,15 @@ function releaseOOT(
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 => {
return path.join(__dirname, '..', allPackages[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