代码拉取完成,页面将自动刷新
const { Toolkit } = require('actions-toolkit');
const fs = require('fs');
const path = require('path');
Toolkit.run(async tools => {
function getVersion() {
const data = fs.readFileSync(path.join(tools.workspace, 'package.json'));
return JSON.parse(data.toString()).version;
}
const npmrc = path.resolve(process.env['HOME'], '.npmrc');
fs.writeFileSync(npmrc, `//registry.npmjs.org/:_authToken=${process.env.NPM_AUTH_TOKEN}`, { flag: 'w+' });
await tools.exec('npm config set unsafe-perm true')
await tools.exec('git', ['config', 'user.name', '"Automated Release"']);
const currentVersion = getVersion();
let tagExists;
try {
await tools.exec(`git ls-remote --exit-code --tags origin v${currentVersion}`);
tagExists = true;
} catch (e) {
tagExists = false;
}
if (tagExists) {
tools.log.info('Current version has a tag, bumping the patch');
await tools.exec('npm version patch');
} else {
tools.log.info(`Current version does not have a tag, creating it`);
await tools.exec(`git tag v${currentVersion}`);
}
await tools.exec('git push origin master');
await tools.exec(`git push origin v${getVersion()}`);
await tools.exec('node --version');
await tools.exec('npm --version');
await tools.exec('npm install');
await tools.exec('npm publish --access public');
tools.exit.success('Done!!')
}, { event: 'push' });
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。