mirror of
https://github.com/goreleaser/goreleaser-action
synced 2026-08-29 10:58:28 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79d4afbba1 | ||
|
|
5df302e5e9 | ||
|
|
69b075db94 | ||
|
|
13b378d620 | ||
|
|
cb1d514d21 | ||
|
|
2efe451c4b | ||
|
|
fcc88bd028 | ||
|
|
25383ef1e0 | ||
|
|
bc087ef4b9 | ||
|
|
f9141d00ae | ||
|
|
1bdedc7bba | ||
|
|
5a54d7e660 | ||
|
|
a59bcd6856 | ||
|
|
b59bff5dc3 | ||
|
|
b2263bd81e | ||
|
|
76bde1890b | ||
|
|
194deb5974 |
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 12 KiB |
@@ -26,7 +26,7 @@ jobs:
|
|||||||
- windows-latest
|
- windows-latest
|
||||||
version:
|
version:
|
||||||
- latest
|
- latest
|
||||||
- '~> 0.166'
|
- '~> 0.182'
|
||||||
distribution:
|
distribution:
|
||||||
- goreleaser
|
- goreleaser
|
||||||
- goreleaser-pro
|
- goreleaser-pro
|
||||||
@@ -120,9 +120,9 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Import GPG key
|
name: Import GPG key
|
||||||
id: import_gpg
|
id: import_gpg
|
||||||
uses: crazy-max/ghaction-import-gpg@v3
|
uses: crazy-max/ghaction-import-gpg@v4
|
||||||
with:
|
with:
|
||||||
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY_TEST }}
|
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY_TEST }}
|
||||||
passphrase: ${{ secrets.PASSPHRASE_TEST }}
|
passphrase: ${{ secrets.PASSPHRASE_TEST }}
|
||||||
-
|
-
|
||||||
name: Check
|
name: Check
|
||||||
|
|||||||
@@ -31,6 +31,6 @@ jobs:
|
|||||||
targets: test
|
targets: test
|
||||||
-
|
-
|
||||||
name: Upload coverage
|
name: Upload coverage
|
||||||
uses: codecov/codecov-action@v1
|
uses: codecov/codecov-action@v2
|
||||||
with:
|
with:
|
||||||
file: ./coverage/clover.xml
|
file: ./coverage/clover.xml
|
||||||
|
|||||||
@@ -98,15 +98,16 @@ Or with a condition on GoReleaser step:
|
|||||||
|
|
||||||
### Signing
|
### Signing
|
||||||
|
|
||||||
If [signing is enabled](https://goreleaser.com/customization/#Signing) in your GoReleaser configuration, you can use the [Import GPG](https://github.com/crazy-max/ghaction-import-gpg) GitHub Action along with this one:
|
If [signing is enabled](https://goreleaser.com/customization/#Signing) in your GoReleaser configuration, you can use
|
||||||
|
the [Import GPG](https://github.com/crazy-max/ghaction-import-gpg) GitHub Action along with this one:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
-
|
-
|
||||||
name: Import GPG key
|
name: Import GPG key
|
||||||
id: import_gpg
|
id: import_gpg
|
||||||
uses: crazy-max/ghaction-import-gpg@v3
|
uses: crazy-max/ghaction-import-gpg@v4
|
||||||
with:
|
with:
|
||||||
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
|
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||||
passphrase: ${{ secrets.PASSPHRASE }}
|
passphrase: ${{ secrets.PASSPHRASE }}
|
||||||
-
|
-
|
||||||
name: Run GoReleaser
|
name: Run GoReleaser
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ describe('git', () => {
|
|||||||
expect(tag).not.toEqual('');
|
expect(tag).not.toEqual('');
|
||||||
});
|
});
|
||||||
it('returns git tag through GITHUB_SHA', async () => {
|
it('returns git tag through GITHUB_SHA', async () => {
|
||||||
process.env.GITHUB_SHA = '6e37040623d14330555c7be1603a9182cf92d32a';
|
process.env.GITHUB_SHA = '6389ff5bd287fd6948a7ccda8af8da4f0bbc856a';
|
||||||
const tag: string = await git.getTag();
|
const tag: string = await git.getTag();
|
||||||
console.log(`tag: ${tag}`);
|
console.log(`tag: ${tag}`);
|
||||||
expect(tag).toEqual('v1');
|
expect(tag).toEqual('v2.2.1');
|
||||||
});
|
});
|
||||||
it('returns git tag through GITHUB_REF', async () => {
|
it('returns git tag through GITHUB_REF', async () => {
|
||||||
process.env.GITHUB_REF = 'refs/tags/v2.2.1';
|
process.env.GITHUB_REF = 'refs/tags/v2.2.1';
|
||||||
|
|||||||
+12
-12
@@ -6,29 +6,29 @@ describe('github', () => {
|
|||||||
expect(release).not.toBeNull();
|
expect(release).not.toBeNull();
|
||||||
expect(release?.tag_name).not.toEqual('');
|
expect(release?.tag_name).not.toEqual('');
|
||||||
});
|
});
|
||||||
it('returns v0.117.0 GoReleaser GitHub release', async () => {
|
it('returns v0.182.0 GoReleaser GitHub release', async () => {
|
||||||
const release = await github.getRelease('goreleaser', 'v0.117.0');
|
const release = await github.getRelease('goreleaser', 'v0.182.0');
|
||||||
expect(release).not.toBeNull();
|
expect(release).not.toBeNull();
|
||||||
expect(release?.tag_name).toEqual('v0.117.0');
|
expect(release?.tag_name).toEqual('v0.182.0');
|
||||||
});
|
});
|
||||||
it('returns v0.132.1 GoReleaser GitHub release', async () => {
|
it('returns v0.182.1 GoReleaser GitHub release', async () => {
|
||||||
const release = await github.getRelease('goreleaser', '~> 0.132');
|
const release = await github.getRelease('goreleaser', '~> 0.182');
|
||||||
expect(release).not.toBeNull();
|
expect(release).not.toBeNull();
|
||||||
expect(release?.tag_name).toEqual('v0.132.1');
|
expect(release?.tag_name).toEqual('v0.182.1');
|
||||||
});
|
});
|
||||||
it('returns latest GoReleaser Pro GitHub release', async () => {
|
it('returns latest GoReleaser Pro GitHub release', async () => {
|
||||||
const release = await github.getRelease('goreleaser-pro', 'latest');
|
const release = await github.getRelease('goreleaser-pro', 'latest');
|
||||||
expect(release).not.toBeNull();
|
expect(release).not.toBeNull();
|
||||||
expect(release?.tag_name).not.toEqual('');
|
expect(release?.tag_name).not.toEqual('');
|
||||||
});
|
});
|
||||||
it('returns v0.166.0-pro GoReleaser Pro GitHub release', async () => {
|
it('returns v0.182.0-pro GoReleaser Pro GitHub release', async () => {
|
||||||
const release = await github.getRelease('goreleaser-pro', 'v0.166.0-pro');
|
const release = await github.getRelease('goreleaser-pro', 'v0.182.0-pro');
|
||||||
expect(release).not.toBeNull();
|
expect(release).not.toBeNull();
|
||||||
expect(release?.tag_name).toEqual('v0.166.0-pro');
|
expect(release?.tag_name).toEqual('v0.182.0-pro');
|
||||||
});
|
});
|
||||||
it('returns v0.166.1-pro GoReleaser Pro GitHub release when using semver', async () => {
|
it('returns v0.182.1-pro GoReleaser Pro GitHub release when using semver', async () => {
|
||||||
const release = await github.getRelease('goreleaser-pro', '~> 0.166');
|
const release = await github.getRelease('goreleaser-pro', '~> 0.182');
|
||||||
expect(release).not.toBeNull();
|
expect(release).not.toBeNull();
|
||||||
expect(release?.tag_name).toEqual('v0.166.1-pro');
|
expect(release?.tag_name).toEqual('v0.182.1-pro');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import fs = require('fs');
|
|||||||
import * as installer from '../src/installer';
|
import * as installer from '../src/installer';
|
||||||
|
|
||||||
describe('installer', () => {
|
describe('installer', () => {
|
||||||
it('acquires v0.117.0 version of GoReleaser', async () => {
|
it('acquires v0.182.0 version of GoReleaser', async () => {
|
||||||
const goreleaser = await installer.getGoReleaser('goreleaser', 'v0.117.0');
|
const goreleaser = await installer.getGoReleaser('goreleaser', 'v0.182.0');
|
||||||
expect(fs.existsSync(goreleaser)).toBe(true);
|
expect(fs.existsSync(goreleaser)).toBe(true);
|
||||||
}, 100000);
|
}, 100000);
|
||||||
|
|
||||||
@@ -12,8 +12,8 @@ describe('installer', () => {
|
|||||||
expect(fs.existsSync(goreleaser)).toBe(true);
|
expect(fs.existsSync(goreleaser)).toBe(true);
|
||||||
}, 100000);
|
}, 100000);
|
||||||
|
|
||||||
it('acquires v0.166.0-pro version of GoReleaser Pro', async () => {
|
it('acquires v0.182.0-pro version of GoReleaser Pro', async () => {
|
||||||
const goreleaser = await installer.getGoReleaser('goreleaser-pro', 'v0.166.0-pro');
|
const goreleaser = await installer.getGoReleaser('goreleaser-pro', 'v0.182.0-pro');
|
||||||
expect(fs.existsSync(goreleaser)).toBe(true);
|
expect(fs.existsSync(goreleaser)).toBe(true);
|
||||||
}, 100000);
|
}, 100000);
|
||||||
|
|
||||||
|
|||||||
+636
-1818
File diff suppressed because it is too large
Load Diff
+13
-13
@@ -21,23 +21,23 @@
|
|||||||
"author": "CrazyMax",
|
"author": "CrazyMax",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.3.0",
|
"@actions/core": "^1.6.0",
|
||||||
"@actions/exec": "^1.0.4",
|
"@actions/exec": "^1.1.0",
|
||||||
"@actions/http-client": "^1.0.11",
|
"@actions/http-client": "^1.0.11",
|
||||||
"@actions/tool-cache": "^1.7.0"
|
"@actions/tool-cache": "^1.7.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.14",
|
"@types/jest": "^26.0.24",
|
||||||
"@types/node": "^14.11.2",
|
"@types/node": "^14.17.6",
|
||||||
"@vercel/ncc": "^0.24.1",
|
"@vercel/ncc": "^0.28.6",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.6.0",
|
||||||
"jest": "^26.4.2",
|
"jest": "^26.6.3",
|
||||||
"jest-circus": "^26.4.2",
|
"jest-circus": "^26.6.3",
|
||||||
"jest-runtime": "^26.4.2",
|
"jest-runtime": "^26.6.3",
|
||||||
"prettier": "^2.1.2",
|
"prettier": "^2.3.2",
|
||||||
"tmp": "^0.2.1",
|
"tmp": "^0.2.1",
|
||||||
"ts-jest": "^26.4.1",
|
"ts-jest": "^26.5.6",
|
||||||
"typescript": "^4.0.3",
|
"typescript": "^4.3.5",
|
||||||
"typescript-formatter": "^7.2.2"
|
"typescript-formatter": "^7.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-34
@@ -1,34 +0,0 @@
|
|||||||
import * as actionsExec from '@actions/exec';
|
|
||||||
import {ExecOptions} from '@actions/exec';
|
|
||||||
|
|
||||||
export interface ExecResult {
|
|
||||||
success: boolean;
|
|
||||||
stdout: string;
|
|
||||||
stderr: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const exec = async (command: string, args: string[] = [], silent: boolean): Promise<ExecResult> => {
|
|
||||||
let stdout: string = '';
|
|
||||||
let stderr: string = '';
|
|
||||||
|
|
||||||
const options: ExecOptions = {
|
|
||||||
silent: silent,
|
|
||||||
ignoreReturnCode: true
|
|
||||||
};
|
|
||||||
options.listeners = {
|
|
||||||
stdout: (data: Buffer) => {
|
|
||||||
stdout += data.toString();
|
|
||||||
},
|
|
||||||
stderr: (data: Buffer) => {
|
|
||||||
stderr += data.toString();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const returnCode: number = await actionsExec.exec(command, args, options);
|
|
||||||
|
|
||||||
return {
|
|
||||||
success: returnCode === 0,
|
|
||||||
stdout: stdout.trim(),
|
|
||||||
stderr: stderr.trim()
|
|
||||||
};
|
|
||||||
};
|
|
||||||
+12
-7
@@ -1,12 +1,17 @@
|
|||||||
import * as exec from './exec';
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
const git = async (args: string[] = []): Promise<string> => {
|
const git = async (args: string[] = []): Promise<string> => {
|
||||||
return await exec.exec(`git`, args, true).then(res => {
|
return await exec
|
||||||
if (res.stderr != '' && !res.success) {
|
.getExecOutput(`git`, args, {
|
||||||
throw new Error(res.stderr);
|
ignoreReturnCode: true,
|
||||||
}
|
silent: true
|
||||||
return res.stdout.trim();
|
})
|
||||||
});
|
.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> {
|
export async function getTag(): Promise<string> {
|
||||||
|
|||||||
+25
-4
@@ -15,7 +15,6 @@ export async function getGoReleaser(distribution: string, version: string): Prom
|
|||||||
throw new Error(`Cannot find GoReleaser ${version} release`);
|
throw new Error(`Cannot find GoReleaser ${version} release`);
|
||||||
}
|
}
|
||||||
|
|
||||||
core.info(`✅ GoReleaser version found: ${release.tag_name}`);
|
|
||||||
const filename = getFilename(distribution);
|
const filename = getFilename(distribution);
|
||||||
const downloadUrl = util.format(
|
const downloadUrl = util.format(
|
||||||
'https://github.com/goreleaser/%s/releases/download/%s/%s',
|
'https://github.com/goreleaser/%s/releases/download/%s/%s',
|
||||||
@@ -24,11 +23,11 @@ export async function getGoReleaser(distribution: string, version: string): Prom
|
|||||||
filename
|
filename
|
||||||
);
|
);
|
||||||
|
|
||||||
core.info(`⬇️ Downloading ${downloadUrl}...`);
|
core.info(`Downloading ${downloadUrl}`);
|
||||||
const downloadPath: string = await tc.downloadTool(downloadUrl);
|
const downloadPath: string = await tc.downloadTool(downloadUrl);
|
||||||
core.debug(`Downloaded to ${downloadPath}`);
|
core.debug(`Downloaded to ${downloadPath}`);
|
||||||
|
|
||||||
core.info('📦 Extracting GoReleaser...');
|
core.info('Extracting GoReleaser');
|
||||||
let extPath: string;
|
let extPath: string;
|
||||||
if (osPlat == 'win32') {
|
if (osPlat == 'win32') {
|
||||||
extPath = await tc.extractZip(downloadPath);
|
extPath = await tc.extractZip(downloadPath);
|
||||||
@@ -47,8 +46,30 @@ export async function getGoReleaser(distribution: string, version: string): Prom
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getFilename = (distribution: string): string => {
|
const getFilename = (distribution: string): string => {
|
||||||
|
let arch: string;
|
||||||
|
switch (osArch) {
|
||||||
|
case 'x64': {
|
||||||
|
arch = 'x86_64';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'x32': {
|
||||||
|
arch = 'i386';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'arm': {
|
||||||
|
const arm_version = (process.config.variables as any).arm_version;
|
||||||
|
arch = arm_version ? 'armv' + arm_version : 'arm';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
arch = osArch;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (osPlat == 'darwin') {
|
||||||
|
arch = 'all';
|
||||||
|
}
|
||||||
const platform: string = osPlat == 'win32' ? 'Windows' : osPlat == 'darwin' ? 'Darwin' : 'Linux';
|
const platform: string = osPlat == 'win32' ? 'Windows' : osPlat == 'darwin' ? 'Darwin' : 'Linux';
|
||||||
const arch: string = osArch == 'x64' ? 'x86_64' : 'i386';
|
|
||||||
const ext: string = osPlat == 'win32' ? 'zip' : 'tar.gz';
|
const ext: string = osPlat == 'win32' ? 'zip' : 'tar.gz';
|
||||||
const suffix: string = pro.suffix(distribution);
|
const suffix: string = pro.suffix(distribution);
|
||||||
return util.format('goreleaser%s_%s_%s.%s', suffix, platform, arch, ext);
|
return util.format('goreleaser%s_%s_%s.%s', suffix, platform, arch, ext);
|
||||||
|
|||||||
+7
-7
@@ -12,7 +12,7 @@ async function run(): Promise<void> {
|
|||||||
const workdir = core.getInput('workdir') || '.';
|
const workdir = core.getInput('workdir') || '.';
|
||||||
const isInstallOnly = /^true$/i.test(core.getInput('install-only'));
|
const isInstallOnly = /^true$/i.test(core.getInput('install-only'));
|
||||||
const goreleaser = await installer.getGoReleaser(distribution, version);
|
const goreleaser = await installer.getGoReleaser(distribution, version);
|
||||||
core.info(`✅ GoReleaser installed successfully`);
|
core.info(`GoReleaser ${version} installed successfully`);
|
||||||
|
|
||||||
if (isInstallOnly) {
|
if (isInstallOnly) {
|
||||||
const goreleaserDir = dirname(goreleaser);
|
const goreleaserDir = dirname(goreleaser);
|
||||||
@@ -20,11 +20,12 @@ async function run(): Promise<void> {
|
|||||||
core.debug(`Added ${goreleaserDir} to PATH`);
|
core.debug(`Added ${goreleaserDir} to PATH`);
|
||||||
return;
|
return;
|
||||||
} else if (!args) {
|
} else if (!args) {
|
||||||
throw new Error('args input required');
|
core.setFailed('args input required');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (workdir && workdir !== '.') {
|
if (workdir && workdir !== '.') {
|
||||||
core.info(`📂 Using ${workdir} as working directory...`);
|
core.info(`Using ${workdir} as working directory`);
|
||||||
process.chdir(workdir);
|
process.chdir(workdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,16 +36,15 @@ async function run(): Promise<void> {
|
|||||||
let snapshot = '';
|
let snapshot = '';
|
||||||
if (args.split(' ').indexOf('release') > -1) {
|
if (args.split(' ').indexOf('release') > -1) {
|
||||||
if (isTagDirty) {
|
if (isTagDirty) {
|
||||||
core.info(`⚠️ No tag found for commit ${commit}. Snapshot forced`);
|
if (!args.includes('--snapshot') && !args.includes('--nightly')) {
|
||||||
if (!args.includes('--snapshot')) {
|
core.info(`No tag found for commit ${commit}. Snapshot forced`);
|
||||||
snapshot = ' --snapshot';
|
snapshot = ' --snapshot';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
core.info(`✅ ${tag} tag found for commit ${commit}`);
|
core.info(`${tag} tag found for commit ${commit}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
core.info('🏃 Running GoReleaser...');
|
|
||||||
if (!('GORELEASER_CURRENT_TAG' in process.env)) {
|
if (!('GORELEASER_CURRENT_TAG' in process.env)) {
|
||||||
process.env.GORELEASER_CURRENT_TAG = tag;
|
process.env.GORELEASER_CURRENT_TAG = tag;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user