Manual Release - Main #110
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: "Manual Release - Main" | |
on: | |
workflow_dispatch: | |
inputs: | |
versionMajor: | |
description: "Major Version" | |
required: false | |
default: 0 | |
type: number | |
versionMinor: | |
description: "Minor Version" | |
required: false | |
default: 1 | |
type: number | |
versionPatch: | |
description: "Patch Version" | |
required: false | |
default: 0 | |
type: number | |
unitTests: | |
description: "Run Unit Tests" | |
required: false | |
default: true | |
type: boolean | |
env: | |
VCPKG_ROOT: C:/vcpkg | |
MSYS2SYSTEM: clang64 | |
ARCH: clang-x86_64 | |
jobs: | |
Setup: | |
name: Setup Environment | |
runs-on: windows-latest | |
outputs: | |
build-number: ${{steps.build-number.outputs.current_build_number}} | |
steps: | |
- name: Setup MSYS2 ${{ env.MSYS2SYSTEM }} (${{ env.ARCH }}) | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: ${{ env.MSYS2SYSTEM }} | |
install: base-devel mingw-w64-${{ env.ARCH }}-toolchain mingw-w64-${{ env.ARCH }}-cmake | |
- name: Get new build number | |
id: build-number | |
run: | | |
$build_number = $((${{ vars.BUILD_NUMBER }} + 1)) | |
echo "current_build_number=$build_number" | Set-Content $env:GITHUB_OUTPUT | |
Build: | |
name: Build ${{matrix.configuration}} | |
runs-on: windows-latest | |
needs: Setup | |
strategy: | |
matrix: | |
configuration: [Debug, Release] | |
permissions: | |
contents: write | |
actions: write | |
attestations: write | |
defaults: | |
run: | |
shell: pwsh | |
steps: | |
- name: Setup MSYS2 ${{ env.MSYS2SYSTEM }} (${{ env.ARCH }}) | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: ${{ env.MSYS2SYSTEM }} | |
install: base-devel mingw-w64-${{ env.ARCH }}-toolchain mingw-w64-${{ env.ARCH }}-cmake | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.ref }} | |
- name: Run CMake | |
shell: msys2 {0} | |
env: | |
RC_VERSION_MAJOR: ${{inputs.versionMajor}} | |
RC_VERSION_MINOR: ${{inputs.versionMinor}} | |
RC_VERSION_PATCH: ${{inputs.versionPatch}} | |
RC_VERSION_BUILD: ${{needs.Setup.outputs.build-number}} | |
run: cmake --workflow --preset ${{matrix.configuration}} --fresh | |
- name: Run CTest | |
if: ${{ success() && inputs.unitTests == 'true' }} | |
shell: msys2 {0} | |
run: ctest --preset ${{matrix.configuration}} --output-on-failure | |
- name: Zip the publish artifacts | |
working-directory: ${{github.workspace}} | |
run: | | |
Add-Type -assembly 'System.IO.Compression' | |
Add-Type -assembly 'System.IO.Compression.FileSystem' | |
[System.IO.Compression.ZipArchive]$zipFile = [System.IO.Compression.ZipFile]::Open('RE2RRandomizer-v${{inputs.versionMajor}}.${{inputs.versionMinor}}.${{inputs.versionPatch}}-${{needs.Setup.outputs.build-number}}-${{matrix.configuration}}.zip', ([System.IO.Compression.ZipArchiveMode]::Create)) | |
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zipFile, 'build/RE2RRandomizer.exe', 'RE2RRandomizer.exe') | |
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zipFile, 'build/RE2RR.Common.dll', 'RE2RR.Common.dll') | |
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zipFile, 'build/RE2RR.Database.dll', 'RE2RR.Database.dll') | |
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zipFile, 'build/RE2RR.Types.dll', 'RE2RR.Types.dll') | |
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zipFile, 'build/RE2RR.Hook.dll', 'RE2RR.Hook.dll') | |
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zipFile, 'LICENSE', 'LICENSE') | |
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zipFile, 'README.md', 'README.md') | |
$zipFile.Dispose() | |
- name: Upload publish artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: RE2RRandomizer-v${{inputs.versionMajor}}.${{inputs.versionMinor}}.${{inputs.versionPatch}}-${{needs.Setup.outputs.build-number}}-${{matrix.configuration}} | |
path: | | |
RE2RRandomizer-v${{inputs.versionMajor}}.${{inputs.versionMinor}}.${{inputs.versionPatch}}-${{needs.Setup.outputs.build-number}}-${{matrix.configuration}}.zip | |
Publish: | |
name: Publish ${{matrix.configuration}} | |
runs-on: windows-latest | |
needs: [Setup, Build] | |
strategy: | |
matrix: | |
configuration: [Debug, Release] | |
defaults: | |
run: | |
shell: pwsh | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: RE2RRandomizer-v${{inputs.versionMajor}}.${{inputs.versionMinor}}.${{inputs.versionPatch}}-${{needs.Setup.outputs.build-number}}-${{matrix.configuration}} | |
- name: Publish | |
uses: marvinpinto/action-automatic-releases@latest | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
automatic_release_tag: "${{matrix.configuration}}-build" | |
prerelease: true | |
title: "Manual Build [main] - v${{inputs.versionMajor}}.${{inputs.versionMinor}}.${{inputs.versionPatch}}-${{needs.Setup.outputs.build-number}} Release" | |
files: | | |
RE2RRandomizer-v${{inputs.versionMajor}}.${{inputs.versionMinor}}.${{inputs.versionPatch}}-${{needs.Setup.outputs.build-number}}-${{matrix.configuration}}.zip | |
PostRun: | |
name: Post-Run | |
runs-on: windows-latest | |
needs: [Setup, Build, Publish] | |
defaults: | |
run: | |
shell: pwsh | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.ref }} | |
- name: Update build number variable | |
env: | |
GH_TOKEN: ${{ secrets.GH_VARIABLE_RW_TOKEN }} | |
run: gh variable set BUILD_NUMBER -b${{ needs.Setup.outputs.build-number }} |