Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save diev/e2fa3e70f0a0199143f122c613fa034f to your computer and use it in GitHub Desktop.

Select an option

Save diev/e2fa3e70f0a0199143f122c613fa034f to your computer and use it in GitHub Desktop.
Simple GitHub action to build NuGet package on tags push
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}}
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