Skip to content
name: Build and Deploy
on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master ]
defaults:
run:
working-directory: src
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
# configuration: [Debug, Release]
configuration: [Debug]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Restore dependencies
run: dotnet restore
- name: Check current directory and files
run: |
echo "Current Directory: $(pwd)"
echo "Files in current directory:"
ls -Recurse
shell: pwsh
- name: Patch csproj version and assembly version
run: |
$csproj_files = Get-ChildItem -Path '*.csproj'
$version = (Get-Content $csproj_files[0].FullName) -match '<Version>(\d+)\.(\d+)\.(\d+)</Version>' | Out-Null
$major = $matches[1]
$minor = $matches[2]
$patch = [int]$matches[3] + 1
$new_version = "$major.$minor.$patch"
foreach ($file in $csproj_files) {
(Get-Content $file.FullName) `
-replace '<Version>.*</Version>', "<Version>$new_version</Version>" `
-replace '<AssemblyVersion>.*</AssemblyVersion>', "<AssemblyVersion>$new_version.0</AssemblyVersion>" `
| Set-Content $file.FullName
}
shell: pwsh
- name: Build
run: dotnet build --configuration ${{ matrix.configuration }} --verbosity minimal
# - name: Publish NuGet package
# if: matrix.configuration == 'Release'
# run: dotnet pack --configuration Release --output ./nupkg
# - name: Push NuGet package
# if: matrix.configuration == 'Release'
# run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
- name: Create GitHub Release
if: matrix.configuration == 'Release'
uses: softprops/action-gh-release@v2
with:
tag_name: $new_version
name: $new_version
files: ./nupkg/*.nupkg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}