Skip to content
This repository was archived by the owner on Oct 26, 2022. It is now read-only.

Commit cc84629

Browse files
log info to help understand the mis-configurations & stages of action
1 parent 6c0ec33 commit cc84629

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

index.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ class Action {
3737
this._execCmd(cmd, { encoding: "utf-8", stdio: [process.stdin, process.stdout, process.stderr] })
3838
}
3939

40-
_resolveIfExists(filePath, msg) {
40+
_resolveIfExists(filePath, errMsg) {
4141
const FULLPATH = path.resolve(process.env.GITHUB_WORKSPACE, filePath)
42-
if (!fs.existsSync(FULLPATH)) this._fail(msg)
42+
43+
if (!fs.existsSync(FULLPATH))
44+
this._fail(errMsg)
45+
4346
return FULLPATH
4447
}
4548

@@ -56,9 +59,15 @@ class Action {
5659

5760
this._execInProc(`dotnet build -c Release ${this.PROJECT_FILE_PATH}`)
5861
this._execInProc(`dotnet pack --no-build -c Release ${this.PROJECT_FILE_PATH} -o .`)
59-
const NUGET_PUSH_RESPONSE = this._execAndCapture(`dotnet nuget push ${this.PACKAGE_NAME}*.nupkg -s https://api.nuget.org/v3/index.json -k ${this.NUGET_KEY}`)
62+
63+
const generatedPackage = fs.readdirSync(".").filter(fn => fn.startsWith(this.PACKAGE_NAME) && fn.endsWith(".nupkg")).shift()
64+
console.log(`Generated Package: ${generatedPackage}`)
65+
66+
const NUGET_PUSH_RESPONSE = this._execAndCapture(`dotnet nuget push ${generatedPackage} -s https://api.nuget.org/v3/index.json -k ${this.NUGET_KEY}`)
6067
const NUGET_ERROR_REGEX = /(error: Response status code does not indicate success.*)/
6168

69+
console.log(NUGET_PUSH_RESPONSE)
70+
6271
if (NUGET_ERROR_REGEX.test(NUGET_PUSH_RESPONSE))
6372
this._fail(`😭 ${NUGET_ERROR_REGEX.exec(NUGET_PUSH_RESPONSE)[1]}`)
6473
}
@@ -86,13 +95,18 @@ class Action {
8695
run() {
8796
if (!this.PROJECT_FILE_PATH)
8897
this._fail("😭 project file not given")
98+
8999
this.PROJECT_FILE_PATH = this._resolveIfExists(this.PROJECT_FILE_PATH, "😭 project file not found")
90-
91-
let CURRENT_VERSION = ""
92-
100+
101+
console.log(`Project Filepath: ${this.PROJECT_FILE_PATH}`)
102+
103+
let CURRENT_VERSION
104+
93105
if (!this.VERSION_STATIC) {
94106
this.VERSION_FILE_PATH = !this.VERSION_FILE_PATH ? this.PROJECT_FILE_PATH : this._resolveIfExists(this.VERSION_FILE_PATH, "😭 version file not found")
95107

108+
console.log(`Version Filepath: ${this.VERSION_FILE_PATH}`)
109+
96110
const FILE_CONTENT = fs.readFileSync(this.VERSION_FILE_PATH, { encoding: "utf-8" }),
97111
VERSION_INFO = this.VERSION_REGEX.exec(FILE_CONTENT)
98112

@@ -103,8 +117,12 @@ class Action {
103117
} else
104118
CURRENT_VERSION = this.VERSION_STATIC
105119

106-
if (!this.PACKAGE_NAME)
120+
console.log(`Version: ${CURRENT_VERSION}`)
121+
122+
if (!this.PACKAGE_NAME) {
107123
this.PACKAGE_NAME = path.basename(this.PROJECT_FILE_PATH).split(".").slice(0, -1).join(".")
124+
console.log(`Package Name: ${this.PACKAGE_NAME}`)
125+
}
108126

109127
https.get(`https://api.nuget.org/v3-flatcontainer/${this.PACKAGE_NAME}/index.json`, res => {
110128
let body = ""

0 commit comments

Comments
 (0)