Skip to content

Build and Pack NuGet #5

Build and Pack NuGet

Build and Pack NuGet #5

Workflow file for this run

name: Build and Pack NuGet
on:
workflow_dispatch: # Manual trigger
push:
tags:
- 'v*' # Trigger on version tags like v1.6.11
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set version number
id: version
run: |
$version = "1.6.11"
echo "VERSION=$version" >> $env:GITHUB_ENV
echo "Version will be: $version"
shell: pwsh
- name: Update GlobalAssemblyInfo.cs
run: |
$file = "Source/Common/GlobalAssemblyInfo.cs"
$content = Get-Content $file -Raw
$content = $content -replace '\[assembly: AssemblyVersion\("[\d\.]+"\)\]', "[assembly: AssemblyVersion(""$env:VERSION.0"")]"
$content = $content -replace '\[assembly: AssemblyFileVersion\("[\d\.]+"\)\]', "[assembly: AssemblyFileVersion(""$env:VERSION.0"")]"
Set-Content $file $content
echo "Updated GlobalAssemblyInfo.cs to version $env:VERSION.0"
shell: pwsh
- name: Update nuspec version
run: |
$file = "Nuget/WriteableBitmapEx.nuspec"
$content = Get-Content $file -Raw
$content = $content -replace '<version>[\d\.]+</version>', "<version>$env:VERSION</version>"
Set-Content $file $content
echo "Updated nuspec to version $env:VERSION"
shell: pwsh
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
6.0.x
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Restore NuGet packages
run: nuget restore Solution/WriteableBitmapEx_All.sln
- name: Build WPF Library
run: dotnet build Source/WriteableBitmapEx.Wpf/WriteableBitmapEx.Wpf.csproj -c Release /p:EnableWindowsTargeting=true
- name: List Build outputs
run: |
echo "Build/Release directory contents:"
dir Build\Release /s
shell: cmd
- name: Pack NuGet package
run: |
cd Nuget
..\3rdParty\nuget\nuget pack WriteableBitmapEx.nuspec -OutputDirectory ..\Build\nuget
shell: cmd
- name: Upload NuGet package as artifact
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: Build/nuget/*.nupkg
- name: Publish to NuGet
run: |
3rdParty\nuget\nuget push Build\nuget\*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_API_KEY }}
shell: cmd