Publish Nuget #373
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Publish Nuget' | |
on: | |
workflow_run: | |
workflows: [' CI/CD'] | |
types: [completed] | |
branches: ['main'] | |
permissions: | |
contents: write | |
packages: write | |
defaults: | |
run: | |
shell: powershell | |
env: | |
buildArtifactsPath: ${{ github.workspace }}/.artifacts | |
packageOutputPath: ${{ github.workspace }}/out | |
repoName: ${{ github.event.repository.name }} | |
jobs: | |
Publish: | |
if: github.event.workflow_run.conclusion == 'success' && github.repository_owner == 'microsoft' | |
runs-on: [ windows-latest ] | |
name: Publish Nuget | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download Build Output | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh run download ${{ github.event.workflow_run.id }} --pattern '*Apps-*' --dir $env:buildArtifactsPath | |
- name: Setup NuGet.exe | |
uses: nuget/setup-nuget@v1 | |
- name: Prepare Package | |
run: | | |
Build/Scripts/Package/PackNuget.ps1 -BuildArtifactsPath $env:buildArtifactsPath -OutputPackageFolder $env:packageOutputPath -RepoName $env:repoName -RepoOwner $env:GITHUB_REPOSITORY_OWNER | |
- name: Push Package | |
run: | | |
$nugetSource = "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" | |
nuget sources add -Name "Github" -Source $nugetSource -Username NotUsed -Password ${{ secrets.GITHUB_TOKEN }} | |
Get-ChildItem -Path "$($env:packageOutputPath)/*nupkg" | % { | |
Write-Host "Pushing package $($_.Name) to $nugetSource" | |
nuget push $($_.FullName) -Source "Github" -ApiKey ${{ secrets.GITHUB_TOKEN }} | |
Write-Host "Pushing package $($_.Name) to nuget.org" | |
nuget push $($_.FullName) -Source "https://api.nuget.org/v3/index.json" -ApiKey ${{ secrets.NUGETTOKEN }} | |
} |