Files
react-native/scripts/bump-hermes-version.js
T
Nicola Corti 4ea593b756 Fix release infrastructure failures discovered during .69 release
Summary:
During the release of .69, we (fortmarek and me) discovered a couple of bits that needed
some intervention.
- `sdks/.hermesversion` was gitignored, so we could not commit that.
- `scripts/bump-hermes-version.js` was not executable, so we had to chmod +x to
  make it runnable.

Here I'm fixing it.

Changelog:
[Internal] [Changed] - Fix release infrastructure failures discovered during .69 release

Reviewed By: cipolleschi

Differential Revision: D36003808

fbshipit-source-id: c4d82ed5e2c63988699035ac84b0e87ed8894540
2022-04-28 07:48:40 -07:00

78 lines
1.7 KiB
JavaScript
Executable File

#!/usr/bin/env node
/**
* 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
*/
'use strict';
/**
* This script walks a releaser through bumping the Hermes version for a release.
* It needs be executed on a release branch.
*/
const {exit} = require('shelljs');
const yargs = require('yargs');
const inquirer = require('inquirer');
const fs = require('fs');
const path = require('path');
const HERMES_TAG_FILE_DIR = 'sdks';
const HERMES_TAG_FILE_PATH = `${HERMES_TAG_FILE_DIR}/.hermesversion`;
let argv = yargs.option('t', {
alias: 'tag',
describe:
'Hermes release tag to use for this React Native release, ex. hermes-2022-02-21-RNv0.68.0',
required: true,
}).argv;
function readHermesTag() {
if (fs.existsSync(path)) {
const data = fs.readFileSync(HERMES_TAG_FILE_PATH, {
encoding: 'utf8',
flag: 'r',
});
return data.trim();
} else {
return '';
}
}
function setHermesTag(hermesTag) {
if (readHermesTag() === hermesTag) {
// No need to update.
return;
}
if (!fs.existsSync(HERMES_TAG_FILE_DIR)) {
fs.mkdirSync(HERMES_TAG_FILE_DIR, {recursive: true});
}
fs.writeFileSync(HERMES_TAG_FILE_PATH, hermesTag.trim());
console.log('Hermes tag has been updated. Please commit your changes.');
}
async function main() {
const hermesTag = argv.tag;
const {confirmHermesTag} = await inquirer.prompt({
type: 'confirm',
name: 'confirmHermesTag',
message: `Do you want to use the Hermes release tagged "${hermesTag}"?`,
});
if (!confirmHermesTag) {
console.log('Aborting.');
return;
}
setHermesTag(hermesTag);
}
main().then(() => {
exit(0);
});