Compare commits

...
22 Commits
Author SHA1 Message Date
b953231f81 fix: current tag not taken into account (#329)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-28 11:24:18 -03:00
c127c9be61 feat: add artifacts and metadata outputs (#327)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-27 20:01:51 +01:00
affd781166 chore: update community files (#328)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-27 18:55:49 +01:00
39419c3fac refactor: setup context (#325)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-27 17:22:06 +01:00
Carlos A Becker a80c8fd82d chore: refresh
Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
2022-01-14 17:42:15 -03:00
Carlos Alexandro BeckerandGitHub 79d4afbba1 fix: should not force snapshot when nightly is set (#321)
* fix: should not force snapshot when nightly is set

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* fix: build

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
2022-01-14 17:50:06 +01:00
Carlos Alexandro BeckerandGitHub 5df302e5e9 fix: get darwin universal binary (#312)
Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
2021-10-15 14:43:54 +02:00
69b075db94 chore: update generate content (#310)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-10-03 23:05:45 +02:00
13b378d620 fix: support arch variant to download GoReleaser (#309)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-10-03 23:03:55 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
cb1d514d21 chore(deps): bump @actions/core from 1.5.0 to 1.6.0 (#307)
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.5.0 to 1.6.0.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

---
updated-dependencies:
- dependency-name: "@actions/core"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-29 09:15:30 -03:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2efe451c4b chore(deps): bump ansi-regex from 5.0.0 to 5.0.1 (#306)
Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 5.0.0 to 5.0.1.
- [Release notes](https://github.com/chalk/ansi-regex/releases)
- [Commits](https://github.com/chalk/ansi-regex/compare/v5.0.0...v5.0.1)

---
updated-dependencies:
- dependency-name: ansi-regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-22 22:01:33 -03:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
fcc88bd028 chore(deps): bump tmpl from 1.0.4 to 1.0.5 (#305)
Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-22 20:00:34 -03:00
25383ef1e0 chore(deps): bump ghaction-import-gpg to v4 (#302)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-09-06 22:45:41 +02:00
bc087ef4b9 fix: platform detection v2 (#300)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-08-27 12:02:19 +02:00
f9141d00ae fix: platform detection (#299)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-08-26 19:23:54 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>CrazyMax
1bdedc7bba chore(deps): bump @actions/core from 1.4.0 to 1.5.0 (#296)
* chore(deps): bump @actions/core from 1.4.0 to 1.5.0

Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

---
updated-dependencies:
- dependency-name: "@actions/core"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(deps): update generated content

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-08-20 12:07:40 +02:00
5a54d7e660 chore(deps): update dev deps (#294)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-07-26 14:06:35 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Carlos Alexandro Becker
a59bcd6856 chore(deps): bump codecov/codecov-action from 1 to 2 (#293)
* chore(deps): bump codecov/codecov-action from 1 to 2

Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 1 to 2.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v1...v2.0.1)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update test.yml

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2021-07-20 09:37:17 -03:00
b59bff5dc3 refactor: use built-in getExecOutput (#292)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-06-10 03:02:52 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>CrazyMax
b2263bd81e chore(deps): bump @actions/exec from 1.0.4 to 1.1.0 (#291)
* chore(deps): bump @actions/exec from 1.0.4 to 1.1.0

Bumps [@actions/exec](https://github.com/actions/toolkit/tree/HEAD/packages/exec) from 1.0.4 to 1.1.0.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/exec/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/@actions/core@1.1.0/packages/exec)

---
updated-dependencies:
- dependency-name: "@actions/exec"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update generated content

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-06-10 00:42:36 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>CrazyMax
76bde1890b chore(deps): bump @actions/core from 1.3.0 to 1.4.0 (#289)
* chore(deps): bump @actions/core from 1.3.0 to 1.4.0

Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

---
updated-dependencies:
- dependency-name: "@actions/core"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update generated content

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-06-10 00:34:58 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>CrazyMax
194deb5974 chore(deps): bump @actions/tool-cache from 1.7.0 to 1.7.1 (#290)
* chore(deps): bump @actions/tool-cache from 1.7.0 to 1.7.1

Bumps [@actions/tool-cache](https://github.com/actions/toolkit/tree/HEAD/packages/tool-cache) from 1.7.0 to 1.7.1.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/tool-cache/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/tool-cache)

---
updated-dependencies:
- dependency-name: "@actions/tool-cache"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update generated content

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-06-10 00:23:31 +02:00
24 changed files with 9975 additions and 3273 deletions
+3 -2
View File
@@ -1,2 +1,3 @@
github: crazy-max github: [crazy-max, caarlos0]
custom: https://www.paypal.me/crazyws open_collective: goreleaser
custom: ["https://goreleaser.com/pro"]
Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 12 KiB

+25 -3
View File
@@ -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
@@ -174,3 +174,25 @@ jobs:
with: with:
name: myapp name: myapp
path: ./test/dist/* path: ./test/dist/*
current-tag:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
-
name: GoReleaser
uses: ./
with:
args: release --skip-publish --rm-dist
workdir: ./test
env:
GORELEASER_CURRENT_TAG: v1.2.3
+1 -1
View File
@@ -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
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2019-2021 CrazyMax Copyright (c) 2019-2022 CrazyMax
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
+14 -6
View File
@@ -7,7 +7,6 @@
<a href="https://github.com/marketplace/actions/goreleaser-action"><img alt="GitHub marketplace" src="https://img.shields.io/badge/marketplace-goreleaser--action-blue?logo=github&style=flat-square"></a> <a href="https://github.com/marketplace/actions/goreleaser-action"><img alt="GitHub marketplace" src="https://img.shields.io/badge/marketplace-goreleaser--action-blue?logo=github&style=flat-square"></a>
<a href="https://github.com/goreleaser/goreleaser-action/actions?workflow=test"><img alt="Test workflow" src="https://img.shields.io/github/workflow/status/goreleaser/goreleaser-action/test?label=test&logo=github&style=flat-square"></a> <a href="https://github.com/goreleaser/goreleaser-action/actions?workflow=test"><img alt="Test workflow" src="https://img.shields.io/github/workflow/status/goreleaser/goreleaser-action/test?label=test&logo=github&style=flat-square"></a>
<a href="https://codecov.io/gh/goreleaser/goreleaser-action"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/goreleaser/goreleaser-action?logo=codecov&style=flat-square"></a> <a href="https://codecov.io/gh/goreleaser/goreleaser-action"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/goreleaser/goreleaser-action?logo=codecov&style=flat-square"></a>
<a href="https://github.com/sponsors/crazy-max"><img src="https://img.shields.io/badge/sponsor-crazy--max-181717.svg?logo=github&style=flat-square" alt="Become a sponsor"></a>
</p> </p>
</p> </p>
@@ -23,6 +22,7 @@ ___
* [Install Only](#install-only) * [Install Only](#install-only)
* [Customizing](#customizing) * [Customizing](#customizing)
* [inputs](#inputs) * [inputs](#inputs)
* [outputs](#outputs)
* [environment variables](#environment-variables) * [environment variables](#environment-variables)
* [Limitation](#limitation) * [Limitation](#limitation)
* [Development](#development) * [Development](#development)
@@ -51,8 +51,6 @@ jobs:
- -
name: Set up Go name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with:
go-version: 1.15
- -
name: Run GoReleaser name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2 uses: goreleaser/goreleaser-action@v2
@@ -98,15 +96,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
@@ -179,6 +178,15 @@ Following inputs can be used as `step.with` keys
> **¹** Can be a fixed version like `v0.117.0` or a max satisfying semver one like `~> 0.132`. In this case this will return `v0.132.1`. > **¹** Can be a fixed version like `v0.117.0` or a max satisfying semver one like `~> 0.132`. In this case this will return `v0.132.1`.
### outputs
Following outputs are available
| Name | Type | Description |
|-------------------|---------|---------------------------------------|
| `artifacts` | JSON | Build result artifacts |
| `metadata` | JSON | Build result metadata |
### environment variables ### environment variables
Following environment variables can be used as `step.env` keys Following environment variables can be used as `step.env` keys
+31
View File
@@ -0,0 +1,31 @@
import * as os from 'os';
import * as context from '../src/context';
describe('setOutput', () => {
beforeEach(() => {
process.stdout.write = jest.fn();
});
it('setOutput produces the correct command', () => {
context.setOutput('some output', 'some value');
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
});
it('setOutput handles bools', () => {
context.setOutput('some output', false);
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
});
it('setOutput handles numbers', () => {
context.setOutput('some output', 1.01);
assertWriteCalls([`::set-output name=some output::1.01${os.EOL}`]);
});
});
// Assert that process.stdout.write calls called only with the given arguments.
function assertWriteCalls(calls: string[]): void {
expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
for (let i = 0; i < calls.length; i++) {
expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
}
}
+2 -2
View File
@@ -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
View File
@@ -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');
}); });
}); });
+33
View File
@@ -0,0 +1,33 @@
import * as fs from 'fs';
import * as goreleaser from '../src/goreleaser';
describe('install', () => {
it('acquires v0.182.0 version of GoReleaser', async () => {
const bin = await goreleaser.install('goreleaser', 'v0.182.0');
expect(fs.existsSync(bin)).toBe(true);
}, 100000);
it('acquires latest version of GoReleaser', async () => {
const bin = await goreleaser.install('goreleaser', 'latest');
expect(fs.existsSync(bin)).toBe(true);
}, 100000);
it('acquires v0.182.0-pro version of GoReleaser Pro', async () => {
const bin = await goreleaser.install('goreleaser-pro', 'v0.182.0-pro');
expect(fs.existsSync(bin)).toBe(true);
}, 100000);
it('acquires latest version of GoReleaser Pro', async () => {
const bin = await goreleaser.install('goreleaser-pro', 'latest');
expect(fs.existsSync(bin)).toBe(true);
}, 100000);
});
describe('distribSuffix', () => {
it('suffixes pro distribution', async () => {
expect(goreleaser.distribSuffix('goreleaser-pro')).toEqual('-pro');
});
it('does not suffix oss distribution', async () => {
expect(goreleaser.distribSuffix('goreleaser')).toEqual('');
});
});
-24
View File
@@ -1,24 +0,0 @@
import fs = require('fs');
import * as installer from '../src/installer';
describe('installer', () => {
it('acquires v0.117.0 version of GoReleaser', async () => {
const goreleaser = await installer.getGoReleaser('goreleaser', 'v0.117.0');
expect(fs.existsSync(goreleaser)).toBe(true);
}, 100000);
it('acquires latest version of GoReleaser', async () => {
const goreleaser = await installer.getGoReleaser('goreleaser', 'latest');
expect(fs.existsSync(goreleaser)).toBe(true);
}, 100000);
it('acquires v0.166.0-pro version of GoReleaser Pro', async () => {
const goreleaser = await installer.getGoReleaser('goreleaser-pro', 'v0.166.0-pro');
expect(fs.existsSync(goreleaser)).toBe(true);
}, 100000);
it('acquires latest version of GoReleaser Pro', async () => {
const goreleaser = await installer.getGoReleaser('goreleaser-pro', 'latest');
expect(fs.existsSync(goreleaser)).toBe(true);
}, 100000);
});
-10
View File
@@ -1,10 +0,0 @@
import * as pro from '../src/pro';
describe('pro', () => {
it('suffixes pro distribution', async () => {
expect(pro.suffix('goreleaser-pro')).toEqual('-pro');
});
it('does not suffix oss distribution', async () => {
expect(pro.suffix('goreleaser')).toEqual('');
});
});
+7 -1
View File
@@ -1,7 +1,7 @@
# https://help.github.com/en/articles/metadata-syntax-for-github-actions # https://help.github.com/en/articles/metadata-syntax-for-github-actions
name: 'GoReleaser Action' name: 'GoReleaser Action'
description: 'GitHub Action for GoReleaser, a release automation tool for Go projects' description: 'GitHub Action for GoReleaser, a release automation tool for Go projects'
author: 'crazy-max' author: 'goreleaser'
branding: branding:
color: 'green' color: 'green'
icon: 'package' icon: 'package'
@@ -27,6 +27,12 @@ inputs:
default: 'false' default: 'false'
required: false required: false
outputs:
artifacts:
description: 'Build result artifacts'
metadata:
description: 'Build result metadata'
runs: runs:
using: 'node12' using: 'node12'
main: 'dist/index.js' main: 'dist/index.js'
Generated Vendored
+8571 -1854
View File
File diff suppressed because one or more lines are too long
+15 -13
View File
@@ -21,23 +21,25 @@
"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",
"js-yaml": "^4.1.0",
"yargs": "^17.3.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"
} }
} }
+29
View File
@@ -0,0 +1,29 @@
import * as os from 'os';
import * as core from '@actions/core';
import {issueCommand} from '@actions/core/lib/command';
export const osPlat: string = os.platform();
export const osArch: string = os.arch();
export interface Inputs {
distribution: string;
version: string;
args: string;
workdir: string;
installOnly: boolean;
}
export async function getInputs(): Promise<Inputs> {
return {
distribution: core.getInput('distribution') || 'goreleaser',
version: core.getInput('version'),
args: core.getInput('args'),
workdir: core.getInput('workdir') || '.',
installOnly: core.getBooleanInput('install-only')
};
}
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
export function setOutput(name: string, value: any): void {
issueCommand('set-output', {name}, value);
}
-34
View File
@@ -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
View File
@@ -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> {
+6 -8
View File
@@ -1,7 +1,7 @@
import * as httpm from '@actions/http-client'; import * as goreleaser from './goreleaser';
import * as core from '@actions/core';
import * as semver from 'semver'; import * as semver from 'semver';
import * as pro from './pro'; import * as core from '@actions/core';
import * as httpm from '@actions/http-client';
export interface GitHubRelease { export interface GitHubRelease {
id: number; id: number;
@@ -22,13 +22,13 @@ const resolveVersion = async (distribution: string, version: string): Promise<st
} }
core.debug(`Found ${allTags.length} tags in total`); core.debug(`Found ${allTags.length} tags in total`);
if (version === 'latest' || !pro.isPro(distribution)) { if (version === 'latest' || !goreleaser.isPro(distribution)) {
return semver.maxSatisfying(allTags, version); return semver.maxSatisfying(allTags, version);
} }
const cleanTags: Array<string> = allTags.map(tag => cleanTag(tag)); const cleanTags: Array<string> = allTags.map(tag => cleanTag(tag));
const cleanVersion: string = cleanTag(version); const cleanVersion: string = cleanTag(version);
return semver.maxSatisfying(cleanTags, cleanVersion) + pro.suffix(distribution); return semver.maxSatisfying(cleanTags, cleanVersion) + goreleaser.distribSuffix(distribution);
}; };
interface GitHubTag { interface GitHubTag {
@@ -37,15 +37,13 @@ interface GitHubTag {
const getAllTags = async (distribution: string): Promise<Array<string>> => { const getAllTags = async (distribution: string): Promise<Array<string>> => {
const http: httpm.HttpClient = new httpm.HttpClient('goreleaser-action'); const http: httpm.HttpClient = new httpm.HttpClient('goreleaser-action');
const suffix: string = pro.suffix(distribution); const suffix: string = goreleaser.distribSuffix(distribution);
const url: string = `https://goreleaser.com/static/releases${suffix}.json`; const url: string = `https://goreleaser.com/static/releases${suffix}.json`;
const getTags = http.getJson<Array<GitHubTag>>(url); const getTags = http.getJson<Array<GitHubTag>>(url);
return getTags.then(response => { return getTags.then(response => {
if (response.result == null) { if (response.result == null) {
return []; return [];
} }
return response.result.map(obj => obj.tag_name); return response.result.map(obj => obj.tag_name);
}); });
}; };
+111
View File
@@ -0,0 +1,111 @@
import * as fs from 'fs';
import * as path from 'path';
import * as util from 'util';
import yaml from 'js-yaml';
import * as context from './context';
import * as github from './github';
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
export async function install(distribution: string, version: string): Promise<string> {
const release: github.GitHubRelease | null = await github.getRelease(distribution, version);
if (!release) {
throw new Error(`Cannot find GoReleaser ${version} release`);
}
const filename = getFilename(distribution);
const downloadUrl = util.format(
'https://github.com/goreleaser/%s/releases/download/%s/%s',
distribution,
release.tag_name,
filename
);
core.info(`Downloading ${downloadUrl}`);
const downloadPath: string = await tc.downloadTool(downloadUrl);
core.debug(`Downloaded to ${downloadPath}`);
core.info('Extracting GoReleaser');
let extPath: string;
if (context.osPlat == 'win32') {
extPath = await tc.extractZip(downloadPath);
} else {
extPath = await tc.extractTar(downloadPath);
}
core.debug(`Extracted to ${extPath}`);
const cachePath: string = await tc.cacheDir(extPath, 'goreleaser-action', release.tag_name.replace(/^v/, ''));
core.debug(`Cached to ${cachePath}`);
const exePath: string = path.join(cachePath, context.osPlat == 'win32' ? 'goreleaser.exe' : 'goreleaser');
core.debug(`Exe path is ${exePath}`);
return exePath;
}
export const distribSuffix = (distribution: string): string => {
return isPro(distribution) ? '-pro' : '';
};
export const isPro = (distribution: string): boolean => {
return distribution === 'goreleaser-pro';
};
const getFilename = (distribution: string): string => {
let arch: string;
switch (context.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 = context.osArch;
break;
}
}
if (context.osPlat == 'darwin') {
arch = 'all';
}
const platform: string = context.osPlat == 'win32' ? 'Windows' : context.osPlat == 'darwin' ? 'Darwin' : 'Linux';
const ext: string = context.osPlat == 'win32' ? 'zip' : 'tar.gz';
const suffix: string = distribSuffix(distribution);
return util.format('goreleaser%s_%s_%s.%s', suffix, platform, arch, ext);
};
export async function getDistPath(yamlfile: string): Promise<string> {
const cfg = yaml.load(yamlfile);
return cfg.dist || 'dist';
}
export async function getArtifacts(distpath: string): Promise<string | undefined> {
const artifactsFile = path.join(distpath, 'artifacts.json');
if (!fs.existsSync(artifactsFile)) {
return undefined;
}
const content = fs.readFileSync(artifactsFile, {encoding: 'utf-8'}).trim();
if (content === 'null') {
return undefined;
}
return content;
}
export async function getMetadata(distpath: string): Promise<string | undefined> {
const metadataFile = path.join(distpath, 'metadata.json');
if (!fs.existsSync(metadataFile)) {
return undefined;
}
const content = fs.readFileSync(metadataFile, {encoding: 'utf-8'}).trim();
if (content === 'null') {
return undefined;
}
return content;
}
-55
View File
@@ -1,55 +0,0 @@
import * as os from 'os';
import * as path from 'path';
import * as util from 'util';
import * as github from './github';
import * as pro from './pro';
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
const osPlat: string = os.platform();
const osArch: string = os.arch();
export async function getGoReleaser(distribution: string, version: string): Promise<string> {
const release: github.GitHubRelease | null = await github.getRelease(distribution, version);
if (!release) {
throw new Error(`Cannot find GoReleaser ${version} release`);
}
core.info(`✅ GoReleaser version found: ${release.tag_name}`);
const filename = getFilename(distribution);
const downloadUrl = util.format(
'https://github.com/goreleaser/%s/releases/download/%s/%s',
distribution,
release.tag_name,
filename
);
core.info(`⬇️ Downloading ${downloadUrl}...`);
const downloadPath: string = await tc.downloadTool(downloadUrl);
core.debug(`Downloaded to ${downloadPath}`);
core.info('📦 Extracting GoReleaser...');
let extPath: string;
if (osPlat == 'win32') {
extPath = await tc.extractZip(downloadPath);
} else {
extPath = await tc.extractTar(downloadPath);
}
core.debug(`Extracted to ${extPath}`);
const cachePath: string = await tc.cacheDir(extPath, 'goreleaser-action', release.tag_name.replace(/^v/, ''));
core.debug(`Cached to ${cachePath}`);
const exePath: string = path.join(cachePath, osPlat == 'win32' ? 'goreleaser.exe' : 'goreleaser');
core.debug(`Exe path is ${exePath}`);
return exePath;
}
const getFilename = (distribution: string): string => {
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 suffix: string = pro.suffix(distribution);
return util.format('goreleaser%s_%s_%s.%s', suffix, platform, arch, ext);
};
+55 -24
View File
@@ -1,54 +1,85 @@
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 git from './git';
import * as installer from './installer'; import * as goreleaser from './goreleaser';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as exec from '@actions/exec'; import * as exec from '@actions/exec';
import {dirname} from 'path';
async function run(): Promise<void> { async function run(): Promise<void> {
try { try {
const distribution = core.getInput('distribution') || 'goreleaser'; const inputs: context.Inputs = await context.getInputs();
const version = core.getInput('version') || 'latest'; const bin = await goreleaser.install(inputs.distribution, inputs.version);
const args = core.getInput('args'); core.info(`GoReleaser ${inputs.version} installed successfully`);
const workdir = core.getInput('workdir') || '.';
const isInstallOnly = /^true$/i.test(core.getInput('install-only'));
const goreleaser = await installer.getGoReleaser(distribution, version);
core.info(`✅ GoReleaser installed successfully`);
if (isInstallOnly) { if (inputs.installOnly) {
const goreleaserDir = dirname(goreleaser); const goreleaserDir = path.dirname(bin);
core.addPath(goreleaserDir); core.addPath(goreleaserDir);
core.debug(`Added ${goreleaserDir} to PATH`); core.debug(`Added ${goreleaserDir} to PATH`);
return; return;
} else if (!args) { } else if (!inputs.args) {
throw new Error('args input required'); core.setFailed('args input required');
return;
} }
if (workdir && workdir !== '.') { if (inputs.workdir && inputs.workdir !== '.') {
core.info(`📂 Using ${workdir} as working directory...`); core.info(`Using ${inputs.workdir} as working directory`);
process.chdir(workdir); process.chdir(inputs.workdir);
} }
const commit = await git.getShortCommit(); const commit = await git.getShortCommit();
const tag = await git.getTag(); const tag = await git.getTag();
const isTagDirty = await git.isTagDirty(tag); const isTagDirty = await git.isTagDirty(tag);
let yamlfile: string | unknown;
const argv = yargs.parse(inputs.args);
if (argv.config) {
yamlfile = argv.config;
} else {
['.goreleaser.yaml', '.goreleaser.yml', 'goreleaser.yaml', 'goreleaser.yml'].forEach(f => {
if (fs.existsSync(f)) {
yamlfile = f;
}
});
}
let snapshot = ''; let snapshot = '';
if (args.split(' ').indexOf('release') > -1) { if (inputs.args.split(' ').indexOf('release') > -1) {
if (isTagDirty) { if (isTagDirty) {
core.info(`⚠️ No tag found for commit ${commit}. Snapshot forced`); if (!inputs.args.includes('--snapshot') && !inputs.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...'); await exec.exec(`${bin} ${inputs.args}${snapshot}`, undefined, {
if (!('GORELEASER_CURRENT_TAG' in process.env)) { env: Object.assign({}, process.env, {
process.env.GORELEASER_CURRENT_TAG = tag; GORELEASER_CURRENT_TAG: process.env.GORELEASER_CURRENT_TAG || tag || ''
}) as {
[key: string]: string;
}
});
if (typeof yamlfile === 'string') {
const artifacts = await goreleaser.getArtifacts(await goreleaser.getDistPath(yamlfile));
if (artifacts) {
await core.group(`Artifacts output`, async () => {
core.info(artifacts);
context.setOutput('artifacts', artifacts);
});
}
const metadata = await goreleaser.getMetadata(await goreleaser.getDistPath(yamlfile));
if (metadata) {
await core.group(`Metadata output`, async () => {
core.info(metadata);
context.setOutput('metadata', metadata);
});
}
} }
await exec.exec(`${goreleaser} ${args}${snapshot}`);
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
} }
-7
View File
@@ -1,7 +0,0 @@
export const suffix = (distribution: string): string => {
return isPro(distribution) ? '-pro' : '';
};
export const isPro = (distribution: string): boolean => {
return distribution === 'goreleaser-pro';
};
+1047 -1209
View File
File diff suppressed because it is too large Load Diff