Match-id-09c2a7aff8300c687f95a5db9e618599ba5bc4bd

This commit is contained in:
* 2022-08-02 11:30:29 +08:00 committed by *
commit f4e0636541
4 changed files with 97 additions and 8 deletions

View File

@ -1,2 +0,0 @@
yarn
yarn run test

View File

@ -19,7 +19,8 @@ env:
- type: workspace
steps:
PRE_BUILD:
- checkout
- checkout:
path: horizon-core
- gitlab:
url: https://szv-y.codehub.huawei.com/CloudSOP/CloudSOP-CI.git
branch: $branch
@ -29,5 +30,8 @@ steps:
command: |
npm install yarn -g
yarn config set strict-ssl false
cd horizon-core
yarn
yarn run test
yarn run build
node .cloudbuild/release.js

80
.cloudbuild/release.js Normal file
View File

@ -0,0 +1,80 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
*/
const fs = require('fs');
const path = require('path');
const childProcess = require('child_process');
const version = process.env.releaseVersion;
const HORIZON_PACKAGE_JSON = path.resolve(__dirname, '../libs/horizon/package.json');
const DIST_PATH = path.resolve(__dirname, '../build/horizon');
const NPMRC = `registry=https://cmc.centralrepo.rnd.huawei.com/npm
@cloudsop:registry=https://cmc.centralrepo.rnd.huawei.com/artifactory/product_npm
_auth = Y2xvdWRzb3BhcnRpZmFjdG9yeTpDbG91ZHNvcDY2NiEhIQ
always-auth = true
email = cloudsop@huawei.com
`;
if (!version) {
return;
}
if (!/\d+\.\d+\.\d+/.test(version)) {
console.log('请输入正确版本号');
return;
}
const exec = (cmd, cwd) => {
return new Promise((resolve, reject) => {
childProcess.exec(
cmd,
{
cwd,
},
function (error, stdout, stderr) {
if (error) {
error && console.log(`Error: ${error}`);
reject(error);
} else {
stdout && console.log(`STDOUT: ${stdout}`);
resolve(stdout);
}
}
);
});
};
const writeVersion = version => {
return new Promise((resolve, reject) => {
const file = HORIZON_PACKAGE_JSON;
fs.readFile(file, 'utf8', function (err, data) {
if (err) {
console.log(`${file}: write version failed`);
reject(err);
}
const packageJson = JSON.parse(data);
packageJson.version = version;
fs.writeFileSync(file, JSON.stringify(packageJson, null, 2));
resolve();
});
});
};
const main = async () => {
console.log(`==== Horizon Upgrade ${version} ====`);
await writeVersion(version);
if (!version.includes('SNAPSHOT')) {
console.log('==== Create git tag =====');
const tagName = `v${version}-h1`;
await exec(`git tag ${tagName}`);
await exec('git push --tags');
}
fs.writeFileSync(path.resolve(DIST_PATH, '.npmrc'), NPMRC);
console.log('==== Publish new version====');
await exec('npm publish', DIST_PATH);
};
main();

View File

@ -19,12 +19,19 @@ env:
- type: workspace
steps:
PRE_BUILD:
- checkout
- checkout:
path: horizon-core
- gitlab:
url: https://szv-y.codehub.huawei.com/CloudSOP/CloudSOP-CI.git
branch: $branch
path: CI
url: https://szv-open.codehub.huawei.com/innersource/shanhai/wutong/react/horizon-test.git
branch: one_tree_dev
path: horizon-test
BUILD:
- build_execute:
command: |
git tag $releaseVersion
npm install yarn -g
yarn config set strict-ssl false
cd horizon-core
yarn
cd ../horizon-test
yarn
yarn run test