Delete VERSION.txt #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, Test, and Release WinSatUi | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- "*" | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Cache NuGet packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.sln') }} | |
restore-keys: | | |
${{ runner.os }}-nuget- | |
- name: Set up MSBuild | |
uses: microsoft/setup-msbuild@v1 | |
- name: Restore dependencies | |
run: nuget restore WinSatUi.sln | |
- name: Build | |
run: msbuild WinSatUi.sln /p:Configuration=Release | |
- name: Run tests | |
run: | | |
# Add your test runner command here if you have tests | |
echo "No tests to run" | |
- name: Increment version number | |
id: increment_version | |
shell: pwsh | |
run: | | |
# Ensure VERSION.txt exists | |
if (-Not (Test-Path "VERSION.txt")) { | |
"1.1" > VERSION.txt | |
} | |
# Read the version from VERSION.txt | |
$version = Get-Content -Path VERSION.txt | |
# Increment the version number | |
$versionParts = $version -split '\.' | |
$versionParts[1] = [int]$versionParts[1] + 1 | |
$newVersion = "$($versionParts[0]).$($versionParts[1])" | |
# Write the new version to VERSION.txt | |
$newVersion > VERSION.txt | |
# Write the new version to an environment file | |
Write-Output "NEW_VERSION=$newVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
# Commit the new version to the repository | |
git config --global user.name "github-actions" | |
git config --global user.email "github-actions@github.com" | |
git add VERSION.txt | |
git commit -m "Increment version to $newVersion" | |
- name: Upload binaries to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: WinSatUi/bin/Release/WinSatUi.exe | |
asset_name: WinSatUi-${{ env.NEW_VERSION }}.exe | |
tag: ${{ env.NEW_VERSION }} | |
overwrite: true | |
body: ${{ github.event.workflow_run.head_commit.message }} | |