Last active
March 29, 2023 21:53
-
-
Save deitry/02311c4f5729b0ae97eb8a7c0093a179 to your computer and use it in GitHub Desktop.
Simple GitHub action to build NuGet package
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: 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/setup-nuget@v1.0.6 | |
- name: Create NuGet package | |
id: nugetPack | |
run: | | |
$xml = [xml](Get-Content ${{inputs.nuspecPath}}) | |
$version = $xml.package.metadata.version | |
echo "::set-output name=version::$version" | |
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}} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment