mirror of
https://github.com/goreleaser/goreleaser-action
synced 2026-06-29 21:29:42 +00:00
fix: do not get releases.json if version is specific (#502)
closes #489
This commit is contained in:
committed by
GitHub
parent
a386515f0c
commit
9a6cd01b33
@@ -86,6 +86,18 @@ describe('getRelease', () => {
|
|||||||
expect(release?.tag_name).toEqual('v2.7.0');
|
expect(release?.tag_name).toEqual('v2.7.0');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('skips JSON check for specific version v2.8.1', async () => {
|
||||||
|
const release = await github.getRelease('goreleaser', 'v2.8.1');
|
||||||
|
expect(release).not.toBeNull();
|
||||||
|
expect(release?.tag_name).toEqual('v2.8.1');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('skips JSON check for specific version without v prefix', async () => {
|
||||||
|
const release = await github.getRelease('goreleaser', '2.8.1');
|
||||||
|
expect(release).not.toBeNull();
|
||||||
|
expect(release?.tag_name).toEqual('v2.8.1');
|
||||||
|
});
|
||||||
|
|
||||||
it('unknown GoReleaser Pro release', async () => {
|
it('unknown GoReleaser Pro release', async () => {
|
||||||
await expect(github.getRelease('goreleaser-pro', 'foo')).rejects.toThrow(
|
await expect(github.getRelease('goreleaser-pro', 'foo')).rejects.toThrow(
|
||||||
new Error('Cannot find GoReleaser release foo in https://goreleaser.com/static/releases-pro.json')
|
new Error('Cannot find GoReleaser release foo in https://goreleaser.com/static/releases-pro.json')
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
@@ -19,6 +19,21 @@ export const getReleaseTag = async (distribution: string, version: string): Prom
|
|||||||
if (version === 'nightly') {
|
if (version === 'nightly') {
|
||||||
return {tag_name: version};
|
return {tag_name: version};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If version is a specific version (not a range), skip the JSON check
|
||||||
|
const cleanVersion: string = cleanTag(version);
|
||||||
|
if (semver.valid(cleanVersion)) {
|
||||||
|
let tag = version.startsWith('v') ? version : `v${version}`;
|
||||||
|
|
||||||
|
// Handle GoReleaser Pro suffix for versions < 2.7.0, but only if not already present
|
||||||
|
// TODO: remove all this `-pro` thing at some point.
|
||||||
|
if (goreleaser.isPro(distribution) && semver.lt(cleanVersion, '2.7.0') && !tag.endsWith('-pro')) {
|
||||||
|
tag = tag + goreleaser.distribSuffix(distribution);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {tag_name: tag};
|
||||||
|
}
|
||||||
|
|
||||||
const tag: string = (await resolveVersion(distribution, version)) || version;
|
const tag: string = (await resolveVersion(distribution, version)) || version;
|
||||||
const suffix: string = goreleaser.distribSuffix(distribution);
|
const suffix: string = goreleaser.distribSuffix(distribution);
|
||||||
const url = `https://goreleaser.com/static/releases${suffix}.json`;
|
const url = `https://goreleaser.com/static/releases${suffix}.json`;
|
||||||
|
|||||||
Reference in New Issue
Block a user