File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import GitRelease from "#core/api/git/release" ;
12import ejs from "#core/ejs" ;
23import Markdown from "#core/markdown" ;
34import { resolve } from "#core/utils" ;
@@ -61,10 +62,6 @@ export default class GitChangelog {
6162 return this . #changes. hasBreakingChanges ;
6263 }
6364
64- get hasFeatureChanges ( ) {
65- return this . #changes. hasFeatureChanges ;
66- }
67-
6865 // public
6966 async createChangelog ( { currentRelease, header, text, ansi = true } = { } ) {
7067 currentRelease ||= this . #currentRelease;
@@ -164,6 +161,23 @@ export default class GitChangelog {
164161 return text ;
165162 }
166163
164+ getNextVersion ( preReleaseTag ) {
165+ const previousRelease = this . previousRelease || GitRelease . initialVersion ;
166+
167+ try {
168+ const nextVersion = previousRelease . increment ( this . hasBreakingChanges
169+ ? "major"
170+ : this . #changes. hasFeatureChanges
171+ ? "minor"
172+ : "patch" , preReleaseTag ) ;
173+
174+ return result ( 200 , nextVersion ) ;
175+ }
176+ catch ( e ) {
177+ return result . catch ( e , { "log" : false } ) ;
178+ }
179+ }
180+
167181 // private
168182 #indexChanges ( commitTypes ) {
169183 this . #changesGroups = [ ] ;
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ import childProcess from "node:child_process";
22import fs from "node:fs" ;
33import _path from "node:path" ;
44import ansi from "#core/ansi" ;
5- import GitRelease from "#core/api/git/release" ;
65import GitHub from "#core/api/github" ;
76import env from "#core/env" ;
87import File from "#core/file" ;
@@ -73,18 +72,11 @@ export default class Publish {
7372 if ( status . isDirty ) return result ( [ 500 , `working copy or sub-repositories has uncommited changes or untracked files` ] ) ;
7473
7574 // define new version
76- try {
77- this . #currentRelease = ( this . #changelog. previousRelease || GitRelease . initialVersion ) . increment ( this . #changelog. hasBreakingChanges
78- ? "major"
79- : this . #changelog. hasFeatureChanges
80- ? "minor"
81- : "patch" , this . #stable
82- ? false
83- : this . #preRelease ) ;
84- }
85- catch ( e ) {
86- return result . catch ( e , { "log" : false } ) ;
87- }
75+ res = this . #changelog. getNextVersion ( this . #stable
76+ ? false
77+ : this . #preRelease ) ;
78+ if ( ! res . ok ) return res ;
79+ this . #currentRelease = res . data ;
8880
8981 // check version can be released
9082 res = status . releases . canRelease ( this . #currentRelease ) ;
You can’t perform that action at this time.
0 commit comments