-
-
Save diev/e2fa3e70f0a0199143f122c613fa034f to your computer and use it in GitHub Desktop.
Simple GitHub action to build NuGet package on tags push
This file contains hidden or 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: Build NuGet package and push to GitHub registry | |
| on: | |
| workflow_call: | |
| inputs: | |
| organizationName: | |
| required: true | |
| type: string | |
| nuspecPath: | |
| required: true | |
| type: string | |
| nugetPackageName: | |
| required: true | |
| type: string | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Setup NuGet.exe for use with actions | |
| uses: NuGet/[email protected] | |
| # requires <version>$PackageVersion</version> in .nuspec | |
| - name: Create NuGet package | |
| id: nugetPack | |
| run: | | |
| $version = git describe --tags --abbrev=0 | |
| echo "::set-output name=version::$version" | |
| ( Get-Content -Path "${{ inputs.nuspecPath }}" ) ` | |
| .replace('$PackageVersion', "$version") | |
| | Set-Content ${{ inputs.nuspecPath }} | |
| nuget pack ${{ inputs.nuspecPath }} -Version $version | |
| - name: Setup NuGet Source | |
| run: | | |
| nuget sources Add ` | |
| -Name github ` | |
| -Source "https://nuget.pkg.github.com/${{ inputs.organizationName }}/index.json" ` | |
| -UserName ${{ github.actor }} ` | |
| -Password ${{ secrets.GITHUB_TOKEN }} ` | |
| -StorePasswordInClearText | |
| - name: Publish NuGet package | |
| run: | | |
| nuget push ` | |
| ${{ inputs.nugetPackageName }}.${{ steps.nugetPack.outputs.version }}.nupkg ` | |
| -Source "github" ` | |
| -ApiKey ${{secrets.GITHUB_TOKEN}} |
This file contains hidden or 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
| on: | |
| push: | |
| tags: | |
| - '*' | |
| jobs: | |
| buildPackage: | |
| uses: ./.github/workflows/make-nuget-with-tag-version.yml | |
| with: | |
| organizationName: *** | |
| nuspecPath: "SDK/SDK.nuspec" | |
| nugetPackageName: SDK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment