New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: get latest maintenance major tag from github releases #2076
Changes from 8 commits
fb1c54e
d4ade35
4cffcdd
45a6b9b
47db891
17f642f
e66ce5a
e0806f3
f1c3f4a
d0c97b7
0938c0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -264,9 +264,15 @@ const markdownList = (lines: string[]) => | |
lines.map((line) => `- \`${line}\``).join("\n"); | ||
|
||
/** Get the previous version. Typically from a package distribution description file. */ | ||
async function getPreviousVersion(auto: Auto, prereleaseBranch: string) { | ||
async function getPreviousVersion(auto: Auto, prereleaseBranch: string, currentBranch: string | undefined) { | ||
let previousVersion = ""; | ||
|
||
let isMaintenanceBranch = false; | ||
|
||
if(auto.config?.versionBranches && currentBranch) { | ||
isMaintenanceBranch = currentBranch.includes(typeof auto.config.versionBranches === "boolean" ? "version-" : auto.config.versionBranches) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Open to thoughts of how to source the default here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this check could go here as |
||
} | ||
|
||
if (isMonorepo()) { | ||
auto.logger.veryVerbose.info( | ||
"Using monorepo to calculate previous release" | ||
|
@@ -281,7 +287,7 @@ async function getPreviousVersion(auto: Auto, prereleaseBranch: string) { | |
} else { | ||
const releasedPackage = getMonorepoPackage(); | ||
|
||
if (!releasedPackage.name && !releasedPackage.version) { | ||
if (isMaintenanceBranch || (!releasedPackage.name && !releasedPackage.version)) { | ||
previousVersion = auto.prefixRelease(monorepoVersion); | ||
} else { | ||
previousVersion = await greaterRelease( | ||
|
@@ -297,15 +303,18 @@ async function getPreviousVersion(auto: Auto, prereleaseBranch: string) { | |
"Using package.json to calculate previous version" | ||
); | ||
const { version, name } = await loadPackageJson(); | ||
|
||
previousVersion = version | ||
? await greaterRelease( | ||
auto.prefixRelease, | ||
name, | ||
auto.prefixRelease(version), | ||
prereleaseBranch | ||
) | ||
: "0.0.0"; | ||
if(isMaintenanceBranch && version) { | ||
previousVersion = version | ||
} else { | ||
previousVersion = version | ||
? await greaterRelease( | ||
auto.prefixRelease, | ||
name, | ||
auto.prefixRelease(version), | ||
prereleaseBranch | ||
) | ||
: "0.0.0"; | ||
} | ||
} | ||
|
||
auto.logger.verbose.info( | ||
|
@@ -736,7 +745,7 @@ export default class NPMPlugin implements IPlugin { | |
}); | ||
|
||
auto.hooks.getPreviousVersion.tapPromise(this.name, () => | ||
getPreviousVersion(auto, prereleaseBranch) | ||
getPreviousVersion(auto, prereleaseBranch, branch) | ||
); | ||
|
||
auto.hooks.getRepository.tapPromise(this.name, async () => { | ||
|
@@ -771,6 +780,14 @@ export default class NPMPlugin implements IPlugin { | |
return line; | ||
} | ||
|
||
// Allows us to see the commit being assessed | ||
auto.logger.veryVerbose.info(`Rendering changelog line for commit:`, commit) | ||
|
||
// adds commits to changelog only if hash is resolvable | ||
if(!commit || !commit.hash) { | ||
return line; | ||
} | ||
|
||
spentacular marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const lernaPackages = await this.getLernaPackages(); | ||
const changedPackages = await getChangedPackages({ | ||
sha: commit.hash, | ||
|
@@ -1199,7 +1216,7 @@ export default class NPMPlugin implements IPlugin { | |
const lastRelease = await auto.git!.getLatestRelease(); | ||
const latestTag = | ||
(await auto.git?.getLastTagNotInBaseBranch(prereleaseBranch)) || | ||
(await getPreviousVersion(auto, prereleaseBranch)); | ||
(await getPreviousVersion(auto, prereleaseBranch, branch)); | ||
|
||
if (isMonorepo()) { | ||
auto.logger.verbose.info("Detected monorepo, using lerna"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prioritizes Canaries so I could test the NPM plugin 😄