Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@deitry
Last active March 29, 2023 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save deitry/3c7fb46da002df6e1162a8d9159e59f6 to your computer and use it in GitHub Desktop.
Save deitry/3c7fb46da002df6e1162a8d9159e59f6 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/setup-nuget@v1.0.6
# 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