mirror of
https://github.com/goreleaser/goreleaser-action.git
synced 2026-05-19 00:41:53 +00:00
fix: nightly resolution to select newest published release (#562)
Some checks are pending
ci / ci (goreleaser, macos-latest, latest) (push) Waiting to run
ci / ci (goreleaser, macos-latest, ~> 2.13) (push) Waiting to run
ci / ci (goreleaser, ubuntu-latest, latest) (push) Waiting to run
ci / ci (goreleaser, ubuntu-latest, ~> 2.13) (push) Waiting to run
ci / ci (goreleaser, windows-latest, latest) (push) Waiting to run
ci / ci (goreleaser, windows-latest, ~> 2.13) (push) Waiting to run
ci / ci (goreleaser-pro, macos-latest, latest) (push) Waiting to run
ci / ci (goreleaser-pro, macos-latest, ~> 2.13) (push) Waiting to run
ci / ci (goreleaser-pro, ubuntu-latest, latest) (push) Waiting to run
ci / ci (goreleaser-pro, ubuntu-latest, ~> 2.13) (push) Waiting to run
ci / ci (goreleaser-pro, windows-latest, latest) (push) Waiting to run
ci / ci (goreleaser-pro, windows-latest, ~> 2.13) (push) Waiting to run
ci / install-only (false, goreleaser, latest) (push) Waiting to run
ci / install-only (false, goreleaser, ~> 2.13) (push) Waiting to run
ci / install-only (false, goreleaser-pro, latest) (push) Waiting to run
ci / install-only (false, goreleaser-pro, ~> 2.13) (push) Waiting to run
ci / install-only (true, goreleaser, latest) (push) Waiting to run
ci / install-only (true, goreleaser, ~> 2.13) (push) Waiting to run
ci / install-only (true, goreleaser-pro, latest) (push) Waiting to run
ci / install-only (true, goreleaser-pro, ~> 2.13) (push) Waiting to run
ci / signing (macos-latest) (push) Waiting to run
ci / signing (ubuntu-latest) (push) Waiting to run
ci / signing (windows-latest) (push) Waiting to run
ci / upload-artifact (push) Waiting to run
ci / dist (push) Waiting to run
ci / nightly (goreleaser, macos-latest) (push) Waiting to run
ci / nightly (goreleaser, ubuntu-latest) (push) Waiting to run
ci / nightly (goreleaser, windows-latest) (push) Waiting to run
ci / nightly (goreleaser-pro, macos-latest) (push) Waiting to run
ci / nightly (goreleaser-pro, ubuntu-latest) (push) Waiting to run
ci / nightly (goreleaser-pro, windows-latest) (push) Waiting to run
test / test (push) Waiting to run
validate / lint (push) Waiting to run
validate / build (push) Waiting to run
validate / vendor (push) Waiting to run
Some checks are pending
ci / ci (goreleaser, macos-latest, latest) (push) Waiting to run
ci / ci (goreleaser, macos-latest, ~> 2.13) (push) Waiting to run
ci / ci (goreleaser, ubuntu-latest, latest) (push) Waiting to run
ci / ci (goreleaser, ubuntu-latest, ~> 2.13) (push) Waiting to run
ci / ci (goreleaser, windows-latest, latest) (push) Waiting to run
ci / ci (goreleaser, windows-latest, ~> 2.13) (push) Waiting to run
ci / ci (goreleaser-pro, macos-latest, latest) (push) Waiting to run
ci / ci (goreleaser-pro, macos-latest, ~> 2.13) (push) Waiting to run
ci / ci (goreleaser-pro, ubuntu-latest, latest) (push) Waiting to run
ci / ci (goreleaser-pro, ubuntu-latest, ~> 2.13) (push) Waiting to run
ci / ci (goreleaser-pro, windows-latest, latest) (push) Waiting to run
ci / ci (goreleaser-pro, windows-latest, ~> 2.13) (push) Waiting to run
ci / install-only (false, goreleaser, latest) (push) Waiting to run
ci / install-only (false, goreleaser, ~> 2.13) (push) Waiting to run
ci / install-only (false, goreleaser-pro, latest) (push) Waiting to run
ci / install-only (false, goreleaser-pro, ~> 2.13) (push) Waiting to run
ci / install-only (true, goreleaser, latest) (push) Waiting to run
ci / install-only (true, goreleaser, ~> 2.13) (push) Waiting to run
ci / install-only (true, goreleaser-pro, latest) (push) Waiting to run
ci / install-only (true, goreleaser-pro, ~> 2.13) (push) Waiting to run
ci / signing (macos-latest) (push) Waiting to run
ci / signing (ubuntu-latest) (push) Waiting to run
ci / signing (windows-latest) (push) Waiting to run
ci / upload-artifact (push) Waiting to run
ci / dist (push) Waiting to run
ci / nightly (goreleaser, macos-latest) (push) Waiting to run
ci / nightly (goreleaser, ubuntu-latest) (push) Waiting to run
ci / nightly (goreleaser, windows-latest) (push) Waiting to run
ci / nightly (goreleaser-pro, macos-latest) (push) Waiting to run
ci / nightly (goreleaser-pro, ubuntu-latest) (push) Waiting to run
ci / nightly (goreleaser-pro, windows-latest) (push) Waiting to run
test / test (push) Waiting to run
validate / lint (push) Waiting to run
validate / build (push) Waiting to run
validate / vendor (push) Waiting to run
* fix(nightly): pick latest nightly by published_at GitHub's /releases endpoint is not reliably ordered by published_at, so resolveNightly could pick an older nightly than the most recent one. Filter, sort by published_at desc, and take the first. * test(nightly): add regression coverage for release ordering --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
parent
5cc7ebb73d
commit
5daf1e915a
3 changed files with 23 additions and 2 deletions
|
|
@ -104,3 +104,16 @@ describe('getRelease', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('latestNightlyRelease', () => {
|
||||
it('returns the newest nightly by published_at even when API order is wrong', () => {
|
||||
const release = github.latestNightlyRelease([
|
||||
{tag_name: 'v2.16.0-c9b458fa-nightly', published_at: '2026-05-12T01:27:50Z'},
|
||||
{tag_name: 'v2.16.0-6724de64-nightly', published_at: '2026-05-13T01:32:53Z'},
|
||||
{tag_name: 'v2.16.0-2827930b-nightly', published_at: '2026-05-17T01:34:11Z'},
|
||||
{tag_name: 'v2.15.4', published_at: '2026-04-21T14:07:57Z'}
|
||||
]);
|
||||
|
||||
expect(release?.tag_name).toEqual('v2.16.0-2827930b-nightly');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
2
dist/index.js
generated
vendored
2
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
|
|
@ -28,6 +28,7 @@ const withRetry = async <T>(operation: () => Promise<T>): Promise<T> => {
|
|||
|
||||
export interface GitHubRelease {
|
||||
tag_name: string;
|
||||
published_at?: string;
|
||||
}
|
||||
|
||||
// Matches the new-style nightly release tag pattern: vX.Y.Z-<sha>-nightly
|
||||
|
|
@ -37,6 +38,13 @@ export const isNightlyTag = (tag: string): boolean => {
|
|||
return nightlyTagRegex.test(tag);
|
||||
};
|
||||
|
||||
export const latestNightlyRelease = (releases: Array<GitHubRelease>): GitHubRelease | undefined => {
|
||||
return releases
|
||||
.filter(r => nightlyTagRegex.test(r.tag_name))
|
||||
.sort((a, b) => (b.published_at || '').localeCompare(a.published_at || ''))
|
||||
.shift();
|
||||
};
|
||||
|
||||
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'.");
|
||||
|
|
@ -113,7 +121,7 @@ const resolveNightly = async (distribution: string): Promise<GitHubRelease> => {
|
|||
return <Array<GitHubRelease>>JSON.parse(body);
|
||||
});
|
||||
|
||||
const match = releases.find(r => nightlyTagRegex.test(r.tag_name));
|
||||
const match = latestNightlyRelease(releases);
|
||||
if (!match) {
|
||||
throw new Error(`No '<version>-<sha>-nightly' release found in ${url}`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue