Fix build steps #75
Workflow file for this run
This file contains hidden or 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: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| permissions: | |
| contents: write # needed for creating releases | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Determine version from tag | |
| shell: pwsh | |
| run: | | |
| # e.g. GITHUB_REF_NAME = v1.2.3 -> VERSION = 1.2.3 | |
| $version = "${env:GITHUB_REF_NAME}".TrimStart('v') | |
| "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| Write-Host "Version: $version" | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' # 8.x SDK can build net5.0 projects | |
| - name: Cache NuGet | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/packages.lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget- | |
| - name: Restore dependencies | |
| run: dotnet restore Mapping_Tools | |
| # Update versions in installer scripts and .csproj using PowerShell regex | |
| - name: Set version in Inno Setup (x86) | |
| shell: pwsh | |
| run: | | |
| (Get-Content -Raw Installer_Script_x86.iss) ` | |
| -replace '(?<=#define\s+MyAppVersion\s+")\d+\.\d+\.\d+(?=")', "${env:VERSION}" ` | |
| | Set-Content Installer_Script_x86.iss -Encoding UTF8 | |
| - name: Set version in Inno Setup (x64) | |
| shell: pwsh | |
| run: | | |
| (Get-Content -Raw Installer_Script_x64.iss) ` | |
| -replace '(?<=#define\s+MyAppVersion\s+")\d+\.\d+\.\d+(?=")', "${env:VERSION}" ` | |
| | Set-Content Installer_Script_x64.iss -Encoding UTF8 | |
| - name: Set AssemblyVersion/FileVersion in csproj | |
| shell: pwsh | |
| run: | | |
| $p = "Mapping_Tools/Mapping_Tools.csproj" | |
| $c = Get-Content -Raw $p | |
| $c = $c -replace '(?<=<AssemblyVersion>)\d+\.\d+\.\d+', "${env:VERSION}" | |
| $c = $c -replace '(?<=<FileVersion>)\d+\.\d+\.\d+', "${env:VERSION}" | |
| $c | Set-Content $p -Encoding UTF8 | |
| - name: Publish x86 | |
| run: dotnet publish Mapping_Tools -c Release -r win-x86 --no-restore --self-contained false | |
| - name: Publish x64 | |
| run: dotnet publish Mapping_Tools -c Release -r win-x64 --no-restore --self-contained false | |
| - name: Install Inno Setup | |
| shell: pwsh | |
| run: choco install innosetup --yes | |
| - name: Build x86 Installer | |
| shell: pwsh | |
| run: '& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "Installer_Script_x86.iss"' | |
| - name: Build x64 Installer | |
| shell: pwsh | |
| run: '& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "Installer_Script_x64.iss"' | |
| - name: Zip x86 app | |
| shell: pwsh | |
| run: | | |
| $outDir = "Mapping_Tools/bin/Release/net5.0-windows/win-x86/publish" | |
| Compress-Archive -Path "$outDir/*" -DestinationPath "$outDir/release.zip" -Force | |
| - name: Zip x64 app | |
| shell: pwsh | |
| run: | | |
| $outDir = "Mapping_Tools/bin/Release/net5.0-windows/win-x64/publish" | |
| Compress-Archive -Path "$outDir/*" -DestinationPath "$outDir/release_x64.zip" -Force | |
| - name: Publish GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: Release version ${{ env.VERSION }} | |
| tag_name: ${{ github.ref_name }} | |
| draft: false | |
| prerelease: false | |
| files: | | |
| Mapping_Tools/bin/Release/net5.0-windows/win-x86/publish/release.zip | |
| Mapping_Tools/bin/Release/net5.0-windows/win-x64/publish/release_x64.zip | |
| **\mapping_tools_installer_x86.exe | |
| **\mapping_tools_installer_x64.exe |