improvement: Review snapshot behavior (#95)

* Improve git tag detection (#77)
* Only handle snapshot flag for release cmd (#94)
* Use core.info instead of console.log
* Update gitattributes
This commit is contained in:
CrazyMax
2020-02-11 13:52:06 +01:00
committed by GitHub
parent 81d25e3b66
commit e198786300
8 changed files with 123 additions and 30 deletions
Generated
+16 -10
View File
@@ -16,6 +16,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const git = __importStar(require("./git"));
const installer = __importStar(require("./installer"));
const core = __importStar(require("@actions/core"));
const exec = __importStar(require("@actions/exec"));
@@ -28,29 +29,34 @@ function run(silent) {
const key = core.getInput('key');
const workdir = core.getInput('workdir') || '.';
const goreleaser = yield installer.getGoReleaser(version);
const commit = yield git.getShortCommit();
const tag = yield git.getTag();
const isTagDirty = yield git.isTagDirty(tag);
if (workdir && workdir !== '.') {
console.log(`📂 Using ${workdir} as working directory...`);
core.info(`📂 Using ${workdir} as working directory...`);
process.chdir(workdir);
}
let snapshot = '';
if (!process.env.GITHUB_REF || !process.env.GITHUB_REF.startsWith('refs/tags/')) {
console.log(`⚠️ No tag found. Snapshot forced`);
if (!args.includes('--snapshot')) {
snapshot = ' --snapshot';
if (args.split(' ').indexOf('release') > -1) {
if (isTagDirty) {
core.info(`⚠️ No tag found for commit ${commit}. Snapshot forced`);
if (!args.includes('--snapshot')) {
snapshot = ' --snapshot';
}
}
else {
core.info(`${tag} tag found for commit ${commit}`);
}
}
else {
console.log(`${process.env.GITHUB_REF.split('/')[2]} tag found`);
}
if (key) {
console.log('🔑 Importing signing key...');
core.info('🔑 Importing signing key...');
let path = `${process.env.HOME}/key.asc`;
fs.writeFileSync(path, key, { mode: 0o600 });
yield exec.exec('gpg', ['--import', path], {
silent: silent
});
}
console.log('🏃 Running GoReleaser...');
core.info('🏃 Running GoReleaser...');
yield exec.exec(`${goreleaser} ${args}${snapshot}`, undefined, {
silent: silent
});