Update build-release.yml #2
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 and creating release | |
on: { workflow_dispatch, push: { paths-ignore: [ '**', '!*.vcxproj', '!src/**', '!.github/workflows/build-release.yml' ] } } | |
# Configuration | |
env: | |
strOutName: HelloWinHlsl | |
strOutExt: lib | |
uriGistId: 10da0f016330624e425e835fcfb75333 | |
strPatchVersionBase: 0 | |
release_artifact_name: artifact-build-release-all | |
jobs: | |
build-release: | |
runs-on: windows-latest | |
permissions: | |
contents: write # read for "actions/checkout@v3" when GITHUB_TOKEN, write for put in release | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set environment values (windows-latest) | |
run: | | |
$dirLib="${{ github.workspace }}\lib"; | |
echo "dirLib=$dirLib" >> $env:GITHUB_ENV | |
$dirLib_x86_Debug="${{ github.workspace }}\lib\x86\Debug"; | |
$dirLib_x86_Release="${{ github.workspace }}\lib\x86\Release"; | |
$dirLib_x64_Debug="${{ github.workspace }}\lib\x64\Debug"; | |
$dirLib_x64_Release="${{ github.workspace }}\lib\x64\Release"; | |
echo "dirLib_x86_Debug=$dirLib_x86_Debug" >> $env:GITHUB_ENV | |
echo "dirLib_x86_Release=$dirLib_x86_Release" >> $env:GITHUB_ENV | |
echo "dirLib_x64_Debug=$dirLib_x64_Debug" >> $env:GITHUB_ENV | |
echo "dirLib_x64_Release=$dirLib_x64_Release" >> $env:GITHUB_ENV | |
$uriVersion='gist.githubusercontent.com/${{ github.repository_owner }}/${{ env.uriGistId }}/raw' | |
echo "uriVersion=$uriVersion" >> $env:GITHUB_ENV | |
- name: Get version values | |
run: | | |
$strVersionMajor=$(curl.exe https://${{ env.uriVersion }}/VersionMajor.txt); | |
$strVersionMinor=$(curl.exe https://${{ env.uriVersion }}/VersionMinor.txt); | |
$strVersionPatch=$(curl.exe https://${{ env.uriVersion }}/VersionPatch.txt); | |
echo "strVersionMajor=$strVersionMajor" >> $env:GITHUB_ENV | |
echo "strVersionMinor=$strVersionMinor" >> $env:GITHUB_ENV | |
echo "strVersionPatch=$strVersionPatch" >> $env:GITHUB_ENV | |
$strVersionBuild=( [int]${{ env.strPatchVersionBase }} + [int]${{ github.run_number }} ) | |
echo "strVersionBuild=$strVersionBuild" >> $env:GITHUB_ENV | |
- name: Set version | |
run: | | |
$ffnVersion='src\Version.h' | |
$env:strText=[System.IO.File]::ReadAllText( $ffnVersion ); | |
Function defineReplacer_ ( $name, $value ) { | |
$env:strText=[Regex]::Replace( $env:strText, "(#define\s+$name\s+)\d+", ( '${1}' + $value ) ); | |
} | |
defineReplacer_ 'A0S_VERSION_MAJOR' ${{ env.strVersionMajor }} | |
defineReplacer_ 'A0S_VERSION_MINOR' ${{ env.strVersionMinor }} | |
defineReplacer_ 'A0S_VERSION_PATCH' ${{ env.strVersionPatch }} | |
defineReplacer_ 'A0S_VERSION_BUILD' ${{ env.strVersionBuild }} | |
[System.IO.File]::WriteAllText( $ffnVersion, $env:strText ) | |
$strMajorMinor='${{ env.strVersionMajor }}.${{ env.strVersionMinor }}'; | |
echo "strTag=$strMajorMinor" >> $env:GITHUB_ENV | |
echo "strVTag=v$strMajorMinor" >> $env:GITHUB_ENV | |
$strSemver="$strMajorMinor.${{ env.strVersionPatch }}.${{ env.strVersionBuild }}"; | |
echo "strSemver=$strSemver" >> $env:GITHUB_ENV | |
- name: Add MSBuild to PATH | |
uses: microsoft/setup-msbuild@v1.1 | |
- name: Build release | |
run: | # build from *.sln | |
MSBuild . -noLogo -verbosity:minimal -m -p:Platform=x86 -p:Configuration=Debug | |
MSBuild . -noLogo -verbosity:minimal -m -p:Platform=x86 -p:Configuration=Release | |
MSBuild . -noLogo -verbosity:minimal -m -p:Platform=x64 -p:Configuration=Debug | |
MSBuild . -noLogo -verbosity:minimal -m -p:Platform=x64 -p:Configuration=Release | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.release_artifact_name }} | |
path: | | |
${{ env.dirLib }}\**.${{ env.strOutExt }} | |
- name: Renaming to versioning names | |
run: | | |
mv -v ${{ env.dirLib_x86_Debug }}\${{ env.strOutName }}.${{ env.strOutExt }} ${{ runner.temp }}\${{ env.strOutName }}-${{ env.strTag }}-x86.${{ env.strOutExt }} | |
mv -v ${{ env.dirLib_x86_Release }}\${{ env.strOutName }}.${{ env.strOutExt }} ${{ runner.temp }}\${{ env.strOutName }}-${{ env.strTag }}-x86.${{ env.strOutExt }} | |
mv -v ${{ env.dirLib_x64_Debug }}\${{ env.strOutName }}.${{ env.strOutExt }} ${{ runner.temp }}\${{ env.strOutName }}-${{ env.strTag }}-x64.${{ env.strOutExt }} | |
mv -v ${{ env.dirLib_x64_Release }}\${{ env.strOutName }}.${{ env.strOutExt }} ${{ runner.temp }}\${{ env.strOutName }}-${{ env.strTag }}-x64.${{ env.strOutExt }} | |
- name: Replace '\\' for softprops/action-gh-release | |
run: | | |
$strGlob="${{ runner.temp }}/${{ env.strOutName }}-${{ env.strTag }}-*.${{ env.strOutExt }}"; | |
$strGlob = $strGlob -replace '\\','/'; | |
echo "strGlob=$strGlob" >> $env:GITHUB_ENV | |
# Warning: only this '/' slashes! | |
- name: Creating GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ env.strVTag }} | |
fail_on_unmatched_files: true | |
body: Version ${{ env.strSemver }} | |
files: ${{ env.strGlob }} |