2022-02-24 18:28:00 +01:00
|
|
|
import semver from 'semver';
|
|
|
|
import path from 'path';
|
|
|
|
import fs from 'fs';
|
|
|
|
|
|
|
|
const PACKAGE_BASE = '';
|
|
|
|
|
|
|
|
function publishPackage(name) {
|
|
|
|
console.info('Publishing %s', name);
|
|
|
|
|
2022-03-10 01:32:29 +01:00
|
|
|
const newVersion = semver.valid(semver.coerce(process.env.TAG_NAME));
|
2022-02-24 18:28:00 +01:00
|
|
|
console.info('New version is %s', newVersion);
|
2022-03-10 01:32:29 +01:00
|
|
|
if (!newVersion) {
|
|
|
|
throw new Error(`Tag name ${process.env.TAG_NAME} is not valid.`);
|
|
|
|
}
|
2022-02-24 18:28:00 +01:00
|
|
|
|
2022-04-23 19:15:51 +02:00
|
|
|
const packageJsonPath =
|
|
|
|
name === 'iconoir'
|
|
|
|
? 'package.json'
|
|
|
|
: path.join('packages', name, 'package.json');
|
2022-02-24 18:28:00 +01:00
|
|
|
const contents = JSON.parse(fs.readFileSync(packageJsonPath).toString());
|
|
|
|
contents.version = newVersion;
|
|
|
|
if (PACKAGE_BASE) {
|
|
|
|
contents.name = `${PACKAGE_BASE}/${name}`;
|
|
|
|
}
|
|
|
|
fs.writeFileSync(packageJsonPath, JSON.stringify(contents, undefined, 2));
|
|
|
|
console.info('package.json updated');
|
|
|
|
}
|
|
|
|
|
2022-04-23 19:15:51 +02:00
|
|
|
publishPackage('iconoir');
|
2022-02-24 18:28:00 +01:00
|
|
|
publishPackage('iconoir-react');
|
|
|
|
publishPackage('iconoir-react-native');
|