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

Create new plugin : one-release-commit #2180

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jBouyoud
Copy link
Contributor

@jBouyoud jBouyoud commented Mar 22, 2022

Create a new plugin to handle this discussion

What Changed

  • refactor(core): split release creation in two steps

    Refactoring needed for the next commit to allow forward current releasing version in afterVersion hook.

  • feat(core): add version in afterVersion hook

    Add version in afterVersion hook

  • feat(one-release-commit): create plugin with automation

    Create plugin boiler plate with automation

  • feat(one-release-commit): first implementation

    First implementation of this plugin

Why

Some users might want a single atomic commit that represent the release (also easy to rollback).

  • Add tests (Also tested in a real repo)
  • Add docs

Change Type

Indicate the type of change your pull request is:

  • documentation
  • patch
  • minor
  • major

🐤 Download canary assets:

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

📦 Published PR as canary version: under canary scope @auto-canary@10.37.0--canary.2180.26196.0

✨ Test out this PR locally via:

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

@intuit-svc intuit-svc added the minor Increment the minor version when merged label Mar 22, 2022
@jBouyoud jBouyoud marked this pull request as ready for review March 23, 2022 07:33
@jBouyoud jBouyoud force-pushed the one-release-commit branch 2 times, most recently from 77bc527 to ce747e0 Compare March 24, 2022 07:06
@jBouyoud jBouyoud mentioned this pull request Mar 25, 2022
6 tasks
@jBouyoud
Copy link
Contributor Author

@hipstersmoothie here an implementation proposal to handle #1949

@jBouyoud
Copy link
Contributor Author

@hipstersmoothie anything that I can do to help merge this PR ?

@jBouyoud jBouyoud force-pushed the one-release-commit branch 2 times, most recently from 7e7ab35 to 640fe0a Compare February 8, 2023 10:40
@jBouyoud
Copy link
Contributor Author

jBouyoud commented Feb 8, 2023

@hipstersmoothie I also rebase this PR ;-P

@jBouyoud
Copy link
Contributor Author

jBouyoud commented Feb 9, 2023

Same as #2182 (comment)

@jBouyoud
Copy link
Contributor Author

jBouyoud commented Feb 10, 2023

@hipstersmoothie Let me know if everything miss to merge this 🎉

@jBouyoud
Copy link
Contributor Author

@hipstersmoothie Let me know if this plugin can be merged or if I have something to change, Thanks

@hipstersmoothie
Copy link
Collaborator

@jBouyoud sorry! been reviewing this and keep getting pulled away. will try to get in ttoday

Copy link
Collaborator

@hipstersmoothie hipstersmoothie left a comment

Choose a reason for hiding this comment

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

I think we can revert all the changes to core and still have a working plugin

@@ -78,7 +78,7 @@ jobs:
at: ~/auto
- run:
name: Check for SemVer Label
command: yarn auto pr-check --url $CIRCLE_BUILD_URL
command: yarn auto pr-check -vv --url $CIRCLE_BUILD_URL
Copy link
Collaborator

Choose a reason for hiding this comment

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

Revert this

auto.config.ts Outdated
@@ -32,6 +32,7 @@ const brewOptions: IBrewPluginOptions = {
export default function rc(): AutoRc {
return {
plugins: [
"one-release-commit",
Copy link
Collaborator

Choose a reason for hiding this comment

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

revert this

@@ -0,0 +1,29 @@
# One-Release-Commit Plugin

Allow to create a single release commit
Copy link
Collaborator

Choose a reason for hiding this comment

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

Write a better description of why someone might want to use this plugin.


if (commits.length > 0) {
await execPromise("git", ["reset", "--soft", remoteHead]);
await execPromise("git", ["commit", "-m", this.options.commitMessage || `"Release version ${version} [skip ci]"`, "--no-verify"]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make sure to include skip-ci even if there is a custom message

@@ -1760,8 +1775,12 @@ export default class Auto {
dryRun: options.dryRun,
quiet: options.quiet,
});

// New new version must be computed, so make release context
const releaseArgs = await this.makeReleaseContext();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is problematic I think. For the default usage this would included the commit for the changelog in the release notes since it would now be in the commitsInRelease. Could you make sure this doesn't augment the normal auto workflow?

The changes below to for makeRelaeaseContext make sense and are good additions but the change in order has me worried.

const commits = await auto.git.getGitLog(remoteHead);
const tags: ITag[] = (await Promise.all(commits.map(commit => getTag(commit.hash)))).filter(tag => tag !== undefined) as ITag[];

auto.logger.log.info(`Rewrote ${commits.length} release commits into a single commit for version [${version}] with tags: [${tags.map(tag => tag.name).join(", ")}]`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait you only need the version for these logs? I don't think that a big enough reason to change core at all.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This log also seems a little early. Nothing happens until the if statement body

this.logger.verbose.info("Calling after version hook");
await this.hooks.afterVersion.promise({ dryRun: options.dryRun });
await this.hooks.afterVersion.promise({ dryRun: options.dryRun, version: releaseArgs.newVersion });
Copy link
Collaborator

Choose a reason for hiding this comment

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

OH I see why you do all of this rearranging. in the afterVersion hook if it's not a dry run it IS a release. We don't have to care about the return value of makeRelease. The undefined that it returns is for it's other usage. Here we know a release (and thus a version) has happened.

You can revert all the changes to core and remove references in you plugin to version and it still all works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Increment the minor version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants