Skip to content

Commit 5daf1e9

Browse files
authored
fix: nightly resolution to select newest published release (#562)
* 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>
1 parent 5cc7ebb commit 5daf1e9

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎__tests__/github.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,16 @@ describe('getRelease', () => {
104104
);
105105
});
106106
});
107+
108+
describe('latestNightlyRelease', () => {
109+
it('returns the newest nightly by published_at even when API order is wrong', () => {
110+
const release = github.latestNightlyRelease([
111+
{tag_name: 'v2.16.0-c9b458fa-nightly', published_at: '2026-05-12T01:27:50Z'},
112+
{tag_name: 'v2.16.0-6724de64-nightly', published_at: '2026-05-13T01:32:53Z'},
113+
{tag_name: 'v2.16.0-2827930b-nightly', published_at: '2026-05-17T01:34:11Z'},
114+
{tag_name: 'v2.15.4', published_at: '2026-04-21T14:07:57Z'}
115+
]);
116+
117+
expect(release?.tag_name).toEqual('v2.16.0-2827930b-nightly');
118+
});
119+
});

‎dist/index.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/github.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const withRetry = async <T>(operation: () => Promise<T>): Promise<T> => {
2828

2929
export interface GitHubRelease {
3030
tag_name: string;
31+
published_at?: string;
3132
}
3233

3334
// Matches the new-style nightly release tag pattern: vX.Y.Z-<sha>-nightly
@@ -37,6 +38,13 @@ export const isNightlyTag = (tag: string): boolean => {
3738
return nightlyTagRegex.test(tag);
3839
};
3940

41+
export const latestNightlyRelease = (releases: Array<GitHubRelease>): GitHubRelease | undefined => {
42+
return releases
43+
.filter(r => nightlyTagRegex.test(r.tag_name))
44+
.sort((a, b) => (b.published_at || '').localeCompare(a.published_at || ''))
45+
.shift();
46+
};
47+
4048
export const getRelease = async (distribution: string, version: string): Promise<GitHubRelease> => {
4149
if (version === 'latest') {
4250
core.warning("You are using 'latest' as default version. Will lock to '~> v2'.");
@@ -113,7 +121,7 @@ const resolveNightly = async (distribution: string): Promise<GitHubRelease> => {
113121
return <Array<GitHubRelease>>JSON.parse(body);
114122
});
115123

116-
const match = releases.find(r => nightlyTagRegex.test(r.tag_name));
124+
const match = latestNightlyRelease(releases);
117125
if (!match) {
118126
throw new Error(`No '<version>-<sha>-nightly' release found in ${url}`);
119127
}

0 commit comments

Comments
 (0)