Compare commits

..
2 Commits
Author SHA1 Message Date
Carlos Alexandro Becker b4b0533a52 Merge remote-tracking branch 'origin/master' into semver
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2024-05-08 16:11:17 -03:00
Carlos Alexandro Becker b885aa77a9 feat: warn about using 'latest' 2024-04-27 12:13:40 -03:00
15 changed files with 90 additions and 72 deletions
+8 -8
View File
@@ -48,7 +48,7 @@ jobs:
uses: ./
with:
version: ${{ matrix.version }}
args: check --verbose
args: check --debug
workdir: ./test
-
name: GoReleaser
@@ -59,7 +59,7 @@ jobs:
with:
distribution: ${{ matrix.distribution }}
version: ${{ matrix.version }}
args: release --skip=publish --clean --snapshot
args: release --skip-publish --clean --snapshot
workdir: ./test
install-only:
@@ -96,7 +96,7 @@ jobs:
name: Check
if: ${{ !(github.event_name == 'pull_request' && matrix.distribution == 'goreleaser-pro') }}
run: |
goreleaser check --verbose
goreleaser check --debug
signing:
runs-on: ${{ matrix.os }}
@@ -131,7 +131,7 @@ jobs:
uses: ./
with:
version: latest
args: -f .goreleaser-signing.yml check --verbose
args: -f .goreleaser-signing.yml check --debug
workdir: ./test
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
@@ -140,7 +140,7 @@ jobs:
uses: ./
with:
version: latest
args: -f .goreleaser-signing.yml release --skip=publish --clean --snapshot
args: -f .goreleaser-signing.yml release --skip-publish --clean --snapshot
workdir: ./test
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
@@ -162,13 +162,13 @@ jobs:
name: Check
uses: ./
with:
args: check --verbose
args: check --debug
workdir: ./test
-
name: GoReleaser
uses: ./
with:
args: release --skip=publish --clean --snapshot
args: release --skip-publish --clean --snapshot
workdir: ./test
-
name: Upload assets
@@ -194,7 +194,7 @@ jobs:
name: GoReleaser
uses: ./
with:
args: release --config .goreleaser-dist.yml --skip=publish --clean --snapshot
args: release --config .goreleaser-dist.yml --skip-publish --clean --snapshot
workdir: ./test
-
name: Check dist
+13 -13
View File
@@ -59,15 +59,15 @@ jobs:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v4
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: '~> v2'
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -93,10 +93,10 @@ Or with a condition on GoReleaser step:
```yaml
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
uses: goreleaser/goreleaser-action@v5
if: startsWith(github.ref, 'refs/tags/')
with:
version: '~> v2'
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -119,9 +119,9 @@ the [Import GPG](https://github.com/crazy-max/ghaction-import-gpg) GitHub Action
passphrase: ${{ secrets.PASSPHRASE }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
uses: goreleaser/goreleaser-action@v5
with:
version: '~> v2'
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -144,9 +144,9 @@ purpose. You can do that with the [actions/upload-artifact](https://github.com/a
```yaml
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
uses: goreleaser/goreleaser-action@v5
with:
version: '~> v2'
version: latest
args: release --clean
workdir: myfolder
env:
@@ -165,7 +165,7 @@ purpose. You can do that with the [actions/upload-artifact](https://github.com/a
steps:
-
name: Install GoReleaser
uses: goreleaser/goreleaser-action@v6
uses: goreleaser/goreleaser-action@v5
with:
install-only: true
-
@@ -182,7 +182,7 @@ Following inputs can be used as `step.with` keys
| Name | Type | Default | Description |
|------------------|---------|--------------|------------------------------------------------------------------|
| `distribution` | String | `goreleaser` | GoReleaser distribution, either `goreleaser` or `goreleaser-pro` |
| `version`**¹** | String | `~> v2` | GoReleaser version |
| `version`**¹** | String | `latest` | GoReleaser version |
| `args` | String | | Arguments to pass to GoReleaser |
| `workdir` | String | `.` | Working directory (below repository root) |
| `install-only` | Bool | `false` | Just install GoReleaser |
@@ -219,9 +219,9 @@ secret named `GH_PAT`, the step will look like this:
```yaml
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
uses: goreleaser/goreleaser-action@v5
with:
version: '~> v2'
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
-24
View File
@@ -32,30 +32,6 @@ describe('getRelease', () => {
expect(release?.tag_name).not.toEqual('');
});
it('returns latest v1 GoReleaser Pro GitHub release', async () => {
const release = await github.getRelease('goreleaser-pro', '~> v1');
expect(release).not.toBeNull();
expect(release?.tag_name).not.toEqual('');
});
it('returns latest v1 GoReleaser GitHub release', async () => {
const release = await github.getRelease('goreleaser', '~> v1');
expect(release).not.toBeNull();
expect(release?.tag_name).not.toEqual('');
});
it('returns latest v2 GoReleaser Pro GitHub release', async () => {
const release = await github.getRelease('goreleaser-pro', '~> v2');
expect(release).not.toBeNull();
expect(release?.tag_name).not.toEqual('');
});
it('returns latest v2 GoReleaser GitHub release', async () => {
const release = await github.getRelease('goreleaser', '~> v2');
expect(release).not.toBeNull();
expect(release?.tag_name).not.toEqual('');
});
it('returns nightly GoReleaser GitHub release', async () => {
const release = await github.getRelease('goreleaser', 'nightly');
expect(release).not.toBeNull();
-10
View File
@@ -28,16 +28,6 @@ describe('install', () => {
expect(fs.existsSync(bin)).toBe(true);
}, 100000);
it('acquires latest v2 version of GoReleaser', async () => {
const bin = await goreleaser.install('goreleaser', '~> v2');
expect(fs.existsSync(bin)).toBe(true);
}, 100000);
it('acquires latest v2 version of GoReleaser Pro', async () => {
const bin = await goreleaser.install('goreleaser-pro', '~> v2');
expect(fs.existsSync(bin)).toBe(true);
}, 100000);
it('acquires latest version of GoReleaser Pro', async () => {
const bin = await goreleaser.install('goreleaser-pro', 'latest');
expect(fs.existsSync(bin)).toBe(true);
+1 -1
View File
@@ -13,7 +13,7 @@ inputs:
required: false
version:
description: 'GoReleaser version'
default: '~> v2'
default: 'latest'
required: false
args:
description: 'Arguments to pass to GoReleaser'
Generated Vendored
+3 -3
View File
File diff suppressed because one or more lines are too long
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
Generated Vendored
+38
View File
@@ -258,6 +258,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
lru-cache
ISC
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
require-directory
MIT
The MIT License (MIT)
@@ -422,6 +441,25 @@ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
yallist
ISC
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
yargs
MIT
MIT License
+1 -1
View File
@@ -31,7 +31,7 @@
"@actions/http-client": "^2.2.1",
"@actions/tool-cache": "^2.0.1",
"js-yaml": "^4.1.0",
"semver": "^7.6.2",
"semver": "^7.6.0",
"yargs": "^17.7.2"
},
"devDependencies": {
+1 -1
View File
@@ -15,7 +15,7 @@ export interface Inputs {
export async function getInputs(): Promise<Inputs> {
return {
distribution: core.getInput('distribution') || 'goreleaser',
version: core.getInput('version') || '~> v2',
version: core.getInput('version') || 'latest',
args: core.getInput('args'),
workdir: core.getInput('workdir') || '.',
installOnly: core.getBooleanInput('install-only')
+17 -2
View File
@@ -9,8 +9,10 @@ export interface GitHubRelease {
export const getRelease = async (distribution: string, version: string): Promise<GitHubRelease> => {
if (version === 'latest') {
core.warning("You are using 'latest' as default version. Will lock to '~> v2'.");
return getReleaseTag(distribution, '~> v2');
core.warning(
"You are using 'latest' as default version. This might include breaking changes. It is recommended to use a SemVer to lock to a major version (e.g. ~> v1)."
);
return getLatestRelease(distribution);
}
return getReleaseTag(distribution, version);
};
@@ -39,6 +41,19 @@ export const getReleaseTag = async (distribution: string, version: string): Prom
throw new Error(`Cannot find GoReleaser release ${version}${suffix} in ${url}`);
};
export const getLatestRelease = async (distribution: string): Promise<GitHubRelease> => {
const suffix: string = goreleaser.distribSuffix(distribution);
const url = `https://goreleaser.com/static/latest${suffix}`;
const http: httpm.HttpClient = new httpm.HttpClient('goreleaser-action');
const resp: httpm.HttpClientResponse = await http.get(url);
const body = await resp.readBody();
const statusCode = resp.message.statusCode || 500;
if (statusCode >= 400) {
throw new Error(`Failed to get GoReleaser release latest from ${url} with status code ${statusCode}: ${body}`);
}
return {tag_name: body};
};
const resolveVersion = async (distribution: string, version: string): Promise<string | null> => {
const allTags: Array<string> | null = await getAllTags(distribution);
if (!allTags) {
-1
View File
@@ -1,4 +1,3 @@
version: 2
env:
- GO111MODULE=on
-1
View File
@@ -1,4 +1,3 @@
version: 2
env:
- GO111MODULE=on
-1
View File
@@ -1,4 +1,3 @@
version: 2
env:
- GO111MODULE=on
+7 -5
View File
@@ -3105,7 +3105,7 @@ __metadata:
jest: ^29.6.4
js-yaml: ^4.1.0
prettier: ^3.0.3
semver: ^7.6.2
semver: ^7.6.0
tmp: ^0.2.1
ts-jest: ^29.1.1
ts-node: ^10.9.1
@@ -4895,12 +4895,14 @@ __metadata:
languageName: node
linkType: hard
"semver@npm:^7.6.2":
version: 7.6.2
resolution: "semver@npm:7.6.2"
"semver@npm:^7.6.0":
version: 7.6.0
resolution: "semver@npm:7.6.0"
dependencies:
lru-cache: ^6.0.0
bin:
semver: bin/semver.js
checksum: 40f6a95101e8d854357a644da1b8dd9d93ce786d5c6a77227bc69dbb17bea83d0d1d1d7c4cd5920a6df909f48e8bd8a5909869535007f90278289f2451d0292d
checksum: 7427f05b70786c696640edc29fdd4bc33b2acf3bbe1740b955029044f80575fc664e1a512e4113c3af21e767154a94b4aa214bf6cd6e42a1f6dba5914e0b208c
languageName: node
linkType: hard