Skip to content

Update build.yml

Update build.yml #22

Workflow file for this run

name: prs-build
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: windows-latest # For a list of available runner types, refer to
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
env:
Solution_Name: PRS.sln
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
# Install the .NET Core workload
- name: Install .NET 8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
# Restore the application to populate the obj folder with RuntimeIdentifiers
- name: Build the application
run: dotnet build -c Release
# Execute all unit tests in the solution
#- name: Execute unit tests
# run: dotnet test
- name: Increase revision number
shell: pwsh
run: |
$xml_file = "./src/prs.csproj"
# Read the current PackageVersion
$package_version = (Select-String -Path $xml_file -Pattern '<PackageVersion>(.*?)<\/PackageVersion>' -AllMatches).Matches.Groups[1].Value
Write-Host "Current PackageVersion: $package_version"
# Split the version and increment the revision
$version_parts = $package_version -split '\.'
$pmajor, $pminor, $pbuild, $prevision = $version_parts
$prevision = [int]$prevision + 1
$new_package_version = "$pmajor.$pminor.$pbuild.$prevision"
Write-Host "New PackageVersion: $new_package_version"
# Update the PackageVersion in the csproj file
(Get-Content $xml_file) -replace '<PackageVersion>.*<\/PackageVersion>', "<PackageVersion>$new_package_version</PackageVersion>" | Set-Content $xml_file
Write-Host "Revision updated."
# Commit and push the changes
git config user.name "prs"
git config user.email ""
git add .
git commit -m "Update revision number to $new_package_version"
git push
Write-Host "Revision number update completed."