Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: use "~> v2" as default #463

Merged
merged 5 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion __tests__/github.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {describe, expect, it} from '@jest/globals';
import { describe, expect, it } from '@jest/globals';
import * as github from '../src/github';

describe('getRelease', () => {
Expand Down Expand Up @@ -44,6 +44,18 @@ describe('getRelease', () => {
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();
Expand Down
13 changes: 12 additions & 1 deletion __tests__/goreleaser.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {describe, expect, it} from '@jest/globals';
import { describe, expect, it } from '@jest/globals';
import * as fs from 'fs';
import * as goreleaser from '../src/goreleaser';

Expand Down Expand Up @@ -28,6 +28,17 @@ 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);
Expand Down
5 changes: 2 additions & 3 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ export interface GitHubRelease {
}

export const getRelease = async (distribution: string, version: string): Promise<GitHubRelease> => {
// TODO: change this to ~> v2 on a future major, once goreleaser v2 is out
if (version === 'latest') {
core.warning("You are using 'latest' as default version. Will lock to '~> v1'.");
core.warning("You are using 'latest' as default version. Will lock to '~> v2'.");
return getReleaseTag(distribution, '~> v1');
}
return getReleaseTag(distribution, version);
};

export const getReleaseTag = async (distribution: string, version: string): Promise<GitHubRelease> => {
if (version === 'nightly') {
return {tag_name: version};
return { tag_name: version };
}
const tag: string = (await resolveVersion(distribution, version)) || version;
const suffix: string = goreleaser.distribSuffix(distribution);
Expand Down
Loading