diff --git a/README.md b/README.md index 0a512bc..aae4c19 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,27 @@ steps: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true ``` +Authentication to Azure Artifacts: +```yaml +steps: +- uses: actions/checkout@master +- uses: actions/setup-dotnet@v1 + with: + dotnet-version: '2.2.103' # SDK Version to use. + source-url: https://pkgs.dev.azure.com//_packaging//nuget/v3/index.json + env: + NUGET_AUTH_TOKEN: ${{secrets.AZURE_DEVOPS_PAT}} # Note, create a secret with this name in Settings +- run: dotnet build +- name: Create the package + run: dotnet pack --configuration Release + env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + - name: Publish the package + run: dotnet nuget push /bin/Release/*.nupkg + env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true +``` + # License The scripts and documentation in this project are released under the [MIT License](LICENSE) diff --git a/__tests__/__snapshots__/authutil.test.ts.snap b/__tests__/__snapshots__/authutil.test.ts.snap index 245ced7..6944c78 100644 --- a/__tests__/__snapshots__/authutil.test.ts.snap +++ b/__tests__/__snapshots__/authutil.test.ts.snap @@ -4,7 +4,7 @@ exports[`authutil tests Existing config not in repo root, sets up a partial NuGe " - + @@ -34,7 +34,7 @@ exports[`authutil tests Existing config w/ GPR source and NuGet.org, sets up a p " - + @@ -49,10 +49,10 @@ exports[`authutil tests Existing config w/ no GPR sources, sets up a full NuGet. " - + - + @@ -67,10 +67,10 @@ exports[`authutil tests Existing config w/ no sources, sets up a full NuGet.conf " - + - + @@ -100,7 +100,7 @@ exports[`authutil tests Existing config w/ only GPR source, sets up a partial Nu " - + @@ -115,7 +115,7 @@ exports[`authutil tests Existing config w/ two GPR sources, sets up a partial Nu " - + @@ -134,10 +134,10 @@ exports[`authutil tests No existing config, sets up a full NuGet.config with URL " - + - + @@ -170,10 +170,10 @@ exports[`authutil tests No existing config, sets up a full NuGet.config with URL " - + - + diff --git a/lib/authutil.js b/lib/authutil.js index 7c98a9f..6e229e0 100644 --- a/lib/authutil.js +++ b/lib/authutil.js @@ -29,7 +29,7 @@ function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) { owner = github.context.repo.owner; } if (feedUrl.indexOf('nuget.pkg.github.com') > -1) { - sourceUrl = 'https://nuget.pkg.github.com/' + owner; + sourceUrl = 'https://nuget.pkg.github.com/' + owner + '/index.json'; } if (!process.env.NUGET_AUTH_TOKEN || process.env.NUGET_AUTH_TOKEN == '') { throw new Error('The NUGET_AUTH_TOKEN environment variable was not provided. In this step, add the following: \r\nenv:\r\n NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}'); @@ -85,13 +85,13 @@ function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) { .up(); sourceKeys.push(keystring); } - xml = xml - .ele('packageSourceCredentials'); + xml = xml.ele('packageSourceCredentials'); sourceKeys.forEach(key => { if (key.indexOf(' ') > -1) { throw new Error("This action currently can't handle source names with spaces. Remove the space from your repo's NuGet.config and try again."); } - xml = xml.ele(key) + xml = xml + .ele(key) .ele('add', { key: 'Username', value: owner }) .up() .ele('add', { diff --git a/src/authutil.ts b/src/authutil.ts index 2979bb6..d1a6992 100644 --- a/src/authutil.ts +++ b/src/authutil.ts @@ -41,7 +41,7 @@ function writeFeedToFile( owner = github.context.repo.owner; } if (feedUrl.indexOf('nuget.pkg.github.com') > -1) { - sourceUrl = 'https://nuget.pkg.github.com/' + owner; + sourceUrl = 'https://nuget.pkg.github.com/' + owner + '/index.json'; } if (!process.env.NUGET_AUTH_TOKEN || process.env.NUGET_AUTH_TOKEN == '') {