Skip to content

Commit

Permalink
fixed package sources handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebel028 committed Dec 4, 2020
1 parent c77f422 commit 9787e1e
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ const os = require("os"),
https = require("https"),
spawnSync = require("child_process").spawnSync

const SOURCE_NAME = "default";

class Action {

SOURCE_NAME = "default";


constructor() {
this.projectFile = process.env.INPUT_PROJECT_FILE_PATH
this.packageName = process.env.INPUT_PACKAGE_NAME || process.env.PACKAGE_NAME
Expand All @@ -23,15 +22,20 @@ class Action {
this.includeSymbols = JSON.parse(process.env.INPUT_INCLUDE_SYMBOLS || process.env.INCLUDE_SYMBOLS)
this.throwOnVersionExixts = process.env.INPUT_THOW_ERROR_IF_VERSION_EXISTS || process.env.THOW_ERROR_IF_VERSION_EXISTS

let addSourceCmd;
if (this.nugetSource.startsWith(`https://nuget.pkg.github.com/`)) {
this.sourceType = "GPR"
const addSourceCmd = `dotnet nuget add source ${this.nugetSource} --name ${(this.SOURCE_NAME)} --username ${this.githubUser} --password ${this.nugetKey}`
this._executeCommand(addSourceCmd, { encoding: "utf-8" })
addSourceCmd = `dotnet nuget add source ${this.nugetSource}/index.json --name=${(SOURCE_NAME)} --username=${this.githubUser} --password=${this.nugetKey} --store-password-in-clear-text`
} else {
this.sourceType = "NuGet"
const addSourceCmd = `dotnet nuget add source ${this.nugetSource} --name ${(this.SOURCE_NAME)}`
this._executeCommand(addSourceCmd, { encoding: "utf-8" })
addSourceCmd = `dotnet nuget add source ${this.nugetSource}/v3/index.json --name=${SOURCE_NAME}`
}

console.log(this._executeCommand(addSourceCmd, { encoding: "utf-8" }).stdout)
const list1 = this._executeCommand("dotnet nuget list source", { encoding: "utf8" }).stdout;
const enable = this._executeCommand(`dotnet nuget enable source ${SOURCE_NAME}`, { encoding: "utf8" }).stdout;
console.log(list1);
console.log(enable);
}

_printErrorAndExit(msg) {
Expand Down Expand Up @@ -80,8 +84,8 @@ class Action {
const packages = fs.readdirSync(".").filter(fn => fn.endsWith("nupkg"))
console.log(`Generated Package(s): ${packages.join(", ")}`)

const pushCmd = `dotnet nuget push *.nupkg -s ${(this.SOURCE_NAME)} ${this.nugetSource !== "GPR"? `-k ${this.nugetKey}`: ""} --skip-duplicate ${!this.includeSymbols ? "-n 1" : ""}`
const pushCmd = `dotnet nuget push *.nupkg -s ${(SOURCE_NAME)} ${this.nugetSource !== "GPR"? `-k ${this.nugetKey}`: ""} --skip-duplicate ${!this.includeSymbols ? "-n 1" : ""}`

const pushOutput = this._executeCommand(pushCmd, { encoding: "utf-8" }).stdout

console.log(pushOutput)
Expand Down

0 comments on commit 9787e1e

Please sign in to comment.