Skip to content

Commit

Permalink
fix brandedoutcast#30 & partially removed 2.4.0 changes due to bugs w…
Browse files Browse the repository at this point in the history
…ith nuget
  • Loading branch information
brandedoutcast committed May 9, 2020
1 parent 8aef0d6 commit d2ec0dc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 28 deletions.
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,11 @@ jobs:
# API key to authenticate with NuGet server
# NUGET_KEY: ${{secrets.NUGET_API_KEY}}

# API key to authenticate with NuGet symbols server, defaults to NUGET_KEY
# NUGET_SYMBOL_KEY: ${{secrets.NUGET_SYMBOLS_API_KEY}}

# NuGet server uri hosting the packages, defaults to https://api.nuget.org
# NUGET_SOURCE: https://api.nuget.org

# NuGet server uri hosting the symbols, defaults to https://api.nuget.org
# NUGET_SYMBOL_SOURCE: https://api.nuget.org

# Flag to toggle pushing symbols along with nuget package to the server, enabled by default
# INCLUDE_SYMBOLS: true
# Flag to toggle pushing symbols along with nuget package to the server, disabled by default
# INCLUDE_SYMBOLS: false
```

- Project gets published only if there's a `NUGET_KEY` configured in the repository
Expand All @@ -78,10 +72,8 @@ VERSION_STATIC| | Useful with external providers like Nerdbank.GitVersioning, ig
TAG_COMMIT | `true` | Flag to toggle git tagging, enabled by default
TAG_FORMAT | `v*` | Format of the git tag, `[*]` gets replaced with actual version
NUGET_KEY | | API key to authenticate with NuGet server
NUGET_SYMBOL_KEY | `[NUGET_KEY]` | API key to authenticate with NuGet symbols server, defaults to NUGET_KEY
NUGET_SOURCE | `https://api.nuget.org` | NuGet server uri hosting the packages, defaults to https://api.nuget.org
NUGET_SYMBOL_SOURCE | `https://api.nuget.org` | NuGet server uri hosting the symbols, defaults to https://api.nuget.org
INCLUDE_SYMBOLS | `true` | Flag to toggle pushing symbols along with nuget package to the server, enabled by default
INCLUDE_SYMBOLS | `false` | Flag to toggle pushing symbols along with nuget package to the server, disabled by default

## Outputs

Expand All @@ -94,7 +86,7 @@ SYMBOLS_PACKAGE_NAME | Name of the symbols package generated
SYMBOLS_PACKAGE_PATH | Path to the generated symbols package

**FYI:**
- Outputs may not be set if the action failed
- Outputs may or may not be set depending on the action inputs or if the action failed
- `NUGET_SOURCE` must support `/v3-flatcontainer/PACKAGE_NAME/index.json` for version change detection to work
- Multiple projects can make use of steps to configure each project individually, common inputs between steps can be given as `env` for [job / workflow](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#env)

Expand Down
11 changes: 2 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,14 @@ inputs:
NUGET_KEY:
description: API key to authenticate with NuGet server
required: false
NUGET_SYMBOL_KEY:
description: API key to authenticate with NuGet symbols server, defaults to NUGET_KEY
required: false
NUGET_SOURCE:
description: NuGet server uri hosting the packages, defaults to https://api.nuget.org
required: false
default: https://api.nuget.org
NUGET_SYMBOL_SOURCE:
description: NuGet server uri hosting the symbols, defaults to https://api.nuget.org
required: false
default: https://api.nuget.org
INCLUDE_SYMBOLS:
description: Flag to toggle pushing symbols along with nuget package to the server, enabled by default
description: Flag to toggle pushing symbols along with nuget package to the server, disabled by default
required: false
default: true
default: false

outputs:
VERSION:
Expand Down
9 changes: 2 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class Action {
this.tagCommit = JSON.parse(process.env.INPUT_TAG_COMMIT || process.env.TAG_COMMIT)
this.tagFormat = process.env.INPUT_TAG_FORMAT || process.env.TAG_FORMAT
this.nugetKey = process.env.INPUT_NUGET_KEY || process.env.NUGET_KEY
this.nugetSymbolKey = process.env.INPUT_NUGET_SYMBOL_KEY || process.env.NUGET_SYMBOL_KEY || this.nugetKey
this.nugetSource = process.env.INPUT_NUGET_SOURCE || process.env.NUGET_SOURCE
this.nugetSymbolSource = process.env.INPUT_NUGET_SYMBOL_SOURCE || process.env.NUGET_SYMBOL_SOURCE
this.includeSymbols = JSON.parse(process.env.INPUT_INCLUDE_SYMBOLS || process.env.INCLUDE_SYMBOLS)
}

Expand Down Expand Up @@ -56,20 +54,17 @@ class Action {
}

console.log(`NuGet Source: ${this.nugetSource}`)
console.log(`NuGet Symbol Source: ${this.nugetSymbolSource}`)

fs.readdirSync(".").filter(fn => fn.endsWith("nupkg")).forEach(fn => fs.unlinkSync(fn))

this._executeInProcess(`dotnet build -c Release ${this.projectFile}`)

const packSymbolFlags = this.includeSymbols ? "--include-symbols -p:SymbolPackageFormat=snupkg" : ""
this._executeInProcess(`dotnet pack ${packSymbolFlags} --no-build -c Release ${this.projectFile} -o .`)
this._executeInProcess(`dotnet pack ${this.includeSymbols ? "--include-symbols -p:SymbolPackageFormat=snupkg" : ""} --no-build -c Release ${this.projectFile} -o .`)

const packages = fs.readdirSync(".").filter(fn => fn.endsWith("nupkg"))
console.log(`Generated Package(s): ${packages.join(", ")}`)

const pushSymbolFlags = this.includeSymbols ? `-ss ${this.nugetSymbolSource}/v3/index.json -sk ${this.nugetSymbolKey}` : "--no-symbols",
pushCmd = `dotnet nuget push *.nupkg -s ${this.nugetSource}/v3/index.json -k ${this.nugetKey} ${pushSymbolFlags} --skip-duplicate`,
const pushCmd = `dotnet nuget push *.nupkg -s ${this.nugetSource}/v3/index.json -k ${this.nugetKey} ${!this.includeSymbols ? "--no-symbols" : ""} --skip-duplicate`,
pushOutput = this._executeCommand(pushCmd, { encoding: "utf-8" }).stdout

console.log(pushOutput)
Expand Down

0 comments on commit d2ec0dc

Please sign in to comment.