Skip to content

Build and creating release #15

Build and creating release

Build and creating release #15

Workflow file for this run

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
$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
- name: Renaming to versioning names
run: |
mv -v ${{ github.workspace }}\lib\x86\Debug\${{ env.strOutName }}.${{ env.strOutExt }} ${{ runner.temp }}\${{ env.strOutName }}-${{ env.strTag }}-x86-Debug.${{ env.strOutExt }}
mv -v ${{ github.workspace }}\lib\x86\Release\${{ env.strOutName }}.${{ env.strOutExt }} ${{ runner.temp }}\${{ env.strOutName }}-${{ env.strTag }}-x86-Release.${{ env.strOutExt }}
mv -v ${{ github.workspace }}\lib\x64\Debug\${{ env.strOutName }}.${{ env.strOutExt }} ${{ runner.temp }}\${{ env.strOutName }}-${{ env.strTag }}-x64-Debug.${{ env.strOutExt }}
mv -v ${{ github.workspace }}\lib\x64\Release\${{ env.strOutName }}.${{ env.strOutExt }} ${{ runner.temp }}\${{ env.strOutName }}-${{ env.strTag }}-x64-Release.${{ env.strOutExt }}
Compress-Archive -Path ${{ runner.temp }}\${{ env.strOutName }}-${{ env.strTag }}-x86-Debug.${{ env.strOutExt }} ${{ runner.temp }}\${{ env.strOutName }}-${{ env.strTag }}-x86-Debug.${{ env.strOutExt }}.zip
Compress-Archive -Path ${{ runner.temp }}\${{ env.strOutName }}-${{ env.strTag }}-x86-Release.${{ env.strOutExt }} ${{ runner.temp }}\${{ env.strOutName }}-${{ env.strTag }}-x86-Release.${{ env.strOutExt }}.zip
Compress-Archive -Path ${{ runner.temp }}\${{ env.strOutName }}-${{ env.strTag }}-x64-Debug.${{ env.strOutExt }} ${{ runner.temp }}\${{ env.strOutName }}-${{ env.strTag }}-x64-Debug.${{ env.strOutExt }}.zip
Compress-Archive -Path ${{ runner.temp }}\${{ env.strOutName }}-${{ env.strTag }}-x64-Release.${{ env.strOutExt }} ${{ runner.temp }}\${{ env.strOutName }}-${{ env.strTag }}-x64-Release.${{ env.strOutExt }}.zip
- name: Replace '\\' for softprops/action-gh-release
run: |
$strGlob="${{ runner.temp }}/${{ env.strOutName }}-${{ env.strTag }}-*.${{ env.strOutExt }}.zip";
$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 }}