@@ -8,6 +8,7 @@ interface Props {
8
8
gitEmail : string
9
9
tagPrefix : string
10
10
failOnMissingCommit : boolean
11
+ failOnMissingTag : boolean
11
12
releaseBranchPrefix : string
12
13
forceBump : boolean
13
14
generateChangelog : boolean
@@ -19,12 +20,16 @@ export const shipitHandler = async ({
19
20
gitUser,
20
21
tagPrefix,
21
22
failOnMissingCommit,
23
+ failOnMissingTag,
22
24
forceBump,
23
25
releaseBranchPrefix,
24
26
generateChangelog,
25
27
changelogPath,
26
28
} : Props ) => {
27
- const git = simpleGit ( )
29
+ const gitWithoutAuthor = simpleGit ( )
30
+ const git = gitWithoutAuthor . addConfig ( 'user.name' , gitUser ) . addConfig ( 'user.email' , gitEmail )
31
+
32
+ // @TODO : Implement check so if no valid tag exists, it will tag first commit in repo.
28
33
29
34
// Fetch tags to ensure we have the latest ones.
30
35
const tags = await git . fetch ( [ '--tags' ] ) . tags ( { '--sort' : '-creatordate' } )
@@ -89,41 +94,25 @@ export const shipitHandler = async ({
89
94
const replacementResults = replaceVersionInCommonFiles ( currentTag , nextTag )
90
95
console . log ( `Replaced version in files.` , replacementResults )
91
96
92
- // Commit changed files (versions) and create a release commit with skip ci flag.
93
- await git
94
- //
95
- . add ( './*' )
96
- . addConfig ( 'user.name' , gitUser )
97
- . addConfig ( 'user.email' , gitEmail )
98
- . raw ( 'commit' , '--message' , `Release: ${ nextTagWithPrefix } ${ skipCiFlag } ` )
99
- . addTag ( nextTagWithPrefix )
100
-
101
- // If flag is passed, changelog is genrated and added after new tag is created.
97
+ // If flag is passed, changelog is generated and added.
102
98
if ( generateChangelog ) {
103
99
console . log ( 'Generating changelog...' )
104
-
105
- await changelogHandler ( { outputFile : changelogPath } )
106
- await git
107
- //
108
- . add ( changelogPath )
109
- . addConfig ( 'user.name' , gitUser )
110
- . addConfig ( 'user.email' , gitEmail )
111
- . raw ( 'commit' , '--amend' , '--no-edit' )
100
+ await changelogHandler ( { outputFile : changelogPath , nextTag : nextTagWithPrefix } )
112
101
}
113
102
103
+ // Commit changed files (versions) and create a release commit with skip ci flag.
114
104
await git
115
105
//
116
- . addConfig ( 'user.name' , gitUser )
117
- . addConfig ( 'user.email' , gitEmail )
118
- . push ( remote . name , branch . current )
119
- . pushTags ( )
106
+ . add ( './*' )
107
+ . commit ( `Release: ${ nextTagWithPrefix } ${ skipCiFlag } ` )
108
+ . addTag ( nextTagWithPrefix )
109
+
110
+ await git . push ( remote . name , branch . current ) . pushTags ( )
120
111
121
112
// As current branch commit includes skip ci flag, we want to ommit this flag for release branch so pipeline can run (omitting infinite loop).
122
113
// So we are overwriting last commit message and pushing to release branch.
123
114
await git
124
115
//
125
- . addConfig ( 'user.name' , gitUser )
126
- . addConfig ( 'user.email' , gitEmail )
127
116
. raw ( 'commit' , '--message' , `Release: ${ nextTagWithPrefix } ` , '--amend' )
128
117
. push ( remote . name , `${ branch . current } :${ releaseBranch } ` )
129
118
0 commit comments