@@ -6,7 +6,7 @@ function run() {
6
6
// check fetch-depth
7
7
const commitCount = parseInt ( runCap ( "git rev-list --count HEAD" ) )
8
8
if ( commitCount < 2 ) {
9
- failure ( "😤 commit history needs to be >= 2" )
9
+ failed ( "😤 git commit history must be >= 2" )
10
10
return
11
11
}
12
12
@@ -16,7 +16,7 @@ function run() {
16
16
projFiles = readdirSync ( projDir ) . filter ( f => f . endsWith ( ".csproj" ) )
17
17
18
18
if ( projFiles . length === 0 ) {
19
- failure ( "😭 project not found" )
19
+ failed ( "😭 project not found" )
20
20
return
21
21
}
22
22
@@ -28,21 +28,21 @@ function run() {
28
28
isVersionChanged = versionRegex . test ( gitDiff )
29
29
30
30
if ( ! isVersionChanged ) {
31
- console . log ( `🥱 no version change in ${ projName } ` )
31
+ console . log ( `🥱 no version change for ${ projName } ` )
32
32
return
33
33
}
34
34
35
- console . log ( `👍 found version change in ${ projName } ` )
35
+ console . log ( `👍 found a new version for ${ projName } ` )
36
36
37
37
// create tag
38
38
const projContents = readFileSync ( projPath , { encoding : "utf-8" } ) ,
39
39
newVersion = versionRegex . exec ( projContents ) [ 1 ] ,
40
40
tagFormat = process . env . INPUT_TAG_FORMAT ,
41
41
tag = tagFormat . replace ( "*" , newVersion ) ,
42
- istagPresent = runCap ( " git tag -l --contains" ) . indexOf ( tag ) >= 0
42
+ istagPresent = runCap ( ` git ls-remote --tags origin ${ tag } ` ) . indexOf ( tag ) >= 0
43
43
44
44
if ( istagPresent ) {
45
- console . log ( `😢 tag named ${ newVersion } already exists` )
45
+ console . log ( `##[warning] 😢 tag ${ newVersion } already exists` )
46
46
return
47
47
}
48
48
@@ -53,17 +53,21 @@ function run() {
53
53
const nugetKey = process . env . INPUT_NUGET_KEY
54
54
55
55
if ( ! nugetKey ) {
56
- console . log ( `😢 no nuget_key input supplied ` )
56
+ console . log ( `##[warning]😢 nuget_key not found ` )
57
57
return
58
58
}
59
59
60
60
if ( ! runCap ( "dotnet --version" ) ) {
61
- failure ( "😭 dotnet not found" )
61
+ failed ( "😭 dotnet not found" )
62
62
return
63
63
}
64
64
65
65
runProc ( `dotnet pack -c Release ${ projPath } -o .` )
66
- runProc ( `dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k ${ nugetKey } ` )
66
+ const out = runCap ( `dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k ${ nugetKey } ` )
67
+ const errorRegex = / ( e r r o r : R e s p o n s e s t a t u s c o d e d o e s n o t i n d i c a t e s u c c e s s .* ) /
68
+
69
+ if ( errorRegex . test ( out ) )
70
+ failed ( `😭 ${ errorRegex . exec ( out ) [ 1 ] } ` )
67
71
}
68
72
69
73
function runCap ( cmd ) { return runCmd ( cmd , { encoding : "utf-8" } ) . stdout }
@@ -75,9 +79,9 @@ function runCmd(cmd, options) {
75
79
return spawnSync ( tool , args , options )
76
80
}
77
81
78
- function failure ( msg ) {
82
+ function failed ( msg ) {
79
83
process . exitCode = 1
80
- console . log ( msg )
84
+ console . log ( `##[error] ${ msg } ` )
81
85
}
82
86
83
87
run ( )
0 commit comments