Fixed typos #330
Workflow file for this run
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 | |
on: | |
push: | |
tags: | |
- "*" | |
jobs: | |
build: | |
strategy: | |
matrix: | |
configuration: [Release] | |
platform: [x64] | |
runs-on: windows-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
with: | |
fetch-depth: 0 | |
- name: Preparing files | |
run: | | |
. "src\Scripts\Set-ReleaseTag.ps1" "${{ github.ref_name }}" | |
. "src\Scripts\Set-DebugMode.ps1" | |
- name: Downloading files | |
run: | | |
. src\Scripts\Get-Dependencies.ps1 | |
- name: Setup NuGet | |
uses: nuget/setup-nuget@main | |
with: | |
nuget-version: latest | |
- name: Restore NuGet Package | |
run: nuget restore "src\SophiApp.sln" | |
- name: Setup MSBuild | |
uses: microsoft/setup-msbuild@main | |
- name: Run MSBuild | |
run: msbuild src\SophiApp.sln /p:Configuration=$env:Configuration /p:platform=$env:Platform | |
env: | |
Platform: ${{ matrix.platform }} | |
Configuration: ${{ matrix.configuration }} | |
- name: Cleanup | |
run: | | |
Get-ChildItem -Path src\SophiApp\bin\Release -Exclude @("*.exe", "*.config") | Remove-Item -Force -Recurse -Confirm:$false | |
# Copy downloaded dependencies to the created Bin folder | |
New-Item -Path src\SophiApp\bin\Release\Bin -ItemType Directory -Force | |
Get-ChildItem -Path "src\Binary" | Copy -Destination src\SophiApp\bin\Release\Bin -Force | |
- name: Compressing folder | |
id: zip_hash | |
run: | | |
$Parameters = @{ | |
Path = "src\SophiApp\bin\Release" | |
NewName = "SophiApp" | |
PassThru = $true | |
} | |
$Build_Directory = (Rename-Item @Parameters).FullName | |
$Parameters = @{ | |
Path = $Build_Directory | |
DestinationPath = "SophiApp.zip" | |
CompressionLevel = "Optimal" | |
} | |
Compress-Archive @Parameters | |
$zip_hash = (Get-FileHash -Path SophiApp.zip -Algorithm SHA256).Hash | |
Write-Host -Object "SophiApp.zip SHA256 hash: $($zip_hash)" | |
echo "zip_hash=$zip_hash" >> $env:GITHUB_ENV | |
- name: ReleaseNotesTemplate | |
id: read_release | |
run: | | |
$Token = "${{ secrets.GITHUB_TOKEN }}" | |
$Headers = @{ | |
Accept = "application/json" | |
Authorization = "Bearer $Token" | |
} | |
$Parameters = @{ | |
Uri = "https://api.github.com/repos/Sophia-Community/SophiApp/releases" | |
Headers = $Headers | |
UseBasicParsing = $true | |
Verbose = $true | |
} | |
$Penultimate = (Invoke-RestMethod @Parameters).tag_name | Select-Object -Index 1 | |
# No need to replace special characters with percent-encoding ones | |
$Parameters = @{ | |
Uri = "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | |
UseBasicParsing = $true | |
Verbose = $true | |
} | |
$html_url = ((Invoke-RestMethod @Parameters).jobs | Where-Object -FilterScript {$_.run_id -eq "${{ github.run_id }}"}).html_url | |
(Get-Content -Path ReleaseNotesTemplate.md -Encoding utf8 -Raw).Replace("NewVersion", "${{ github.ref_name }}").Replace("OldVersion", $Penultimate).Replace("CurrentDate", $(Get-Date -f "dd.MM.yyyy")).Replace("html_url", $html_url).Replace("SHA256_hash", "${{ env.zip_hash }}") | Set-Content -Path ReleaseNotesTemplate.md -Encoding UTF8 | |
# https://en.wikipedia.org/wiki/Percent-encoding | |
Add-Content -Path $env:GITHUB_OUTPUT -Value "ReleaseBody=ReleaseNotesTemplate.md" | |
- name: Uploading | |
uses: softprops/action-gh-release@master | |
with: | |
name: ${{ github.ref_name }} | |
token: ${{ github.token }} | |
files: SophiApp.zip | |
body_path: ${{ steps.read_release.outputs.ReleaseBody }} |