@@ -5,25 +5,14 @@ const execAsync = util.promisify(exec);
5
5
6
6
module . exports = async ( { github, context, versionType } ) => {
7
7
async function configureGit ( ) {
8
- try {
9
- await execAsync ( 'git config user.name "github-actions"' ) ;
10
- await execAsync ( 'git config user.email "github-actions@github.com"' ) ;
11
- } catch ( e ) {
12
- console . log ( "Error in configuring git user" ) ;
13
- throw Error ( e ) ;
14
- }
15
-
8
+ await execAsync ( 'git config user.name "github-actions"' ) ;
9
+ await execAsync ( 'git config user.email "github-actions@github.com"' ) ;
16
10
console . log ( "Configured git user" ) ;
17
11
}
18
12
19
13
async function incrementVersion ( ) {
20
14
console . log ( `Incrementing version with ${ versionType } ` ) ;
21
- try {
22
- await execAsync ( `npm version ${ versionType } ` ) ;
23
- } catch ( e ) {
24
- console . log ( "Error in incrementing version" ) ;
25
- throw Error ( e ) ;
26
- }
15
+ await execAsync ( `npm version ${ versionType } ` ) ;
27
16
const packageJson = require ( "../../package.json" ) ;
28
17
const version = packageJson . version ;
29
18
console . log ( `Incremented version to v${ version } (${ versionType } )` ) ;
@@ -32,44 +21,29 @@ module.exports = async ({ github, context, versionType }) => {
32
21
}
33
22
34
23
async function pushChangesAndTags ( featureBranch ) {
35
- try {
36
- await execAsync ( `git push origin HEAD:refs/heads/${ featureBranch } ` ) ;
37
- await execAsync ( "git push origin --tags" ) ;
38
- } catch ( e ) {
39
- console . log ( "Error in pushing changes and tags" ) ;
40
- throw Error ( e ) ;
41
- }
24
+ await execAsync ( `git push origin HEAD:refs/heads/${ featureBranch } ` ) ;
25
+ await execAsync ( "git push origin --tags" ) ;
42
26
}
43
27
44
28
async function getPull ( source , target ) {
45
- try {
46
- const existingPr = await github . pulls . list ( {
47
- owner : context . repo . owner ,
48
- repo : context . repo . repo ,
49
- head : source ,
50
- base : target ,
51
- } ) ;
52
- return existingPr . data . length > 0 ;
53
- } catch ( e ) {
54
- console . log ( "Error in getting pull request" ) ;
55
- throw Error ( e ) ;
56
- }
29
+ const existingPr = await github . pulls . list ( {
30
+ owner : context . repo . owner ,
31
+ repo : context . repo . repo ,
32
+ head : source ,
33
+ base : target ,
34
+ } ) ;
35
+ return existingPr . data . length > 0 ;
57
36
}
58
37
59
38
async function createPull ( title , source , target ) {
60
- try {
61
- await github . pulls . create ( {
62
- title,
63
- body : `${ title } PR.` ,
64
- owner : context . repo . owner ,
65
- repo : context . repo . repo ,
66
- head : source ,
67
- base : target ,
68
- } ) ;
69
- } catch ( e ) {
70
- console . log ( "Error in creating pull request" ) ;
71
- throw Error ( e ) ;
72
- }
39
+ await github . pulls . create ( {
40
+ title,
41
+ body : `${ title } PR.` ,
42
+ owner : context . repo . owner ,
43
+ repo : context . repo . repo ,
44
+ head : source ,
45
+ base : target ,
46
+ } ) ;
73
47
}
74
48
75
49
try {
@@ -81,15 +55,14 @@ module.exports = async ({ github, context, versionType }) => {
81
55
await pushChangesAndTags ( featureBranch ) ;
82
56
const title = `Version Increment to v${ version } (${ versionType } )` ;
83
57
await createPull ( title , featureBranch , "master" ) ;
84
-
85
58
console . log (
86
59
`Created pull request for version increment to v${ version } (${ versionType } ).`
87
60
) ;
88
61
} else {
89
- throw new Error ( "Pull request already exists for this version increment" ) ;
62
+ console . error ( "Pull request already exists for this version increment" ) ;
90
63
}
91
64
} catch ( error ) {
92
- console . error ( error ) ;
93
- throw new Error ( "Error in version increment and PR creation" ) ;
65
+ console . error ( "Error encountered:" , error ) ;
66
+ // Decide whether to re-throw the error or handle it differently here
94
67
}
95
68
} ;
0 commit comments