Compare commits

...
10 Commits
Author SHA1 Message Date
Carlos Alexandro BeckerandGitHub 70eb4e573c feat: support downloading goreleaser pro (#284) 2021-05-27 00:25:31 -03:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>CrazyMax
a3b2f49e7c chore(deps): bump @actions/core from 1.2.7 to 1.3.0 (#283)
* chore(deps): bump @actions/core from 1.2.7 to 1.3.0

Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.7 to 1.3.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)

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-05-24 19:06:23 +02:00
8571fa911c fix(ci): pin actions to major (#282)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-05-12 15:26:14 -03:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
a604a9b2f7 chore(deps): bump crazy-max/ghaction-import-gpg from 3 to 3.1.0 (#277)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-12 10:14:55 -03:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
239f064349 chore(deps): bump actions/checkout from 2 to 2.3.4 (#278)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 2.3.4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v2.3.4)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-12 10:11:27 -03:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
ab4f17620b chore(deps): bump codecov/codecov-action from 1 to 1.5.0 (#279)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 1 to 1.5.0.
- [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...v1.5.0)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-12 10:11:15 -03:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
15c488ce8f chore(deps): bump docker/bake-action from 1 to 1.4.0 (#280)
Bumps [docker/bake-action](https://github.com/docker/bake-action) from 1 to 1.4.0.
- [Release notes](https://github.com/docker/bake-action/releases)
- [Commits](https://github.com/docker/bake-action/compare/v1...v1.4.0)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-12 10:11:03 -03:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
f08023819a chore(deps): bump hosted-git-info from 2.8.8 to 2.8.9 (#276)
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-11 19:14:08 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
4921ce3062 chore(deps): bump lodash from 4.17.19 to 4.17.21 (#275)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.19...4.17.21)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-11 19:11:28 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>CrazyMax
6b584eeb7a chore(deps): bump @actions/core from 1.2.6 to 1.2.7 (#273)
* chore(deps): bump @actions/core from 1.2.6 to 1.2.7

Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.6 to 1.2.7.
- [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)

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

* chore: 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-04-16 11:58:36 +02:00
11 changed files with 231 additions and 70 deletions
+17 -11
View File
@@ -57,10 +57,14 @@ jobs:
name: Run GoReleaser name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2 uses: goreleaser/goreleaser-action@v2
with: with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest version: latest
args: release --rm-dist args: release --rm-dist
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
``` ```
> **IMPORTANT**: note the `fetch-depth: 0` input in `Checkout` step. It is required for the changelog to work correctly. > **IMPORTANT**: note the `fetch-depth: 0` input in `Checkout` step. It is required for the changelog to work correctly.
@@ -165,12 +169,13 @@ steps:
Following inputs can be used as `step.with` keys Following inputs can be used as `step.with` keys
| Name | Type | Default | Description | | Name | Type | Default | Description |
|------------------|---------|-----------|-------------------------------------------| |------------------|---------|--------------|------------------------------------------------------------------|
| `version`**¹** | String | `latest` | GoReleaser version | | `distribution` | String | `goreleaser` | GoReleaser distribution, either `goreleaser` or `goreleaser-pro` |
| `args` | String | | Arguments to pass to GoReleaser | | `version`**¹** | String | `latest` | GoReleaser version |
| `workdir` | String | `.` | Working directory (below repository root) | | `args` | String | | Arguments to pass to GoReleaser |
| `install-only` | Bool | `false` | Just install GoReleaser | | `workdir` | String | `.` | Working directory (below repository root) |
| `install-only` | Bool | `false` | Just install GoReleaser |
> **¹** 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`.
@@ -178,17 +183,18 @@ Following inputs can be used as `step.with` keys
Following environment variables can be used as `step.env` keys Following environment variables can be used as `step.env` keys
| Name | Description | | Name | Description |
|----------------|---------------------------------------| |------------------|---------------------------------------|
| `GITHUB_TOKEN` | [GITHUB_TOKEN](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token) as provided by `secrets` | | `GITHUB_TOKEN` | [GITHUB_TOKEN](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token) as provided by `secrets` |
| `GORELEASER_KEY` | Your [GoReleaser Pro](https://goreleaser.com/pro) License Key, in case you are using the `goreleaser-pro` distribution |
## Limitation ## Limitation
`GITHUB_TOKEN` permissions [are limited to the repository](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#about-the-github_token-secret) `GITHUB_TOKEN` permissions [are limited to the repository](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#about-the-github_token-secret)
that contains your workflow. that contains your workflow.
If you need to push the homebrew tap to another repository, you must therefore create a custom [Personal Access Token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/) If you need to push the homebrew tap to another repository, you must therefore create a custom [Personal Access Token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/)
with `repo` permissions and [add it as a secret in the repository](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets). If you create a with `repo` permissions and [add it as a secret in the repository](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets). If you create a
secret named `GH_PAT`, the step will look like this: secret named `GH_PAT`, the step will look like this:
```yaml ```yaml
+18 -4
View File
@@ -2,19 +2,33 @@ import * as github from '../src/github';
describe('github', () => { describe('github', () => {
it('returns latest GoReleaser GitHub release', async () => { it('returns latest GoReleaser GitHub release', async () => {
const release = await github.getRelease('latest'); const release = await github.getRelease('goreleaser', 'latest');
expect(release).not.toBeNull(); expect(release).not.toBeNull();
expect(release?.tag_name).not.toEqual(''); expect(release?.tag_name).not.toEqual('');
console.log(`tag_name: ${release?.tag_name}`);
}); });
it('returns v0.117.0 GoReleaser GitHub release', async () => { it('returns v0.117.0 GoReleaser GitHub release', async () => {
const release = await github.getRelease('v0.117.0'); const release = await github.getRelease('goreleaser', 'v0.117.0');
expect(release).not.toBeNull(); expect(release).not.toBeNull();
expect(release?.tag_name).toEqual('v0.117.0'); expect(release?.tag_name).toEqual('v0.117.0');
}); });
it('returns v0.132.1 GoReleaser GitHub release', async () => { it('returns v0.132.1 GoReleaser GitHub release', async () => {
const release = await github.getRelease('~> 0.132'); const release = await github.getRelease('goreleaser', '~> 0.132');
expect(release).not.toBeNull(); expect(release).not.toBeNull();
expect(release?.tag_name).toEqual('v0.132.1'); expect(release?.tag_name).toEqual('v0.132.1');
}); });
it('returns latest GoReleaser Pro GitHub release', async () => {
const release = await github.getRelease('goreleaser-pro', 'latest');
expect(release).not.toBeNull();
expect(release?.tag_name).not.toEqual('');
});
it('returns v0.166.0-pro GoReleaser Pro GitHub release', async () => {
const release = await github.getRelease('goreleaser-pro', 'v0.166.0-pro');
expect(release).not.toBeNull();
expect(release?.tag_name).toEqual('v0.166.0-pro');
});
it('returns v0.166.0-pro GoReleaser Pro GitHub release when using semver', async () => {
const release = await github.getRelease('goreleaser-pro', '~> 0.166');
expect(release).not.toBeNull();
expect(release?.tag_name).toEqual('v0.166.0-pro');
});
}); });
+12 -2
View File
@@ -3,12 +3,22 @@ import * as installer from '../src/installer';
describe('installer', () => { describe('installer', () => {
it('acquires v0.117.0 version of GoReleaser', async () => { it('acquires v0.117.0 version of GoReleaser', async () => {
const goreleaser = await installer.getGoReleaser('v0.117.0'); const goreleaser = await installer.getGoReleaser('goreleaser', 'v0.117.0');
expect(fs.existsSync(goreleaser)).toBe(true); expect(fs.existsSync(goreleaser)).toBe(true);
}, 100000); }, 100000);
it('acquires latest version of GoReleaser', async () => { it('acquires latest version of GoReleaser', async () => {
const goreleaser = await installer.getGoReleaser('latest'); 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); expect(fs.existsSync(goreleaser)).toBe(true);
}, 100000); }, 100000);
}); });
+10
View File
@@ -0,0 +1,10 @@
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('');
});
});
Generated Vendored
+125 -27
View File
@@ -190,23 +190,30 @@ exports.getRelease = void 0;
const httpm = __importStar(__webpack_require__(925)); const httpm = __importStar(__webpack_require__(925));
const core = __importStar(__webpack_require__(186)); const core = __importStar(__webpack_require__(186));
const semver = __importStar(__webpack_require__(911)); const semver = __importStar(__webpack_require__(911));
exports.getRelease = (version) => __awaiter(void 0, void 0, void 0, function* () { const pro = __importStar(__webpack_require__(989));
const resolvedVersion = (yield resolveVersion(version)) || version; exports.getRelease = (distribution, version) => __awaiter(void 0, void 0, void 0, function* () {
const url = `https://github.com/goreleaser/goreleaser/releases/${resolvedVersion}`; const resolvedVersion = (yield resolveVersion(distribution, version)) || version;
const url = `https://github.com/goreleaser/${distribution}/releases/${resolvedVersion}`;
const http = new httpm.HttpClient('goreleaser-action'); const http = new httpm.HttpClient('goreleaser-action');
return (yield http.getJson(url)).result; return (yield http.getJson(url)).result;
}); });
const resolveVersion = (version) => __awaiter(void 0, void 0, void 0, function* () { const resolveVersion = (distribution, version) => __awaiter(void 0, void 0, void 0, function* () {
const allTags = yield getAllTags(); const allTags = yield getAllTags(distribution);
if (!allTags) { if (!allTags) {
throw new Error(`Cannot find GoReleaser tags`); throw new Error(`Cannot find GoReleaser tags`);
} }
core.debug(`Found ${allTags.length} tags in total`); core.debug(`Found ${allTags.length} tags in total`);
return semver.maxSatisfying(allTags, version); if (version === 'latest' || !pro.isPro(distribution)) {
return semver.maxSatisfying(allTags, version);
}
const cleanTags = allTags.map(tag => cleanTag(tag));
const cleanVersion = cleanTag(version);
return semver.maxSatisfying(cleanTags, cleanVersion) + pro.suffix(distribution);
}); });
const getAllTags = () => __awaiter(void 0, void 0, void 0, function* () { const getAllTags = (distribution) => __awaiter(void 0, void 0, void 0, function* () {
const http = new httpm.HttpClient('goreleaser-action'); const http = new httpm.HttpClient('goreleaser-action');
const url = `https://goreleaser.com/static/releases.json`; const suffix = pro.suffix(distribution);
const url = `https://goreleaser.com/static/releases${suffix}.json`;
const getTags = http.getJson(url); const getTags = http.getJson(url);
return getTags.then(response => { return getTags.then(response => {
if (response.result == null) { if (response.result == null) {
@@ -215,6 +222,9 @@ const getAllTags = () => __awaiter(void 0, void 0, void 0, function* () {
return response.result.map(obj => obj.tag_name); return response.result.map(obj => obj.tag_name);
}); });
}); });
const cleanTag = (tag) => {
return tag.replace(/-pro$/, '');
};
//# sourceMappingURL=github.js.map //# sourceMappingURL=github.js.map
/***/ }), /***/ }),
@@ -258,19 +268,20 @@ const os = __importStar(__webpack_require__(87));
const path = __importStar(__webpack_require__(622)); const path = __importStar(__webpack_require__(622));
const util = __importStar(__webpack_require__(669)); const util = __importStar(__webpack_require__(669));
const github = __importStar(__webpack_require__(928)); const github = __importStar(__webpack_require__(928));
const pro = __importStar(__webpack_require__(989));
const core = __importStar(__webpack_require__(186)); const core = __importStar(__webpack_require__(186));
const tc = __importStar(__webpack_require__(784)); const tc = __importStar(__webpack_require__(784));
const osPlat = os.platform(); const osPlat = os.platform();
const osArch = os.arch(); const osArch = os.arch();
function getGoReleaser(version) { function getGoReleaser(distribution, version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const release = yield github.getRelease(version); const release = yield github.getRelease(distribution, version);
if (!release) { if (!release) {
throw new Error(`Cannot find GoReleaser ${version} release`); throw new Error(`Cannot find GoReleaser ${version} release`);
} }
core.info(`✅ GoReleaser version found: ${release.tag_name}`); core.info(`✅ GoReleaser version found: ${release.tag_name}`);
const filename = getFilename(); const filename = getFilename(distribution);
const downloadUrl = util.format('https://github.com/goreleaser/goreleaser/releases/download/%s/%s', release.tag_name, filename); const downloadUrl = util.format('https://github.com/goreleaser/%s/releases/download/%s/%s', distribution, release.tag_name, filename);
core.info(`⬇️ Downloading ${downloadUrl}...`); core.info(`⬇️ Downloading ${downloadUrl}...`);
const downloadPath = yield tc.downloadTool(downloadUrl); const downloadPath = yield tc.downloadTool(downloadUrl);
core.debug(`Downloaded to ${downloadPath}`); core.debug(`Downloaded to ${downloadPath}`);
@@ -291,11 +302,12 @@ function getGoReleaser(version) {
}); });
} }
exports.getGoReleaser = getGoReleaser; exports.getGoReleaser = getGoReleaser;
const getFilename = () => { const getFilename = (distribution) => {
const platform = osPlat == 'win32' ? 'Windows' : osPlat == 'darwin' ? 'Darwin' : 'Linux'; const platform = osPlat == 'win32' ? 'Windows' : osPlat == 'darwin' ? 'Darwin' : 'Linux';
const arch = osArch == 'x64' ? 'x86_64' : 'i386'; const arch = osArch == 'x64' ? 'x86_64' : 'i386';
const ext = osPlat == 'win32' ? 'zip' : 'tar.gz'; const ext = osPlat == 'win32' ? 'zip' : 'tar.gz';
return util.format('goreleaser_%s_%s.%s', platform, arch, ext); const suffix = pro.suffix(distribution);
return util.format('goreleaser%s_%s_%s.%s', suffix, platform, arch, ext);
}; };
//# sourceMappingURL=installer.js.map //# sourceMappingURL=installer.js.map
@@ -343,11 +355,12 @@ const path_1 = __webpack_require__(622);
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
const distribution = core.getInput('distribution') || 'goreleaser';
const version = core.getInput('version') || 'latest'; const version = core.getInput('version') || 'latest';
const args = core.getInput('args'); const args = core.getInput('args');
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 = yield installer.getGoReleaser(version); const goreleaser = yield installer.getGoReleaser(distribution, version);
core.info(`✅ GoReleaser installed successfully`); core.info(`✅ GoReleaser installed successfully`);
if (isInstallOnly) { if (isInstallOnly) {
const goreleaserDir = path_1.dirname(goreleaser); const goreleaserDir = path_1.dirname(goreleaser);
@@ -393,19 +406,49 @@ run();
/***/ }), /***/ }),
/***/ 989:
/***/ ((__unused_webpack_module, exports) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.isPro = exports.suffix = void 0;
exports.suffix = (distribution) => {
return exports.isPro(distribution) ? '-pro' : '';
};
exports.isPro = (distribution) => {
return distribution === 'goreleaser-pro';
};
//# sourceMappingURL=pro.js.map
/***/ }),
/***/ 241: /***/ 241:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) { /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
result["default"] = mod; __setModuleDefault(result, mod);
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.issue = exports.issueCommand = void 0;
const os = __importStar(__webpack_require__(87)); const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(278); const utils_1 = __webpack_require__(278);
/** /**
@@ -484,6 +527,25 @@ function escapeProperty(s) {
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
@@ -493,14 +555,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
const command_1 = __webpack_require__(241); const command_1 = __webpack_require__(241);
const file_command_1 = __webpack_require__(717); const file_command_1 = __webpack_require__(717);
const utils_1 = __webpack_require__(278); const utils_1 = __webpack_require__(278);
@@ -567,7 +623,9 @@ function addPath(inputPath) {
} }
exports.addPath = addPath; exports.addPath = addPath;
/** /**
* Gets the value of an input. The value is also trimmed. * Gets the value of an input.
* Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
* Returns an empty string if the value is not defined.
* *
* @param name name of the input to get * @param name name of the input to get
* @param options optional. See InputOptions. * @param options optional. See InputOptions.
@@ -578,9 +636,34 @@ function getInput(name, options) {
if (options && options.required && !val) { if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`); throw new Error(`Input required and not supplied: ${name}`);
} }
if (options && options.trimWhitespace === false) {
return val;
}
return val.trim(); return val.trim();
} }
exports.getInput = getInput; exports.getInput = getInput;
/**
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
* Support boolean input list: `true | True | TRUE | false | False | FALSE` .
* The return value is also in boolean type.
* ref: https://yaml.org/spec/1.2/spec.html#id2804923
*
* @param name name of the input to get
* @param options optional. See InputOptions.
* @returns boolean
*/
function getBooleanInput(name, options) {
const trueValue = ['true', 'True', 'TRUE'];
const falseValue = ['false', 'False', 'FALSE'];
const val = getInput(name, options);
if (trueValue.includes(val))
return true;
if (falseValue.includes(val))
return false;
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` +
`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
}
exports.getBooleanInput = getBooleanInput;
/** /**
* Sets the value of an output. * Sets the value of an output.
* *
@@ -589,6 +672,7 @@ exports.getInput = getInput;
*/ */
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
function setOutput(name, value) { function setOutput(name, value) {
process.stdout.write(os.EOL);
command_1.issueCommand('set-output', { name }, value); command_1.issueCommand('set-output', { name }, value);
} }
exports.setOutput = setOutput; exports.setOutput = setOutput;
@@ -730,14 +814,27 @@ exports.getState = getState;
"use strict"; "use strict";
// For internal use, subject to change. // For internal use, subject to change.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
result["default"] = mod; __setModuleDefault(result, mod);
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.issueCommand = void 0;
// We use any as a valid input type // We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
const fs = __importStar(__webpack_require__(747)); const fs = __importStar(__webpack_require__(747));
@@ -768,6 +865,7 @@ exports.issueCommand = issueCommand;
// We use any as a valid input type // We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.toCommandValue = void 0;
/** /**
* Sanitizes an input into a string so it can be passed into issueCommand safely * Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string * @param input input to sanitize into a string
+1 -1
View File
@@ -21,7 +21,7 @@
"author": "CrazyMax", "author": "CrazyMax",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.3.0",
"@actions/exec": "^1.0.4", "@actions/exec": "^1.0.4",
"@actions/http-client": "^1.0.11", "@actions/http-client": "^1.0.11",
"@actions/tool-cache": "^1.6.1" "@actions/tool-cache": "^1.6.1"
+20 -8
View File
@@ -1,36 +1,44 @@
import * as httpm from '@actions/http-client'; import * as httpm from '@actions/http-client';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as semver from 'semver'; import * as semver from 'semver';
import * as pro from './pro';
export interface GitHubRelease { export interface GitHubRelease {
id: number; id: number;
tag_name: string; tag_name: string;
} }
export const getRelease = async (version: string): Promise<GitHubRelease | null> => { export const getRelease = async (distribution: string, version: string): Promise<GitHubRelease | null> => {
const resolvedVersion: string = (await resolveVersion(version)) || version; const resolvedVersion: string = (await resolveVersion(distribution, version)) || version;
const url: string = `https://github.com/goreleaser/goreleaser/releases/${resolvedVersion}`; const url: string = `https://github.com/goreleaser/${distribution}/releases/${resolvedVersion}`;
const http: httpm.HttpClient = new httpm.HttpClient('goreleaser-action'); const http: httpm.HttpClient = new httpm.HttpClient('goreleaser-action');
return (await http.getJson<GitHubRelease>(url)).result; return (await http.getJson<GitHubRelease>(url)).result;
}; };
const resolveVersion = async (version: string): Promise<string | null> => { const resolveVersion = async (distribution: string, version: string): Promise<string | null> => {
const allTags: Array<string> | null = await getAllTags(); const allTags: Array<string> | null = await getAllTags(distribution);
if (!allTags) { if (!allTags) {
throw new Error(`Cannot find GoReleaser tags`); throw new Error(`Cannot find GoReleaser tags`);
} }
core.debug(`Found ${allTags.length} tags in total`); core.debug(`Found ${allTags.length} tags in total`);
return semver.maxSatisfying(allTags, version); if (version === 'latest' || !pro.isPro(distribution)) {
return semver.maxSatisfying(allTags, version);
}
const cleanTags: Array<string> = allTags.map(tag => cleanTag(tag));
const cleanVersion: string = cleanTag(version);
return semver.maxSatisfying(cleanTags, cleanVersion) + pro.suffix(distribution);
}; };
interface GitHubTag { interface GitHubTag {
tag_name: string; tag_name: string;
} }
const getAllTags = async (): 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 url: string = `https://goreleaser.com/static/releases.json`; const suffix: string = pro.suffix(distribution);
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 => {
@@ -41,3 +49,7 @@ const getAllTags = async (): Promise<Array<string>> => {
return response.result.map(obj => obj.tag_name); return response.result.map(obj => obj.tag_name);
}); });
}; };
const cleanTag = (tag: string): string => {
return tag.replace(/-pro$/, '');
};
+9 -6
View File
@@ -2,22 +2,24 @@ import * as os from 'os';
import * as path from 'path'; import * as path from 'path';
import * as util from 'util'; import * as util from 'util';
import * as github from './github'; import * as github from './github';
import * as pro from './pro';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
const osPlat: string = os.platform(); const osPlat: string = os.platform();
const osArch: string = os.arch(); const osArch: string = os.arch();
export async function getGoReleaser(version: string): Promise<string> { export async function getGoReleaser(distribution: string, version: string): Promise<string> {
const release: github.GitHubRelease | null = await github.getRelease(version); const release: github.GitHubRelease | null = await github.getRelease(distribution, version);
if (!release) { if (!release) {
throw new Error(`Cannot find GoReleaser ${version} release`); throw new Error(`Cannot find GoReleaser ${version} release`);
} }
core.info(`✅ GoReleaser version found: ${release.tag_name}`); core.info(`✅ GoReleaser version found: ${release.tag_name}`);
const filename = getFilename(); const filename = getFilename(distribution);
const downloadUrl = util.format( const downloadUrl = util.format(
'https://github.com/goreleaser/goreleaser/releases/download/%s/%s', 'https://github.com/goreleaser/%s/releases/download/%s/%s',
distribution,
release.tag_name, release.tag_name,
filename filename
); );
@@ -44,9 +46,10 @@ export async function getGoReleaser(version: string): Promise<string> {
return exePath; return exePath;
} }
const getFilename = (): string => { const getFilename = (distribution: string): string => {
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 arch: string = osArch == 'x64' ? 'x86_64' : 'i386';
const ext: string = osPlat == 'win32' ? 'zip' : 'tar.gz'; const ext: string = osPlat == 'win32' ? 'zip' : 'tar.gz';
return util.format('goreleaser_%s_%s.%s', platform, arch, ext); const suffix: string = pro.suffix(distribution);
return util.format('goreleaser%s_%s_%s.%s', suffix, platform, arch, ext);
}; };
+2 -1
View File
@@ -6,11 +6,12 @@ import {dirname} from 'path';
async function run(): Promise<void> { async function run(): Promise<void> {
try { try {
const distribution = core.getInput('distribution') || 'goreleaser';
const version = core.getInput('version') || 'latest'; const version = core.getInput('version') || 'latest';
const args = core.getInput('args'); const args = core.getInput('args');
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(version); const goreleaser = await installer.getGoReleaser(distribution, version);
core.info(`✅ GoReleaser installed successfully`); core.info(`✅ GoReleaser installed successfully`);
if (isInstallOnly) { if (isInstallOnly) {
+7
View File
@@ -0,0 +1,7 @@
export const suffix = (distribution: string): string => {
return isPro(distribution) ? '-pro' : '';
};
export const isPro = (distribution: string): boolean => {
return distribution === 'goreleaser-pro';
};
+10 -10
View File
@@ -2,10 +2,10 @@
# yarn lockfile v1 # yarn lockfile v1
"@actions/core@^1.2.6": "@actions/core@^1.2.6", "@actions/core@^1.3.0":
version "1.2.6" version "1.3.0"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.6.tgz#a78d49f41a4def18e88ce47c2cac615d5694bf09" resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.3.0.tgz#f5e4b24c889e7f2e58b466cc8c7481292284eba0"
integrity sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA== integrity sha512-xxtX0Cwdhb8LcgatfJkokqT8KzPvcIbwL9xpLU09nOwBzaStbfm0dNncsP0M4us+EpoPdWy7vbzU5vSOH7K6pg==
"@actions/exec@^1.0.0", "@actions/exec@^1.0.4": "@actions/exec@^1.0.0", "@actions/exec@^1.0.4":
version "1.0.4" version "1.0.4"
@@ -1656,9 +1656,9 @@ has-values@^1.0.0:
kind-of "^4.0.0" kind-of "^4.0.0"
hosted-git-info@^2.1.4: hosted-git-info@^2.1.4:
version "2.8.8" version "2.8.9"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg== integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==
html-encoding-sniffer@^2.0.1: html-encoding-sniffer@^2.0.1:
version "2.0.1" version "2.0.1"
@@ -2512,9 +2512,9 @@ lodash.sortby@^4.7.0:
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
lodash@^4.17.13, lodash@^4.17.15: lodash@^4.17.13, lodash@^4.17.15:
version "4.17.19" version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
lru-cache@^4.1.5: lru-cache@^4.1.5:
version "4.1.5" version "4.1.5"