Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions packages/hadron-build/commands/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const path = require('path');
const os = require('os');
const { promises: fs } = require('fs');
const { deepStrictEqual } = require('assert');
const semver = require('semver');
const { Octokit } = require('@octokit/rest');
const { GithubRepo } = require('@mongodb-js/devtools-github-repo');
const { diffString } = require('json-diff');
Expand Down Expand Up @@ -253,7 +254,7 @@ async function getLatestRelease(channel = 'stable') {
auth: process.env.GITHUB_TOKEN,
});

const page = 1;
let page = 1;

// eslint-disable-next-line no-constant-condition
while (true) {
Expand All @@ -279,14 +280,24 @@ async function getLatestRelease(channel = 'stable') {
return null;
}

const latestRelease = releases.find((release) => {
return (
!release.draft &&
(channel === 'beta'
? isBeta(release.tag_name)
: isStable(release.tag_name))
);
});
const latestRelease = releases
.sort((a, b) => {
if (semver.lt(a.tag_name, b.tag_name)) {
return 1;
}
if (semver.gt(a.tag_name, b.tag_name)) {
return -1;
}
return 0;
})
.find((release) => {
return (
!release.draft &&
(channel === 'beta'
? isBeta(release.tag_name)
: isStable(release.tag_name))
);
});

if (latestRelease) {
return latestRelease;
Expand Down
Loading