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:
commit
66134d94a7
|
@ -57,7 +57,7 @@ jobs:
|
|||
with:
|
||||
distribution: ${{ matrix.distribution }}
|
||||
version: ${{ matrix.version }}
|
||||
args: release --skip-publish --rm-dist
|
||||
args: release --skip-publish --rm-dist --snapshot
|
||||
workdir: ./test
|
||||
|
||||
install-only:
|
||||
|
@ -138,7 +138,7 @@ jobs:
|
|||
uses: ./
|
||||
with:
|
||||
version: latest
|
||||
args: -f .goreleaser-signing.yml release --skip-publish --rm-dist
|
||||
args: -f .goreleaser-signing.yml release --skip-publish --rm-dist --snapshot
|
||||
workdir: ./test
|
||||
env:
|
||||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
||||
|
@ -166,7 +166,7 @@ jobs:
|
|||
name: GoReleaser
|
||||
uses: ./
|
||||
with:
|
||||
args: release --skip-publish --rm-dist
|
||||
args: release --skip-publish --rm-dist --snapshot
|
||||
workdir: ./test
|
||||
-
|
||||
name: Upload assets
|
||||
|
@ -175,28 +175,6 @@ jobs:
|
|||
name: myapp
|
||||
path: ./test/dist/*
|
||||
|
||||
current-tag:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
-
|
||||
name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.18
|
||||
-
|
||||
name: GoReleaser
|
||||
uses: ./
|
||||
with:
|
||||
args: release --skip-publish --rm-dist
|
||||
workdir: ./test
|
||||
env:
|
||||
GORELEASER_CURRENT_TAG: v99.99.99
|
||||
|
||||
dist:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
@ -214,7 +192,7 @@ jobs:
|
|||
name: GoReleaser
|
||||
uses: ./
|
||||
with:
|
||||
args: release --config .goreleaser-dist.yml --skip-publish --rm-dist
|
||||
args: release --config .goreleaser-dist.yml --skip-publish --rm-dist --snapshot
|
||||
workdir: ./test
|
||||
-
|
||||
name: Check dist
|
||||
|
|
|
@ -138,6 +138,7 @@ purpose. You can do that with the [actions/upload-artifact](https://github.com/a
|
|||
with:
|
||||
version: latest
|
||||
args: release --rm-dist
|
||||
workdir: myfolder
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
|
@ -145,7 +146,7 @@ purpose. You can do that with the [actions/upload-artifact](https://github.com/a
|
|||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: myapp
|
||||
path: dist/*
|
||||
path: myfolder/dist/*
|
||||
```
|
||||
|
||||
### Install Only
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
import {describe, expect, it} from '@jest/globals';
|
||||
import * as git from '../src/git';
|
||||
|
||||
describe('git', () => {
|
||||
it('returns git tag through describe', async () => {
|
||||
process.env.GITHUB_SHA = '309312125ed7a32fcd48f3a1e24dcafe669c186a';
|
||||
const tag: string = await git.getTag();
|
||||
expect(tag).not.toEqual('');
|
||||
});
|
||||
|
||||
it('returns git tag through GITHUB_SHA', async () => {
|
||||
process.env.GITHUB_SHA = '6389ff5bd287fd6948a7ccda8af8da4f0bbc856a';
|
||||
const tag: string = await git.getTag();
|
||||
expect(tag).toEqual('v2.2.1');
|
||||
});
|
||||
|
||||
it('returns git tag through GITHUB_REF', async () => {
|
||||
process.env.GITHUB_REF = 'refs/tags/v2.2.1';
|
||||
const tag: string = await git.getTag();
|
||||
expect(tag).toEqual('v2.2.1');
|
||||
});
|
||||
|
||||
it('checks if tag is dirty', async () => {
|
||||
expect(await git.isTagDirty('v1.3.1')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns short commit', async () => {
|
||||
const commit: string = await git.getShortCommit();
|
||||
expect(commit).not.toEqual('');
|
||||
});
|
||||
});
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -26,7 +26,7 @@
|
|||
"@actions/http-client": "^2.0.1",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"yargs": "^17.6.0"
|
||||
"yargs": "^17.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.11.26",
|
||||
|
|
49
src/git.ts
49
src/git.ts
|
@ -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']);
|
||||
}
|
|
@ -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 {
|
||||
|
|
25
src/main.ts
25
src/main.ts
|
@ -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));
|
||||
|
|
18
yarn.lock
18
yarn.lock
|
@ -3558,10 +3558,10 @@ yargs-parser@20.x, yargs-parser@^20.2.2:
|
|||
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee"
|
||||
integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==
|
||||
|
||||
yargs-parser@^21.0.0:
|
||||
version "21.0.1"
|
||||
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.0.1.tgz#0267f286c877a4f0f728fceb6f8a3e4cb95c6e35"
|
||||
integrity sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==
|
||||
yargs-parser@^21.1.1:
|
||||
version "21.1.1"
|
||||
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"
|
||||
integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==
|
||||
|
||||
yargs@^16.2.0:
|
||||
version "16.2.0"
|
||||
|
@ -3576,10 +3576,10 @@ yargs@^16.2.0:
|
|||
y18n "^5.0.5"
|
||||
yargs-parser "^20.2.2"
|
||||
|
||||
yargs@^17.6.0:
|
||||
version "17.6.0"
|
||||
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.6.0.tgz#e134900fc1f218bc230192bdec06a0a5f973e46c"
|
||||
integrity sha512-8H/wTDqlSwoSnScvV2N/JHfLWOKuh5MVla9hqLjK3nsfyy6Y4kDSYSvkU5YCUEPOSnRXfIyx3Sq+B/IWudTo4g==
|
||||
yargs@^17.6.2:
|
||||
version "17.6.2"
|
||||
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.6.2.tgz#2e23f2944e976339a1ee00f18c77fedee8332541"
|
||||
integrity sha512-1/9UrdHjDZc0eOU0HxOHoS78C69UD3JRMvzlJ7S79S2nTaWRA/whGCTV8o9e/N/1Va9YIV7Q4sOxD8VV4pCWOw==
|
||||
dependencies:
|
||||
cliui "^8.0.1"
|
||||
escalade "^3.1.1"
|
||||
|
@ -3587,7 +3587,7 @@ yargs@^17.6.0:
|
|||
require-directory "^2.1.1"
|
||||
string-width "^4.2.3"
|
||||
y18n "^5.0.5"
|
||||
yargs-parser "^21.0.0"
|
||||
yargs-parser "^21.1.1"
|
||||
|
||||
yn@3.1.1:
|
||||
version "3.1.1"
|
||||
|
|
Loading…
Reference in New Issue