2 Star 0 Fork 0

mirrors_jitsi/gh-action-autopublish

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
index.js 1.55 KB
一键复制 编辑 原始数据 按行查看 历史
Saúl Ibarra Corretgé 提交于 2022-09-26 19:42 . Log Node and npm versions
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"']);
await tools.exec('git', ['config', 'user.email', '"[email protected]"']);
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' });
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_jitsi/gh-action-autopublish.git
[email protected]:mirrors_jitsi/gh-action-autopublish.git
mirrors_jitsi
gh-action-autopublish
gh-action-autopublish
master

搜索帮助