Skip to content
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

Merged
merged 11 commits into from
Oct 26, 2021

Conversation

sumwatshade
Copy link
Collaborator

@sumwatshade sumwatshade commented Sep 16, 2021

What Changed

This is a patch fix to tweak the way latest release is determined.

Why

When using versionBranches configuration, we observed that the calculated "latest release" relative to the maintenance branch was still the latest overall version, resulting in version conflicts. This change verifies that if versionBranches is enabled, then it will:

  • use the branch naming scheme to determine the major (ex. major-2 -> 2)
  • detect the latest git release within that major
  • calculate version bump based on that release.
  • Have current branch support the case that env-ci returns prBranch (undefined) and branch, which happens when merging to a branch that is non-default
  • suppress changelog rendering for maintenence case due to edge where commit hash is not being returned
  • Configure NPM to ignore the latest released version when in a maintenance release

Todo:

  • Add tests
  • Add docs (N/A, since this is a patch

Change Type

Indicate the type of change your pull request is:

  • documentation
  • patch
  • minor
  • major

🐤 Download canary assets:

auto-linux--canary.2076.24992.gz
auto-macos--canary.2076.24992.gz
auto-win.exe--canary.2076.24992.gz

📦 Published PR as canary version: under canary scope @auto-canary@10.32.2--canary.2076.24992.0

✨ Test out this PR locally via:

npm install @auto-canary/bot-list@10.32.2--canary.2076.24992.0
npm install @auto-canary/auto@10.32.2--canary.2076.24992.0
npm install @auto-canary/core@10.32.2--canary.2076.24992.0
npm install @auto-canary/package-json-utils@10.32.2--canary.2076.24992.0
npm install @auto-canary/all-contributors@10.32.2--canary.2076.24992.0
npm install @auto-canary/brew@10.32.2--canary.2076.24992.0
npm install @auto-canary/chrome@10.32.2--canary.2076.24992.0
npm install @auto-canary/cocoapods@10.32.2--canary.2076.24992.0
npm install @auto-canary/conventional-commits@10.32.2--canary.2076.24992.0
npm install @auto-canary/crates@10.32.2--canary.2076.24992.0
npm install @auto-canary/docker@10.32.2--canary.2076.24992.0
npm install @auto-canary/exec@10.32.2--canary.2076.24992.0
npm install @auto-canary/first-time-contributor@10.32.2--canary.2076.24992.0
npm install @auto-canary/gem@10.32.2--canary.2076.24992.0
npm install @auto-canary/gh-pages@10.32.2--canary.2076.24992.0
npm install @auto-canary/git-tag@10.32.2--canary.2076.24992.0
npm install @auto-canary/gradle@10.32.2--canary.2076.24992.0
npm install @auto-canary/jira@10.32.2--canary.2076.24992.0
npm install @auto-canary/magic-zero@10.32.2--canary.2076.24992.0
npm install @auto-canary/maven@10.32.2--canary.2076.24992.0
npm install @auto-canary/microsoft-teams@10.32.2--canary.2076.24992.0
npm install @auto-canary/npm@10.32.2--canary.2076.24992.0
npm install @auto-canary/omit-commits@10.32.2--canary.2076.24992.0
npm install @auto-canary/omit-release-notes@10.32.2--canary.2076.24992.0
npm install @auto-canary/pr-body-labels@10.32.2--canary.2076.24992.0
npm install @auto-canary/released@10.32.2--canary.2076.24992.0
npm install @auto-canary/s3@10.32.2--canary.2076.24992.0
npm install @auto-canary/sbt@10.32.2--canary.2076.24992.0
npm install @auto-canary/slack@10.32.2--canary.2076.24992.0
npm install @auto-canary/twitter@10.32.2--canary.2076.24992.0
npm install @auto-canary/upload-assets@10.32.2--canary.2076.24992.0
npm install @auto-canary/vscode@10.32.2--canary.2076.24992.0
# or 
yarn add @auto-canary/bot-list@10.32.2--canary.2076.24992.0
yarn add @auto-canary/auto@10.32.2--canary.2076.24992.0
yarn add @auto-canary/core@10.32.2--canary.2076.24992.0
yarn add @auto-canary/package-json-utils@10.32.2--canary.2076.24992.0
yarn add @auto-canary/all-contributors@10.32.2--canary.2076.24992.0
yarn add @auto-canary/brew@10.32.2--canary.2076.24992.0
yarn add @auto-canary/chrome@10.32.2--canary.2076.24992.0
yarn add @auto-canary/cocoapods@10.32.2--canary.2076.24992.0
yarn add @auto-canary/conventional-commits@10.32.2--canary.2076.24992.0
yarn add @auto-canary/crates@10.32.2--canary.2076.24992.0
yarn add @auto-canary/docker@10.32.2--canary.2076.24992.0
yarn add @auto-canary/exec@10.32.2--canary.2076.24992.0
yarn add @auto-canary/first-time-contributor@10.32.2--canary.2076.24992.0
yarn add @auto-canary/gem@10.32.2--canary.2076.24992.0
yarn add @auto-canary/gh-pages@10.32.2--canary.2076.24992.0
yarn add @auto-canary/git-tag@10.32.2--canary.2076.24992.0
yarn add @auto-canary/gradle@10.32.2--canary.2076.24992.0
yarn add @auto-canary/jira@10.32.2--canary.2076.24992.0
yarn add @auto-canary/magic-zero@10.32.2--canary.2076.24992.0
yarn add @auto-canary/maven@10.32.2--canary.2076.24992.0
yarn add @auto-canary/microsoft-teams@10.32.2--canary.2076.24992.0
yarn add @auto-canary/npm@10.32.2--canary.2076.24992.0
yarn add @auto-canary/omit-commits@10.32.2--canary.2076.24992.0
yarn add @auto-canary/omit-release-notes@10.32.2--canary.2076.24992.0
yarn add @auto-canary/pr-body-labels@10.32.2--canary.2076.24992.0
yarn add @auto-canary/released@10.32.2--canary.2076.24992.0
yarn add @auto-canary/s3@10.32.2--canary.2076.24992.0
yarn add @auto-canary/sbt@10.32.2--canary.2076.24992.0
yarn add @auto-canary/slack@10.32.2--canary.2076.24992.0
yarn add @auto-canary/twitter@10.32.2--canary.2076.24992.0
yarn add @auto-canary/upload-assets@10.32.2--canary.2076.24992.0
yarn add @auto-canary/vscode@10.32.2--canary.2076.24992.0

@adierkens adierkens added the patch Increment the patch version when merged label Sep 16, 2021
@codecov
Copy link

codecov bot commented Sep 16, 2021

Codecov Report

Merging #2076 (0938c0e) into main (9f1a57d) will increase coverage by 0.00%.
The diff coverage is 74.07%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2076   +/-   ##
=======================================
  Coverage   80.19%   80.19%           
=======================================
  Files          66       66           
  Lines        5403     5414   +11     
  Branches     1254     1262    +8     
=======================================
+ Hits         4333     4342    +9     
  Misses        709      709           
- Partials      361      363    +2     
Impacted Files Coverage Δ
packages/core/src/auto.ts 77.46% <50.00%> (-0.10%) ⬇️
plugins/npm/src/index.ts 72.20% <53.84%> (-0.67%) ⬇️
packages/core/src/utils/get-current-branch.ts 100.00% <100.00%> (+41.66%) ⬆️
packages/core/src/utils/load-plugins.ts 81.73% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d79865f...0938c0e. Read the comment docs.

const isPrerelease = this.inPrereleaseBranch();

const maintenanceMajor = this.config?.versionBranches && typeof this.config?.versionBranches === "string" && currentBranch?.startsWith(this.config.versionBranches) ?
parseInt(currentBranch.replace(this.config.versionBranches, ""), 10) : null
const [, latestTagInBranch] = await on(this.git.getLatestTagInBranch());
const lastRelease =
from ||
Copy link
Contributor

@kelyvin kelyvin Sep 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, this will prioritize the from value over the proper version number that you fetched with your function.

In the following line: https://github.com/intuit/auto/blob/main/packages/core/src/auto.ts#L1688, auto passes in the from: latestTag from the function getLatestTagInBranch(). getLatestTagInBranch can still return the incorrect tag version, and will get prioritized when passed into the getVersion method from the publishRelease function here: https://github.com/intuit/auto/blob/main/packages/core/src/auto.ts#L1714, then it will be prioritized over your change.

@sumwatshade sumwatshade reopened this Oct 21, 2021
@sumwatshade
Copy link
Collaborator Author

sumwatshade commented Oct 21, 2021

Didn't mean to close it, seems like pushing a reset to origin triggers an auto-close of a PR :P I updated the logic to only include the fix.

@@ -166,18 +166,18 @@ export function findPlugin(
return userPlugin;
}

const officialPlugin = path.join("@auto-it", pluginPath);
const canaryPlugin = path.join("@auto-canary", pluginPath);
Copy link
Collaborator Author

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 😄

let isMaintenanceBranch = false;

if(auto.config?.versionBranches && currentBranch) {
isMaintenanceBranch = currentBranch.includes(typeof auto.config.versionBranches === "boolean" ? "version-" : auto.config.versionBranches)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to thoughts of how to source the default here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this check could go here as versionBranch instead (to align with the naming style for how preleaseBranch), then you could just pass versionBranch as an argument to getPreviousVersion directly.

let isMaintenanceBranch = false;

if(auto.config?.versionBranches && currentBranch) {
isMaintenanceBranch = currentBranch.includes(typeof auto.config.versionBranches === "boolean" ? "version-" : auto.config.versionBranches)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this check could go here as versionBranch instead (to align with the naming style for how preleaseBranch), then you could just pass versionBranch as an argument to getPreviousVersion directly.

plugins/npm/src/index.ts Show resolved Hide resolved
@adierkens adierkens merged commit 1d1ba5c into intuit:main Oct 26, 2021
@adierkens
Copy link
Collaborator

🚀 PR was released in v10.32.2 🚀

@adierkens adierkens added the released This issue/pull request has been released. label Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest patch Increment the patch version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants