Manual Release #13
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: "Manual Release" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| buildConfig: | |
| description: "Build configuration" | |
| required: true | |
| default: "Release" | |
| type: choice | |
| options: | |
| - "Release" | |
| - "Debug" | |
| releaseTypeTag: # Use -alpha, -beta, or -rc for pre-release. An empty string for stable. | |
| description: "Release type tag" | |
| required: true | |
| default: "-beta" | |
| type: choice | |
| options: | |
| - "alpha" | |
| - "beta" | |
| - "RC" | |
| - "" | |
| runLinters: | |
| description: "Run Linters" | |
| required: false | |
| default: false | |
| type: boolean | |
| unitTests: | |
| description: "Run Unit Tests" | |
| required: false | |
| default: false | |
| type: boolean | |
| publish: | |
| description: "Publish to NuGet" | |
| required: true | |
| default: true | |
| type: boolean | |
| jobs: | |
| Build: | |
| name: "Build, Test, and Publish Project" | |
| runs-on: "windows-latest" | |
| defaults: | |
| run: | |
| shell: "pwsh" | |
| strategy: | |
| matrix: | |
| BUILD_PLATFORM: [x86, x64] | |
| env: | |
| BUILD_PLATFORM: ${{matrix.BUILD_PLATFORM}} | |
| SOLUTION: ProcessMemory.sln | |
| CSPROJECT: src/ProcessMemory/ProcessMemory.csproj | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{github.ref}} | |
| - name: Read and process version.txt | |
| id: Get-Version | |
| run: | | |
| $baseVersion = (Get-Content "version.txt" -Raw).Split('.') | |
| $versionBuild = (${{vars.BUILD_NUMBER}} + 1) | |
| "VersionMajor=$($baseVersion[0])" >> $env:GITHUB_OUTPUT | |
| "VersionMinor=$($baseVersion[1])" >> $env:GITHUB_OUTPUT | |
| "VersionPatch=$($baseVersion[2])" >> $env:GITHUB_OUTPUT | |
| "VersionBuild=$versionBuild" >> $env:GITHUB_OUTPUT | |
| "VersionPreRelease=${{inputs.releaseTypeTag}}" >> $env:GITHUB_OUTPUT | |
| "VersionCommitHash=$(("${{github.sha}}".substring(0, 7)))" >> $env:GITHUB_OUTPUT | |
| - name: Get SemVer | |
| uses: Squirrelies/CI-CD/GetSemVerString@main | |
| id: Get-SemVer | |
| with: | |
| versionMajor: ${{steps.Get-Version.outputs.VersionMajor}} | |
| versionMinor: ${{steps.Get-Version.outputs.VersionMinor}} | |
| versionPatch: ${{steps.Get-Version.outputs.VersionPatch}} | |
| preRelease: ${{steps.Get-Version.outputs.VersionPreRelease}} | |
| versionBuild: ${{steps.Get-Version.outputs.VersionBuild}} | |
| commitHash: ${{steps.Get-Version.outputs.VersionCommitHash}} | |
| - name: Set versioning environment variable | |
| run: | | |
| echo 'VERSION=${{steps.Get-SemVer.outputs.Version}}' >> $env:GITHUB_ENV | |
| echo 'FILEVERSION=${{steps.Get-Version.outputs.VersionMajor}}.${{steps.Get-Version.outputs.VersionMinor}}.${{steps.Get-Version.outputs.VersionPatch}}.${{steps.Get-Version.outputs.VersionBuild}}' >> $env:GITHUB_ENV | |
| echo 'ASSEMBLYVERSION=${{steps.Get-Version.outputs.VersionMajor}}.${{steps.Get-Version.outputs.VersionMinor}}.0.0' >> $env:GITHUB_ENV | |
| - name: Build Native Library | |
| uses: Squirrelies/CI-CD/BuildMSYS2CMakeVCPkgProject@main | |
| id: build-native-library | |
| with: | |
| root-path: ./src/ProcessMemoryNative | |
| msys2-msystem: ${{ matrix.BUILD_PLATFORM == 'x64' && 'clang64' || 'mingw32' }} | |
| msys2-packages: ${{ matrix.BUILD_PLATFORM == 'x64' && 'base-devel mingw-w64-clang-x86_64-toolchain mingw-w64-clang-x86_64-cmake mingw-w64-x86_64-clang-tools-extra' || 'base-devel mingw-w64-i686-toolchain mingw-w64-i686-cmake mingw-w64-i686-clang mingw-w64-i686-lld mingw-w64-i686-clang-tools-extra mingw-w64-i686-libc++ mingw-w64-i686-headers-git' }} | |
| #vcpkg-root: C:/VCPkg | |
| preset-configuration: ${{inputs.buildConfig}} | |
| preset-configuration-tidy: ${{ inputs.runLinters == true && format('{0}-Tidy', inputs.buildConfig) || ''}} | |
| run-unit-tests: ${{inputs.unitTests}} | |
| additional-cmake-args: -DARCH=${{matrix.BUILD_PLATFORM}} -DRC_VERSION_MAJOR=${{steps.Get-Version.outputs.VersionMajor}} -DRC_VERSION_MINOR=${{steps.Get-Version.outputs.VersionMinor}} -DRC_VERSION_PATCH=${{steps.Get-Version.outputs.VersionPatch}} -DRC_VERSION_BUILD=${{steps.Get-Version.outputs.VersionBuild}} -DRC_VERSION_PRERELEASE_TAG=${{steps.Get-Version.outputs.VersionPreRelease}} -DRC_VERSION_BUILD_HASH=${{steps.Get-Version.outputs.VersionCommitHash}} | |
| - name: Setup NuGet | |
| uses: NuGet/setup-nuget@v2 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| dotnet-quality: "ga" | |
| - name: Restore NuGet Packages | |
| run: dotnet restore $env:SOLUTION --verbosity normal | |
| - name: Build .NET Project | |
| run: dotnet build $env:SOLUTION /p:"Configuration=${{inputs.buildConfig}};Platform=$env:BUILD_PLATFORM;VERSION=$env:VERSION;FILEVERSION=$env:FILEVERSION;ASSEMBLYVERSION=$env:ASSEMBLYVERSION" --no-restore --verbosity normal | |
| - name: Run .NET Project Unit Tests | |
| if: ${{ !cancelled() && inputs.unitTests == 'true' }} | |
| run: dotnet test /p:"Configuration=${{inputs.buildConfig}};Platform=$env:BUILD_PLATFORM;VERSION=$env:VERSION;FILEVERSION=$env:FILEVERSION;ASSEMBLYVERSION=$env:ASSEMBLYVERSION" --no-restore --no-build --verbosity normal | |
| - name: Publish NuGet Package | |
| if: ${{ !cancelled() && inputs.publish == 'true' }} | |
| run: nuget push **\*.nupkg -Source "https://api.nuget.org/v3/index.json" -ApiKey "${{secrets.NUGET_API_KEY}}" -SkipDuplicate | |
| - name: Update build number variable | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_VARIABLE_RW_TOKEN }} | |
| run: gh variable set BUILD_NUMBER -b${{ steps.Get-Version.outputs.VersionBuild }} |