diff --git a/lib/datasource/github-releases/__snapshots__/index.spec.ts.snap b/lib/datasource/github-releases/__snapshots__/index.spec.ts.snap index 9eeabf0cc6cf4f9d7be65e98cb72376419eae3ee..b4544ba763a996daf23aebdcd7073233e4b03f8e 100644 --- a/lib/datasource/github-releases/__snapshots__/index.spec.ts.snap +++ b/lib/datasource/github-releases/__snapshots__/index.spec.ts.snap @@ -5,18 +5,22 @@ Object { "releases": Array [ Object { "gitRef": "a", + "releaseTimestamp": "2020-03-09T13:00:00Z", "version": "a", }, Object { "gitRef": "v", + "releaseTimestamp": "2020-03-09T12:00:00Z", "version": "v", }, Object { "gitRef": "1.0.0", + "releaseTimestamp": "2020-03-09T11:00:00Z", "version": "1.0.0", }, Object { "gitRef": "v1.1.0", + "releaseTimestamp": "2020-03-09T10:00:00Z", "version": "v1.1.0", }, ], diff --git a/lib/datasource/github-releases/index.spec.ts b/lib/datasource/github-releases/index.spec.ts index 4213117cfd5ff66e50b525a927ce97e52dafaa0f..8e19d6e1c4721c0ff2eeacdcc5fe1a34decb32d9 100644 --- a/lib/datasource/github-releases/index.spec.ts +++ b/lib/datasource/github-releases/index.spec.ts @@ -14,10 +14,10 @@ describe('datasource/github-releases', () => { beforeAll(() => global.renovateCache.rmAll()); it('returns releases', async () => { const body = [ - { tag_name: 'a' }, - { tag_name: 'v' }, - { tag_name: '1.0.0' }, - { tag_name: 'v1.1.0' }, + { tag_name: 'a', published_at: '2020-03-09T13:00:00Z' }, + { tag_name: 'v', published_at: '2020-03-09T12:00:00Z' }, + { tag_name: '1.0.0', published_at: '2020-03-09T11:00:00Z' }, + { tag_name: 'v1.1.0', published_at: '2020-03-09T10:00:00Z' }, ]; ghGot.mockReturnValueOnce({ headers: {}, body }); const res = await github.getPkgReleases({ diff --git a/lib/datasource/github-releases/index.ts b/lib/datasource/github-releases/index.ts index f57f0434b5c394d5f70b9c9db47bd5ce5b3de97a..02b192b992d55e44ff23e1b30e676a939eb632b0 100644 --- a/lib/datasource/github-releases/index.ts +++ b/lib/datasource/github-releases/index.ts @@ -8,6 +8,11 @@ export const id = 'github-releases'; const cacheNamespace = 'datasource-github-releases'; +type GithubRelease = { + tag_name: string; + published_at: string; +}; + /** * github.getPkgReleases * @@ -21,7 +26,7 @@ const cacheNamespace = 'datasource-github-releases'; export async function getPkgReleases({ lookupName: repo, }: GetReleasesConfig): Promise<ReleaseResult | null> { - let versions: string[]; + let githubReleases: GithubRelease[]; const cachedResult = await renovateCache.get<ReleaseResult>( cacheNamespace, repo @@ -32,29 +37,25 @@ export async function getPkgReleases({ } try { const url = `https://api.github.com/repos/${repo}/releases?per_page=100`; - type GitHubRelease = { - tag_name: string; - }[]; - - versions = ( - await ghGot<GitHubRelease>(url, { - paginate: true, - }) - ).body.map(o => o.tag_name); + const res = await ghGot<GithubRelease[]>(url, { + paginate: true, + }); + githubReleases = res.body; } catch (err) /* istanbul ignore next */ { logger.debug({ repo, err }, 'Error retrieving from github'); } // istanbul ignore if - if (!versions) { + if (!githubReleases) { return null; } const dependency: ReleaseResult = { sourceUrl: 'https://github.com/' + repo, releases: null, }; - dependency.releases = versions.map(version => ({ - version, - gitRef: version, + dependency.releases = githubReleases.map(({ tag_name, published_at }) => ({ + version: tag_name, + gitRef: tag_name, + releaseTimestamp: published_at, })); const cacheMinutes = 10; await renovateCache.set(cacheNamespace, repo, dependency, cacheMinutes);