Skip to content

Commit

Permalink
Merge pull request #51 from dotnet/addFeed
Browse files Browse the repository at this point in the history
Add the `toolFeed` optional input to the nbgv Action
  • Loading branch information
AArnott authored Sep 9, 2022
2 parents d93f8b6 + 9d582b3 commit bbee33c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ All inputs are optional.
`setAllVars`|false|Defines ALL version variables as environment variables, with a "NBGV_" prefix. Adds the `--all-vars` switch to the `nbgv cloud` command.
`stamp`||The path to a file whose version setting should be changed to match the computed version. Supported file types: `package.json`
`toolVersion`|latest stable|The version of the nbgv dotnet CLI tool to install and use. If not specified, the default is the latest stable version.
`toolFeed`|nuget.config content|An additional feed to search for the nbgv dotnet CLI tool. Default feeds may include https://api.nuget.org/v3/index.json or whatever is specified in a nuget.config file at the root of your repo.

## Outputs

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ inputs:
toolVersion:
description: The version of the nbgv dotnet CLI tool to install and use. If not specified, the default is the latest stable version.
required: false
toolFeed:
description: An additional feed to search for the nbgv dotnet CLI tool. Default feeds may include https://api.nuget.org/v3/index.json or whatever is specified in a nuget.config file at the root of your repo.
required: false
outputs:
CloudBuildNumber:
description: The cloud build number
Expand Down
8 changes: 8 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1606,8 +1606,12 @@ async function run() {
try {
let installArgs = ['tool', 'install', '-g', 'nbgv'];
if (settings_1.Inputs.toolVersion) {
installArgs[1] = 'update';
installArgs.push('--version', settings_1.Inputs.toolVersion);
}
if (settings_1.Inputs.toolFeed) {
installArgs.push('--add-source', settings_1.Inputs.toolFeed);
}
let exitCode = await exec_1.exec('dotnet', installArgs, { ignoreReturnCode: true });
if (exitCode > 1) {
throw new Error("dotnet tool install failed.");
Expand Down Expand Up @@ -2591,6 +2595,10 @@ class Inputs {
const result = core.getInput('toolVersion');
return result === '' || result === null ? undefined : result;
}
static get toolFeed() {
const result = core.getInput('toolFeed');
return result === '' || result === null ? undefined : result;
}
}
exports.Inputs = Inputs;

Expand Down
5 changes: 5 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ async function run() {
// install nbgv
let installArgs = ['tool', 'install', '-g', 'nbgv'];
if (Inputs.toolVersion) {
installArgs[1] = 'update'; // using 'update' will either install, or will change the version to what we want.
installArgs.push('--version', Inputs.toolVersion);
}

if (Inputs.toolFeed) {
installArgs.push('--add-source', Inputs.toolFeed);
}

let exitCode = await exec('dotnet', installArgs, { ignoreReturnCode: true });
if (exitCode > 1) {
throw new Error("dotnet tool install failed.");
Expand Down
5 changes: 5 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ export class Inputs {
const result = core.getInput('toolVersion');
return result === '' || result === null ? undefined : result;
}

static get toolFeed(): string | undefined {
const result = core.getInput('toolFeed');
return result === '' || result === null ? undefined : result;
}
}

0 comments on commit bbee33c

Please sign in to comment.