mirror of
https://github.com/goreleaser/goreleaser-action
synced 2026-06-29 23:47:30 +00:00
Merge remote-tracking branch 'origin/master' into flarco/master
Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
-49
@@ -1,49 +0,0 @@
|
||||
import * as exec from '@actions/exec';
|
||||
|
||||
const git = async (args: string[] = []): Promise<string> => {
|
||||
return await exec
|
||||
.getExecOutput(`git`, args, {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
})
|
||||
.then(res => {
|
||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||
throw new Error(res.stderr);
|
||||
}
|
||||
return res.stdout.trim();
|
||||
});
|
||||
};
|
||||
|
||||
export async function getTag(): Promise<string> {
|
||||
try {
|
||||
if ((process.env.GITHUB_REF || '').startsWith('refs/tags')) {
|
||||
const tag = (process.env.GITHUB_REF || '').split('/').pop();
|
||||
if (tag !== '' && tag !== undefined) {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
return await git(['tag', '--points-at', `${process.env.GITHUB_SHA}`, '--sort', '-version:creatordate']).then(
|
||||
tags => {
|
||||
if (tags.length == 0) {
|
||||
return git(['describe', '--tags', '--abbrev=0']);
|
||||
}
|
||||
return tags.split('\n')[0];
|
||||
}
|
||||
);
|
||||
} catch (err) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
export async function isTagDirty(currentTag: string): Promise<boolean> {
|
||||
try {
|
||||
await git(['describe', '--exact-match', '--tags', '--match', currentTag]);
|
||||
} catch (err) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function getShortCommit(): Promise<string> {
|
||||
return await git(['show', "--format='%h'", 'HEAD', '--quiet']);
|
||||
}
|
||||
+2
-2
@@ -28,8 +28,8 @@ export async function install(distribution: string, version: string): Promise<st
|
||||
core.info('Extracting GoReleaser');
|
||||
let extPath: string;
|
||||
if (context.osPlat == 'win32') {
|
||||
if(!downloadPath.endsWith('.zip')) {
|
||||
let newPath = downloadPath + '.zip';
|
||||
if (!downloadPath.endsWith('.zip')) {
|
||||
const newPath = downloadPath + '.zip';
|
||||
fs.renameSync(downloadPath, newPath);
|
||||
extPath = await tc.extractZip(newPath);
|
||||
} else {
|
||||
|
||||
+1
-24
@@ -2,7 +2,6 @@ import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import yargs from 'yargs';
|
||||
import * as context from './context';
|
||||
import * as git from './git';
|
||||
import * as goreleaser from './goreleaser';
|
||||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
@@ -28,10 +27,6 @@ async function run(): Promise<void> {
|
||||
process.chdir(inputs.workdir);
|
||||
}
|
||||
|
||||
const commit = await git.getShortCommit();
|
||||
const tag = await git.getTag();
|
||||
const isTagDirty = await git.isTagDirty(tag);
|
||||
|
||||
let yamlfile: string | unknown;
|
||||
const argv = yargs.parse(inputs.args);
|
||||
if (argv.config) {
|
||||
@@ -44,25 +39,7 @@ async function run(): Promise<void> {
|
||||
});
|
||||
}
|
||||
|
||||
let snapshot = '';
|
||||
if (inputs.args.split(' ').indexOf('release') > -1) {
|
||||
if (isTagDirty) {
|
||||
if (!inputs.args.includes('--snapshot') && !inputs.args.includes('--nightly')) {
|
||||
core.info(`No tag found for commit ${commit}. Snapshot forced`);
|
||||
snapshot = ' --snapshot';
|
||||
}
|
||||
} else {
|
||||
core.info(`${tag} tag found for commit ${commit}`);
|
||||
}
|
||||
}
|
||||
|
||||
await exec.exec(`${bin} ${inputs.args}${snapshot}`, undefined, {
|
||||
env: Object.assign({}, process.env, {
|
||||
GORELEASER_CURRENT_TAG: process.env.GORELEASER_CURRENT_TAG || tag || ''
|
||||
}) as {
|
||||
[key: string]: string;
|
||||
}
|
||||
});
|
||||
await exec.exec(`${bin} ${inputs.args}`);
|
||||
|
||||
if (typeof yamlfile === 'string') {
|
||||
const artifacts = await goreleaser.getArtifacts(await goreleaser.getDistPath(yamlfile));
|
||||
|
||||
Reference in New Issue
Block a user