Skip to content

Commit

Permalink
feat: add NO_BUILD flag to allow skipping dotnet build step (#3)
Browse files Browse the repository at this point in the history
* fix: build issues on some projects

* feat: add NO_BUILD flag to allow skipping dotnet build step
  • Loading branch information
Kurounin authored Mar 14, 2022
1 parent 2d8248d commit b0539a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ jobs:

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

# Flag to toggle not building the project and letting pack command handle restoring & building, disabled by default
# NO_BUILD: false
```

- Project gets published only if there's a `NUGET_KEY` configured in the repository
Expand All @@ -74,6 +77,7 @@ TAG_FORMAT | `v*` | Format of the git tag, `[*]` gets replaced with actual versi
NUGET_KEY | | API key to authenticate with NuGet server
NUGET_SOURCE | `https://api.nuget.org` | NuGet server uri hosting the packages, defaults to https://api.nuget.org
INCLUDE_SYMBOLS | `false` | Flag to toggle pushing symbols along with nuget package to the server, disabled by default
NO_BUILD | `false` | Flag to toggle not building the project and letting pack command handle restoring & building, disabled by default

## Outputs

Expand Down
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Action {
this.nugetKey = process.env.INPUT_NUGET_KEY || process.env.NUGET_KEY
this.nugetSource = process.env.INPUT_NUGET_SOURCE || process.env.NUGET_SOURCE
this.includeSymbols = JSON.parse(process.env.INPUT_INCLUDE_SYMBOLS || process.env.INCLUDE_SYMBOLS)
this.noBuild = JSON.parse(process.env.INPUT_NO_BUILD || process.env.NO_BUILD)
}

_printErrorAndExit(msg) {
Expand Down Expand Up @@ -57,6 +58,10 @@ class Action {

fs.readdirSync(".").filter(fn => /\.s?nupkg$/.test(fn)).forEach(fn => fs.unlinkSync(fn))

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

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

const packages = fs.readdirSync(".").filter(fn => fn.endsWith("nupkg"))
Expand Down

0 comments on commit b0539a1

Please sign in to comment.