Scheduled Build #145
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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
name: Build | |
on: | |
schedule: | |
- cron: '0 4 * * *' | |
workflow_dispatch: | |
# push: | |
# branches: [ "master" ] | |
# pull_request: | |
# branches: [ "master" ] | |
env: | |
# Path to the solution file relative to the root of the project. | |
SOLUTION_FILE_PATH: . | |
# Configuration type to build. | |
# You can convert this to a build matrix if you need coverage of multiple configuration types. | |
# https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix | |
BUILD_CONFIGURATION: Release | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'true' | |
- name: Extract Version | |
id: get_version | |
working-directory: ${{ github.workspace }} | |
shell: powershell | |
run: | | |
$resourceFile = ".\OptiScaler\resource.h" | |
if (-Not (Test-Path $resourceFile)) { | |
Write-Error "File not found: $resourceFile" | |
exit 1 | |
} | |
# Helper function to extract a version component | |
function Get-Version-Component { | |
param ( | |
[string]$pattern, | |
[string]$replacement | |
) | |
$line = Get-Content $resourceFile | Select-String $pattern | Select-Object -First 1 | |
if ($line) { | |
return ($line -replace $replacement).Trim() | |
} else { | |
Write-Error "Pattern not found: $pattern" | |
exit 1 | |
} | |
} | |
# Extract version components | |
$majorVersion = Get-Version-Component 'VER_MAJOR_VERSION' '#define VER_MAJOR_VERSION\s+' | |
$minorVersion = Get-Version-Component 'VER_MINOR_VERSION' '#define VER_MINOR_VERSION\s+' | |
$hotfixVersion = Get-Version-Component 'VER_HOTFIX_VERSION' '#define VER_HOTFIX_VERSION\s+' | |
$buildVersion = Get-Version-Component 'VER_BUILD_NUMBER' '#define VER_BUILD_NUMBER\s+' | |
# Merge into a single version string | |
$version = "$majorVersion.$minorVersion.$hotfixVersion-pre$buildVersion" | |
# Output the version | |
Write-Output "Extracted Version: $version" | |
# Optionally set the version as an output | |
echo "::set-output name=version::$version" | |
continue-on-error: false | |
- name: Add MSBuild to PATH | |
uses: microsoft/setup-msbuild@v2 | |
- name: Build | |
working-directory: ${{env.GITHUB_WORKSPACE}} | |
# Add additional options to the MSBuild command line here (like platform or verbosity level). | |
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference | |
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}} | |
- name: Compress the artifact | |
run: | | |
$zipName = "OptiScaler_${{ steps.get_version.outputs.version }}.7z" | |
7z a ${{ github.workspace }}\$zipName ${{ github.workspace }}\x64\Release\a\*.* | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: OptiScaler_${{ steps.get_version.outputs.version }} | |
path: ${{ github.workspace }}\OptiScaler_${{ steps.get_version.outputs.version }}.7z | |
compression-level: 0 | |
if-no-files-found: error |