Skip to content

Commit

Permalink
Fix pre-release handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dappnodedev committed Mar 20, 2024
1 parent fd0bde1 commit 19758e3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 12 additions & 3 deletions src/commands/githubActions/bumpUpstream/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,20 @@ export function getUpstreamVersionTag(versionsToUpdate: ComposeVersionsToUpdate)
}
}

//Checking if the proposed release is nightly or realeaseCandidate
export function isUndesiredRelease(version: string): boolean {
return !(semver.valid(version) && !semver.prerelease(version));
export function isValidRelease(version: string): boolean {
// Nightly builds are not considered valid releases (not taken into account by semver)
if (version.includes("nightly")) return false;

if (!semver.valid(version)) return false;

const preReleases = semver.prerelease(version);

// A version is considered a valid release if it has no pre-release components.
return preReleases === null || preReleases.length === 0;
}



export function getBranch(upstreamVersions: UpstreamRepoMap): GitBranch {
const branchName = branchNameRoot +
Array.from(Object.values(upstreamVersions))
Expand Down
6 changes: 3 additions & 3 deletions src/commands/githubActions/bumpUpstream/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { getNextVersionFromApm } from "../../../utils/versions/getNextVersionFro
import { Compose, Manifest } from "@dappnode/types";
import { isEmpty } from "lodash-es";
import { UpstreamSettings, UpstreamRepoMap, ComposeVersionsToUpdate, GitSettings, GithubSettings } from "./types.js";
import { closeOldPrs, getGitHubSettings, getPrBody, getUpstreamVersionTag, isBranchNew, isUndesiredRelease } from "./git.js";
import { closeOldPrs, getGitHubSettings, getPrBody, getUpstreamVersionTag, isBranchNew, isValidRelease } from "./git.js";
import { printSettings, readInitialSetup } from "./setup.js";
import { ManifestFormat } from "../../../files/manifest/types.js";

Expand Down Expand Up @@ -114,8 +114,8 @@ async function getUpstreamRepoVersions(upstreamSettings: UpstreamSettings[]): Pr
if (!latestRelease) throw Error(`No release found for ${upstreamRepo}`);

const newVersion = latestRelease.tag_name;
if (isUndesiredRelease(newVersion)) {
console.log(`This is a realease candidate - ${upstreamRepo}: ${newVersion}`);
if (!isValidRelease(newVersion)) {
console.log(`This is not a valid release (probably a release candidate) - ${upstreamRepo}: ${newVersion}`);
continue;
}

Expand Down

0 comments on commit 19758e3

Please sign in to comment.