Compare commits

...
21 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
CrazyMax 5e15885530 chore: update changelog 2021-03-31 00:06:25 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>CrazyMaxCrazyMax
748d6973af chore(deps): bump @actions/http-client from 1.0.9 to 1.0.11 (#270)
* chore(deps): bump @actions/http-client from 1.0.9 to 1.0.11

Bumps [@actions/http-client](https://github.com/actions/http-client) from 1.0.9 to 1.0.11.
- [Release notes](https://github.com/actions/http-client/releases)
- [Changelog](https://github.com/actions/http-client/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/http-client/commits)

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 <1951866+crazy-max@users.noreply.github.com>
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-03-30 23:59:14 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
0e0aa65c79 chore(deps): bump y18n from 4.0.0 to 4.0.1 (#272)
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-30 23:51:56 +02:00
b458824747 chore: enhance workflow (#271)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-03-30 23:48:02 +02:00
CrazyMax d8a076a057 Rename Dockerfile 2021-03-18 19:06:55 +01:00
CrazyMax e1c89b9548 Update Dockerfile 2021-03-18 19:05:39 +01:00
CrazyMax e64074c2ea 2021 2021-01-06 21:07:29 +01:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
edea00d0c6 chore(deps): bump node-notifier from 8.0.0 to 8.0.1 (#263)
Bumps [node-notifier](https://github.com/mikaelbr/node-notifier) from 8.0.0 to 8.0.1.
- [Release notes](https://github.com/mikaelbr/node-notifier/releases)
- [Changelog](https://github.com/mikaelbr/node-notifier/blob/v8.0.1/CHANGELOG.md)
- [Commits](https://github.com/mikaelbr/node-notifier/compare/v8.0.0...v8.0.1)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-22 17:41:30 +00:00
CrazyMax 56f5b77f7f Do not overwrite GORELEASER_CURRENT_TAG if already declared (#260) 2020-12-02 16:50:57 +01:00
CrazyMax c1dfc73b78 Fix workflow 2020-12-01 20:41:26 +01:00
CrazyMax 97d4c6b042 Update CI workflow 2020-12-01 20:40:45 +01:00
26 changed files with 443 additions and 219 deletions
+2 -1
View File
@@ -1 +1,2 @@
node_modules /coverage
/node_modules
+15 -7
View File
@@ -3,14 +3,16 @@ name: ci
on: on:
schedule: schedule:
- cron: '0 10 * * *' # everyday at 10am - cron: '0 10 * * *' # everyday at 10am
pull_request:
branches:
- master
- releases/v*
push: push:
branches: branches:
- master - 'master'
- releases/v* - 'releases/v*'
tags:
- 'v*'
pull_request:
branches:
- 'master'
- 'releases/v*'
jobs: jobs:
ci: ci:
@@ -42,12 +44,14 @@ jobs:
with: with:
version: ${{ matrix.version }} version: ${{ matrix.version }}
args: check --debug args: check --debug
workdir: ./test
- -
name: GoReleaser name: GoReleaser
uses: ./ uses: ./
with: with:
version: ${{ matrix.version }} version: ${{ matrix.version }}
args: release --skip-publish --rm-dist args: release --skip-publish --rm-dist
workdir: ./test
install-only: install-only:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -113,6 +117,7 @@ jobs:
with: with:
version: latest version: latest
args: -f .goreleaser-signing.yml check --debug args: -f .goreleaser-signing.yml check --debug
workdir: ./test
env: env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
- -
@@ -121,6 +126,7 @@ jobs:
with: with:
version: latest version: latest
args: -f .goreleaser-signing.yml release --skip-publish --rm-dist args: -f .goreleaser-signing.yml release --skip-publish --rm-dist
workdir: ./test
env: env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
@@ -142,14 +148,16 @@ jobs:
uses: ./ uses: ./
with: with:
args: check --debug args: check --debug
workdir: ./test
- -
name: GoReleaser name: GoReleaser
uses: ./ uses: ./
with: with:
args: release --skip-publish --rm-dist args: release --skip-publish --rm-dist
workdir: ./test
- -
name: Upload assets name: Upload assets
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: myapp name: myapp
path: dist/* path: ./test/dist/*
+11 -32
View File
@@ -3,16 +3,15 @@ name: test
on: on:
push: push:
branches: branches:
- master - 'master'
- releases/v* - 'releases/v*'
paths-ignore:
- '**.md'
pull_request: pull_request:
paths-ignore: branches:
- '**.md' - 'master'
- 'releases/v*'
jobs: jobs:
test-containerized: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- -
@@ -22,36 +21,16 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- -
name: Validate name: Validate
run: docker buildx bake validate uses: docker/bake-action@v1
-
name: Test
run: docker buildx bake test
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macOS-latest
- windows-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
with: with:
fetch-depth: 0 targets: validate
-
name: Install
run: yarn install
- -
name: Test name: Test
run: yarn run test uses: docker/bake-action@v1
with:
targets: test
- -
name: Upload coverage name: Upload coverage
uses: codecov/codecov-action@v1 uses: codecov/codecov-action@v1
if: success()
with: with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage/clover.xml file: ./coverage/clover.xml
+11
View File
@@ -1,5 +1,16 @@
# Changelog # Changelog
## 2.5.0 (2021/03/31)
* Bump y18n from 4.0.0 to 4.0.1 (#272)
* Bump @actions/http-client from 1.0.9 to 1.0.11 (#270)
* Enhance workflow (#271)
* Bump node-notifier from 8.0.0 to 8.0.1 (#263)
## 2.4.1 (2020/12/02)
* Do not overwrite GORELEASER_CURRENT_TAG if already declared (#260)
## 2.4.0 (2020/11/30) ## 2.4.0 (2020/11/30)
* Set GORELEASER_CURRENT_TAG (#259) * Set GORELEASER_CURRENT_TAG (#259)
-46
View File
@@ -1,46 +0,0 @@
#syntax=docker/dockerfile:1.1-experimental
FROM node:12 AS deps
WORKDIR /src
COPY package.json yarn.lock ./
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn \
yarn install
FROM scratch AS update-yarn
COPY --from=deps /src/yarn.lock /
FROM deps AS validate-yarn
COPY .git .git
RUN status=$(git status --porcelain -- yarn.lock); if [ -n "$status" ]; then echo $status; exit 1; fi
FROM deps AS base
COPY . .
FROM base AS build
RUN yarn build
FROM deps AS test
ARG TARGETOS
ARG TARGETARCH
ENV RUNNER_TEMP=/tmp/github_runner
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
COPY . .
RUN yarn run test
FROM base AS run-format
RUN yarn run format
FROM scratch AS format
COPY --from=run-format /src/src/*.ts /src/
FROM base AS validate-format
RUN yarn run format-check
FROM scratch AS dist
COPY --from=build /src/dist/ /dist/
FROM build AS validate-build
RUN status=$(git status --porcelain -- dist); if [ -n "$status" ]; then echo $status; exit 1; fi
FROM base AS dev
ENTRYPOINT ["bash"]
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2019-2020 CrazyMax Copyright (c) 2019-2021 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
+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
+131 -29
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);
@@ -378,7 +391,9 @@ function run() {
} }
} }
core.info('🏃 Running GoReleaser...'); core.info('🏃 Running GoReleaser...');
process.env.GORELEASER_CURRENT_TAG = tag; if (!('GORELEASER_CURRENT_TAG' in process.env)) {
process.env.GORELEASER_CURRENT_TAG = tag;
}
yield exec.exec(`${goreleaser} ${args}${snapshot}`); yield exec.exec(`${goreleaser} ${args}${snapshot}`);
} }
catch (error) { catch (error) {
@@ -391,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);
/** /**
@@ -482,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) {
@@ -491,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);
@@ -565,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.
@@ -576,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.
* *
@@ -587,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;
@@ -728,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));
@@ -766,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
@@ -1875,7 +1975,9 @@ class HttpClient {
maxSockets: maxSockets, maxSockets: maxSockets,
keepAlive: this._keepAlive, keepAlive: this._keepAlive,
proxy: { proxy: {
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`, ...((proxyUrl.username || proxyUrl.password) && {
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
}),
host: proxyUrl.hostname, host: proxyUrl.hostname,
port: proxyUrl.port port: proxyUrl.port
} }
+42 -28
View File
@@ -1,53 +1,67 @@
variable "NODE_VERSION" {
default = "12"
}
target "node-version" {
args = {
NODE_VERSION = NODE_VERSION
}
}
group "default" { group "default" {
targets = ["build"] targets = ["build"]
} }
group "pre-checkin" { group "pre-checkin" {
targets = ["update-yarn", "format", "build"] targets = ["vendor-update", "format", "build"]
} }
group "validate" { group "validate" {
targets = ["validate-format", "validate-build", "validate-yarn"] targets = ["format-validate", "build-validate", "vendor-validate"]
}
target "dockerfile" {
dockerfile = "Dockerfile.dev"
}
target "update-yarn" {
inherits = ["dockerfile"]
target = "update-yarn"
output = ["."]
} }
target "build" { target "build" {
inherits = ["dockerfile"] inherits = ["node-version"]
target = "dist" dockerfile = "./hack/build.Dockerfile"
target = "build-update"
output = ["."] output = ["."]
} }
target "test" { target "build-validate" {
inherits = ["dockerfile"] inherits = ["node-version"]
target = "test" dockerfile = "./hack/build.Dockerfile"
target = "build-validate"
} }
target "format" { target "format" {
inherits = ["dockerfile"] inherits = ["node-version"]
target = "format" dockerfile = "./hack/build.Dockerfile"
target = "format-update"
output = ["."] output = ["."]
} }
target "validate-format" { target "format-validate" {
inherits = ["dockerfile"] inherits = ["node-version"]
target = "validate-format" dockerfile = "./hack/build.Dockerfile"
target = "format-validate"
} }
target "validate-build" { target "vendor-update" {
inherits = ["dockerfile"] inherits = ["node-version"]
target = "validate-build" dockerfile = "./hack/vendor.Dockerfile"
target = "update"
output = ["."]
} }
target "validate-yarn" { target "vendor-validate" {
inherits = ["dockerfile"] inherits = ["node-version"]
target = "validate-yarn" dockerfile = "./hack/vendor.Dockerfile"
target = "validate"
}
target "test" {
inherits = ["node-version"]
dockerfile = "./hack/test.Dockerfile"
target = "test-coverage"
output = ["./coverage"]
} }
+42
View File
@@ -0,0 +1,42 @@
# syntax=docker/dockerfile:1.2
ARG NODE_VERSION
FROM node:${NODE_VERSION}-alpine AS base
RUN apk add --no-cache cpio findutils git
WORKDIR /src
FROM base AS deps
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules \
yarn install
FROM deps AS build
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules \
yarn run build && mkdir /out && cp -Rf dist /out/
FROM scratch AS build-update
COPY --from=build /out /
FROM build AS build-validate
RUN --mount=type=bind,target=.,rw \
git add -A && cp -rf /out/* .; \
if [ -n "$(git status --porcelain -- dist)" ]; then \
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'; \
git status --porcelain -- dist; \
exit 1; \
fi
FROM deps AS format
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules \
yarn run format \
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out
FROM scratch AS format-update
COPY --from=format /out /
FROM deps AS format-validate
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules \
yarn run format-check \
+21
View File
@@ -0,0 +1,21 @@
# syntax=docker/dockerfile:1.2
ARG NODE_VERSION
FROM node:${NODE_VERSION}-alpine AS base
RUN apk add --no-cache git
WORKDIR /src
FROM base AS deps
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules \
yarn install
FROM deps AS test
ENV RUNNER_TEMP=/tmp/github_runner
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules \
yarn run test --coverageDirectory=/tmp/coverage
FROM scratch AS test-coverage
COPY --from=test /tmp/coverage /
+23
View File
@@ -0,0 +1,23 @@
# syntax=docker/dockerfile:1.2
ARG NODE_VERSION
FROM node:${NODE_VERSION}-alpine AS base
RUN apk add --no-cache git
WORKDIR /src
FROM base AS vendored
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules \
yarn install && mkdir /out && cp yarn.lock /out
FROM scratch AS update
COPY --from=vendored /out /
FROM vendored AS validate
RUN --mount=type=bind,target=.,rw \
git add -A && cp -rf /out/* .; \
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then \
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'; \
git status --porcelain -- yarn.lock; \
exit 1; \
fi
+1 -1
View File
@@ -8,7 +8,7 @@ module.exports = {
testEnvironment: 'node', testEnvironment: 'node',
testMatch: ['**/*.test.ts'], testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner', testRunner: 'jest-circus/runner',
testTimeout: 10000, testTimeout: 30000,
transform: { transform: {
'^.+\\.ts$': 'ts-jest' '^.+\\.ts$': 'ts-jest'
}, },
+2 -2
View File
@@ -21,9 +21,9 @@
"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.9", "@actions/http-client": "^1.0.11",
"@actions/tool-cache": "^1.6.1" "@actions/tool-cache": "^1.6.1"
}, },
"devDependencies": { "devDependencies": {
+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);
}; };
+5 -2
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) {
@@ -44,7 +45,9 @@ async function run(): Promise<void> {
} }
core.info('🏃 Running GoReleaser...'); core.info('🏃 Running GoReleaser...');
process.env.GORELEASER_CURRENT_TAG = tag; if (!('GORELEASER_CURRENT_TAG' in process.env)) {
process.env.GORELEASER_CURRENT_TAG = tag;
}
await exec.exec(`${goreleaser} ${args}${snapshot}`); await exec.exec(`${goreleaser} ${args}${snapshot}`);
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
+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';
};
@@ -1,6 +1,5 @@
env: env:
- GO111MODULE=on - GO111MODULE=on
- GOPROXY=https://goproxy.io
before: before:
hooks: hooks:
@@ -26,10 +25,6 @@ archives:
format_overrides: format_overrides:
- goos: windows - goos: windows
format: zip format: zip
files:
- LICENSE
- README.md
- CHANGELOG.md
checksum: checksum:
name_template: 'checksums.txt' name_template: 'checksums.txt'
-5
View File
@@ -1,6 +1,5 @@
env: env:
- GO111MODULE=on - GO111MODULE=on
- GOPROXY=https://goproxy.io
before: before:
hooks: hooks:
@@ -26,10 +25,6 @@ archives:
format_overrides: format_overrides:
- goos: windows - goos: windows
format: zip format: zip
files:
- LICENSE
- README.md
- CHANGELOG.md
checksum: checksum:
name_template: 'checksums.txt' name_template: 'checksums.txt'
View File
View File
+43 -29
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"
@@ -14,10 +14,10 @@
dependencies: dependencies:
"@actions/io" "^1.0.1" "@actions/io" "^1.0.1"
"@actions/http-client@^1.0.8", "@actions/http-client@^1.0.9": "@actions/http-client@^1.0.11", "@actions/http-client@^1.0.8":
version "1.0.9" version "1.0.11"
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.9.tgz#af1947d020043dbc6a3b4c5918892095c30ffb52" resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.11.tgz#c58b12e9aa8b159ee39e7dd6cbd0e91d905633c0"
integrity sha512-0O4SsJ7q+MK0ycvXPl2e6bMXV7dxAXOGjrXS1eTF9s2S401Tp6c/P3c3Joz04QefC1J6Gt942Wl2jbm3f4mLcg== integrity sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==
dependencies: dependencies:
tunnel "0.0.6" tunnel "0.0.6"
@@ -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"
@@ -1788,9 +1788,9 @@ is-descriptor@^1.0.0, is-descriptor@^1.0.2:
kind-of "^6.0.2" kind-of "^6.0.2"
is-docker@^2.0.0: is-docker@^2.0.0:
version "2.0.0" version "2.1.1"
resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.0.0.tgz#2cb0df0e75e2d064fe1864c37cdeacb7b2dcf25b" resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.1.1.tgz#4125a88e44e450d384e09047ede71adc2d144156"
integrity sha512-pJEdRugimx4fBMra5z2/5iRdZ63OhYV0vr0Dwm5+xtW4D1FvRkB8hamMIhnWfyJeDdyr/aa7BDyNbtG38VxgoQ== integrity sha512-ZOoqiXfEwtGknTiuDEy8pN2CfE3TxMHprvNer1mXiqwkOT77Rw3YVrUQ52EqAOU3QAWDQ+bQdx7HJzrv7LS2Hw==
is-extendable@^0.1.0, is-extendable@^0.1.1: is-extendable@^0.1.0, is-extendable@^0.1.1:
version "0.1.1" version "0.1.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"
@@ -2524,6 +2524,13 @@ lru-cache@^4.1.5:
pseudomap "^1.0.2" pseudomap "^1.0.2"
yallist "^2.1.2" yallist "^2.1.2"
lru-cache@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
dependencies:
yallist "^4.0.0"
make-dir@^3.0.0: make-dir@^3.0.0:
version "3.1.0" version "3.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"
@@ -2677,9 +2684,9 @@ node-modules-regexp@^1.0.0:
integrity sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA= integrity sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA=
node-notifier@^8.0.0: node-notifier@^8.0.0:
version "8.0.0" version "8.0.1"
resolved "https://registry.yarnpkg.com/node-notifier/-/node-notifier-8.0.0.tgz#a7eee2d51da6d0f7ff5094bc7108c911240c1620" resolved "https://registry.yarnpkg.com/node-notifier/-/node-notifier-8.0.1.tgz#f86e89bbc925f2b068784b31f382afdc6ca56be1"
integrity sha512-46z7DUmcjoYdaWyXouuFNNfUo6eFa94t23c53c+lG/9Cvauk4a98rAUp9672X5dxGdQmLpPzTxzu8f/OeEPaFA== integrity sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==
dependencies: dependencies:
growly "^1.3.0" growly "^1.3.0"
is-wsl "^2.2.0" is-wsl "^2.2.0"
@@ -3142,9 +3149,11 @@ saxes@^5.0.0:
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
semver@7.x, semver@^7.3.2: semver@7.x, semver@^7.3.2:
version "7.3.2" version "7.3.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97"
integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== integrity sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==
dependencies:
lru-cache "^6.0.0"
semver@^6.0.0, semver@^6.1.0, semver@^6.3.0: semver@^6.0.0, semver@^6.1.0, semver@^6.3.0:
version "6.3.0" version "6.3.0"
@@ -3640,9 +3649,9 @@ uuid@^3.3.2:
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
uuid@^8.3.0: uuid@^8.3.0:
version "8.3.0" version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.0.tgz#ab738085ca22dc9a8c92725e459b1d507df5d6ea" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ== integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
v8-to-istanbul@^5.0.1: v8-to-istanbul@^5.0.1:
version "5.0.1" version "5.0.1"
@@ -3786,15 +3795,20 @@ xmlchars@^2.2.0:
integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw== integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==
y18n@^4.0.0: y18n@^4.0.0:
version "4.0.0" version "4.0.1"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.1.tgz#8db2b83c31c5d75099bb890b23f3094891e247d4"
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== integrity sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==
yallist@^2.1.2: yallist@^2.1.2:
version "2.1.2" version "2.1.2"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"
integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=
yallist@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
yargs-parser@20.x: yargs-parser@20.x:
version "20.2.0" version "20.2.0"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.0.tgz#944791ca2be2e08ddadd3d87e9de4c6484338605" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.0.tgz#944791ca2be2e08ddadd3d87e9de4c6484338605"