Skip to content

Commit

Permalink
feat(datasource/github-releases): skip draft releases (#12856)
Browse files Browse the repository at this point in the history
* feat(datasource/github-releases): skip draft releases

* Apply suggestions from code review

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>

* invert logic

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
  • Loading branch information
3 people committed Nov 27, 2021
1 parent ef51e85 commit c814a9a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 5 additions & 1 deletion lib/datasource/github-releases/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const responseBody = [
{ 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' },
{ tag_name: 'v1.1.0', draft: false, published_at: '2020-03-09T10:00:00Z' },
{ tag_name: '1.2.0', draft: true, published_at: '2020-03-09T10:00:00Z' },
{
tag_name: '2.0.0',
published_at: '2020-04-09T10:00:00Z',
Expand Down Expand Up @@ -47,6 +48,9 @@ describe('datasource/github-releases/index', () => {
expect(
res.releases.find((release) => release.version === 'v1.1.0')
).toBeDefined();
expect(
res.releases.find((release) => release.version === '1.2.0')
).toBeUndefined();
expect(
res.releases.find((release) => release.version === '2.0.0').isStable
).toBeFalse();
Expand Down
8 changes: 4 additions & 4 deletions lib/datasource/github-releases/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ export async function getReleases({
sourceUrl: getSourceUrl(repo, registryUrl),
releases: null,
};
dependency.releases = githubReleases.map(
({ tag_name, published_at, prerelease }) => ({
dependency.releases = githubReleases
.filter(({ draft }) => draft !== true)
.map(({ tag_name, published_at, prerelease }) => ({
version: tag_name,
gitRef: tag_name,
releaseTimestamp: published_at,
isStable: prerelease ? false : undefined,
})
);
}));
const cacheMinutes = 10;
await packageCache.set(cacheNamespace, cacheKey, dependency, cacheMinutes);
return dependency;
Expand Down
1 change: 1 addition & 0 deletions lib/datasource/github-releases/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export type GithubRelease = {
tag_name: string;
published_at: string;
prerelease: boolean;
draft?: boolean;
assets: GithubReleaseAsset[];

html_url: string;
Expand Down

0 comments on commit c814a9a

Please sign in to comment.