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

Support custom logic of getNextVersion #713

Closed
azu opened this issue Mar 7, 2020 · 3 comments · Fixed by #724
Closed

Support custom logic of getNextVersion #713

azu opened this issue Mar 7, 2020 · 3 comments · Fixed by #724

Comments

@azu
Copy link

azu commented Mar 7, 2020

Is your feature request related to a problem? Please describe.

Currently, It seems that ship.js support only conventional commits to get Next version.

Can I custom the detection logic for getting next version?

I want to custom the logic of getNextVersion.
For example, I want to implement label based version management:

Calculate Next version from GitHub PR's labels
If these includes only Version: patch, next version is patch
If these includes Version: patch and Version: minor, next version is minor
If any one is Version: major label, next version is major
-- https://gist.github.com/azu/e39fcc506eff4242beb27b84cac17b82

During I try to implement my Release Flow idea using ship.js, I noticed that ship.js only support conventional commits to detect next version.

Describe the solution you'd like

Add new lifecyle hook like updateVersion before shouldPrepare

module.exports = {
    updateVersion: async ({
                     revisionRange,
                     currentVersion,
                     dir}) => {
       // user defined logic
       const nextVersion = await calculateNextVersion();
       return { nextVersion } 
    }
};

Describe alternatives you've considered

  • Options 2: Add { versionStrategy: "conventional-commits" | customFunction }
  • Options 3: Load next version from file if exist
    • Example: If exists .next-version file in the repository, use it as next version and delete it after prepared
    • This approach is similar with changesets

I don't know ship.js internal, maybe exist more reasonable implementation.

Additional context

@eunjae-lee
Copy link
Contributor

Hi @azu ,
I guess we can expose a config so that you can override getNextVersion function.

I will try to work on this this week or next week.
Or, if you want to contribute on the code level, let me know. I will help you onboard!

@eunjae-lee
Copy link
Contributor

eunjae-lee commented Mar 17, 2020

Hi @azu, this has been released at v0.18.0.
Read the doc →

@azu
Copy link
Author

azu commented Mar 18, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants