fix: accept nightly tags without 'v' prefix

goreleaser-pro publishes nightly releases as e.g. 2.16.0-eaeb08c50-nightly
(no 'v' prefix). Make the nightly tag regex tolerate either form, and
split the integration tests so OSS asserts the legacy fallback while
Pro asserts the new <version>-<sha>-nightly format.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2026-04-26 15:32:45 -03:00
parent 2c8756b88a
commit 7673f7fb5b
No known key found for this signature in database
4 changed files with 11 additions and 8 deletions

View file

@ -56,16 +56,18 @@ describe('getRelease', () => {
expect(release?.tag_name).not.toEqual(''); expect(release?.tag_name).not.toEqual('');
}); });
it('resolves nightly to a vX.Y.Z-<sha>-nightly GoReleaser release', async () => { it('resolves nightly to the legacy nightly tag for OSS GoReleaser', async () => {
// No <version>-<sha>-nightly release exists in goreleaser/goreleaser yet,
// so this should fall back to the legacy moving `nightly` tag.
const release = await github.getRelease('goreleaser', 'nightly'); const release = await github.getRelease('goreleaser', 'nightly');
expect(release).not.toBeNull(); expect(release).not.toBeNull();
expect(github.isNightlyTag(release.tag_name)).toBe(true); expect(release.tag_name).toEqual('nightly');
}); });
it('resolves nightly to a vX.Y.Z-<sha>-nightly GoReleaser Pro release', async () => { it('resolves nightly to a <version>-<sha>-nightly release for GoReleaser Pro', async () => {
const release = await github.getRelease('goreleaser-pro', 'nightly'); const release = await github.getRelease('goreleaser-pro', 'nightly');
expect(release).not.toBeNull(); expect(release).not.toBeNull();
expect(github.isNightlyTag(release.tag_name)).toBe(true); expect(release.tag_name).toMatch(github.nightlyTagRegex);
}); });
it('returns v0.182.0 GoReleaser Pro GitHub release', async () => { it('returns v0.182.0 GoReleaser Pro GitHub release', async () => {

View file

@ -123,7 +123,7 @@ describe('getCertificateIdentity', () => {
}); });
it('uses nightly-pro.yml@refs/heads/main for Pro nightly tag', () => { it('uses nightly-pro.yml@refs/heads/main for Pro nightly tag', () => {
expect(goreleaser.getCertificateIdentity('goreleaser-pro', 'v2.16.0-abc1234-nightly')).toEqual( expect(goreleaser.getCertificateIdentity('goreleaser-pro', '2.16.0-eaeb08c50-nightly')).toEqual(
'https://github.com/goreleaser/goreleaser-pro-internal/.github/workflows/nightly-pro.yml@refs/heads/main' 'https://github.com/goreleaser/goreleaser-pro-internal/.github/workflows/nightly-pro.yml@refs/heads/main'
); );
}); });

2
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

View file

@ -30,8 +30,9 @@ export interface GitHubRelease {
tag_name: string; tag_name: string;
} }
// Matches the new-style nightly release tag pattern: vX.Y.Z-<sha>-nightly // Matches the new-style nightly release tag pattern: [v]X.Y.Z-<sha>-nightly
export const nightlyTagRegex = /^v\d+\.\d+\.\d+-[0-9a-f]+-nightly$/i; // (the `v` prefix is optional — goreleaser-pro tags don't have it).
export const nightlyTagRegex = /^v?\d+\.\d+\.\d+-[0-9a-f]+-nightly$/i;
export const isNightlyTag = (tag: string): boolean => { export const isNightlyTag = (tag: string): boolean => {
return tag === 'nightly' || nightlyTagRegex.test(tag); return tag === 'nightly' || nightlyTagRegex.test(tag);