From 799e35bafc6566c96f8b828424cafc052a262ce0 Mon Sep 17 00:00:00 2001 From: Benjamen Meyer Date: Sat, 23 Mar 2024 00:05:26 -0400 Subject: [PATCH 1/3] Enhancement: Mac/Win Release processes We had the Linux Release methods; now add them for Mac and Windows --- .github/workflows/Windows-CI.yml | 4 +- .github/workflows/Windows-Release.yml | 120 ++++++++++++++++++++++++++ .github/workflows/macos-release.yml | 108 +++++++++++++++++++++++ script/build.ps1 | 9 +- 4 files changed, 239 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/Windows-Release.yml create mode 100644 .github/workflows/macos-release.yml diff --git a/.github/workflows/Windows-CI.yml b/.github/workflows/Windows-CI.yml index eee73215a8..5292514802 100644 --- a/.github/workflows/Windows-CI.yml +++ b/.github/workflows/Windows-CI.yml @@ -23,10 +23,12 @@ jobs: cmake-generator: VS2019Win64 enable-pie: 1 build-type: Release + is-release: 0 - os: windows-2022 cmake-generator: VS2022Win64 enable-pie: 1 build-type: Debug + is-release: 0 env: # Indicates the location of vcpkg @@ -89,7 +91,7 @@ jobs: - name: run-build-script working-directory: ${{ github.workspace }} - run: .\script\build.ps1 -Generator ${{ matrix.cmake-generator }} -EnablePIE ${{ matrix.enable-pie }} -BuildType ${{ matrix.build-type }} + run: .\script\build.ps1 -Generator ${{ matrix.cmake-generator }} -EnablePIE ${{ matrix.enable-pie }} -BuildType ${{ matrix.build-type }} -IsRelease ${{ matrix.is-release }} - name: Test working-directory: ${{ github.workspace }} diff --git a/.github/workflows/Windows-Release.yml b/.github/workflows/Windows-Release.yml new file mode 100644 index 0000000000..7cb4e38872 --- /dev/null +++ b/.github/workflows/Windows-Release.yml @@ -0,0 +1,120 @@ +name: Windows-CI + +# Controls when the action will run. +on: + release: + types: + - created + - edited + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + include: + - os: windows-2019 + cmake-generator: VS2019Win64 + enable-pie: 1 + build-type: Release + is-release: 1 + - os: windows-2022 + cmake-generator: VS2022Win64 + enable-pie: 1 + build-type: Debug + is-release: 1 + + env: + # Indicates the location of vcpkg + VCPKG_ROOT: '${{ github.workspace }}/v' + # Tells vcpkg where binary packages are stored. + VCPKG_DEFAULT_BINARY_CACHE: '${{ github.workspace }}/vbincache' + ## Let's use GitHub Action cache as storage for the vcpkg Binary Caching feature. + #VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite' + VCPKG_DEFAULT_TRIPLET: x64-windows + VCPKG_DEFAULT_HOST_TRIPLET: x64-windows + PYTHONHOME: '${{ github.workspace }}/v/packages/python3_x64-windows/tools/python3' + TAG_NAME: '${{ github.ref_name }}' + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Set env vars needed for vcpkg to leverage the GitHub Action cache as a storage + # for Binary Caching. + # Also process the `github.sha` value to produce the SHORT_SHA we'll need later + - uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 #v6.4.1 + with: + script: | + const git_sha = context.sha.substring(0, 7) + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('SHORT_SHA', git_sha); + + - name: Test tag name and short SHA + run: | + echo "${TAG_NAME}" + echo "${SHORT_SHA}" + + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 + + - name: "Create directory '${{ env.VCPKG_DEFAULT_BINARY_CACHE }}'" + run: mkdir -p $VCPKG_DEFAULT_BINARY_CACHE + shell: bash + + - name: install-cmake + uses: lukka/get-cmake@359fbae4b163fa01633e6de228fa7f2a31ab1fc7 #v3.26.1 + with: + cmakeVersion: 3.26.1 + ninjaVersion: 1.11.1 + + # # Restore vcpkg from the GitHub Action cache service. Note that packages are restored by vcpkg's binary caching + # # when it is being run afterward by CMake. + # - name: restore-vcpkg + # uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 #v3.3.1 + # with: + # # The first path is the location of vcpkg: it contains the vcpkg executable and data files, as long as the + # # built package archives (aka binary cache) which are located by VCPKG_DEFAULT_BINARY_CACHE env var. + # # The other paths starting with '!' are exclusions: they contain temporary files generated during the build of the installed packages. + # path: | + # ${{ env.VCPKG_ROOT }} + # !${{ env.VCPKG_ROOT }}/buildtrees + # !${{ env.VCPKG_ROOT }}/packages + # !${{ env.VCPKG_ROOT }}/downloads + # !${{ env.VCPKG_ROOT }}/installed + # # The key is composed in a way that it gets properly invalidated whenever a different version of vcpkg is being used. + # key: | + # ${{ hashFiles( '.git/modules/vcpkg/HEAD' )}} + + - name: install-vcpkg + #if: steps.cache.outputs.cache-hit != 'true' + run: | + git clone https://github.com/vegastrike/vcpkg-local.git ${{ env.VCPKG_ROOT }} + ${{ env.VCPKG_ROOT }}\bootstrap-vcpkg.bat -disableMetrics + + - name: run-build-script + working-directory: ${{ github.workspace }} + run: .\script\build.ps1 -Generator ${{ matrix.cmake-generator }} -EnablePIE ${{ matrix.enable-pie }} -BuildType ${{ matrix.build-type }} -IsRelease ${{ matrix.is-release }} -GitTag ${{ env.TAG_NAME }} -GitSha ${{ env.SHORT_SHA }} + + - name: Test + working-directory: ${{ github.workspace }} + env: + GTEST_OUTPUT: xml + GTEST_COLOR: 1 + run: .\script\test.ps1 -Generator ${{ matrix.cmake-generator }} -EnablePIE ${{ matrix.enable-pie }} -BuildType ${{ matrix.build-type }} + + - name: Upload artifacts + uses: skx/github-action-publish-binaries@44887b225ceca96efd8a912d39c09ad70312af31 # master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ARTIFACT_EXT: ${{ matrix.ARTIFACT_EXT }} + with: + path: "${{ github.workspace }}/**/*.zip" diff --git a/.github/workflows/macos-release.yml b/.github/workflows/macos-release.yml new file mode 100644 index 0000000000..f2c437a901 --- /dev/null +++ b/.github/workflows/macos-release.yml @@ -0,0 +1,108 @@ +name: 'MacOS-CI' + +on: + release: + types: + - created + - edited + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build: + name: Build + runs-on: ${{ matrix.os }} + continue-on-error: true + + defaults: + run: + shell: bash + + strategy: + fail-fast: false + matrix: + os: + #- macos-11 + - macos-12 + compiler: + - clang + - gcc + homebrew-gl: + - true + # - false + homebrew-al: + - true + - false + + steps: + + # The following dependencies are already present within macos-* images: + # - clang (llvm) + # - cmake + # - expat + # - gcc + # - git + # - jpeg + # - libpng + # - libvorbis + # - python + - name: Install dependencies using homebrew + run: brew install boost-python3 gtk+3 gtkglext sdl + + # The following Apple-provided libraries are deprecated: + # * OpenGL as of macOS 10.14 + # * GLUT as of macOS 10.9 + - name: Optionally install homebrewed OpenGL and GLUT + if: ${{ matrix.homebrew-gl }} + run: | + brew install mesa mesa-glu freeglut + ln -s /usr/local/include/GL /usr/local/include/OpenGL + ln -s /usr/local/include/GL /usr/local/include/GLUT + # ln -s /usr/local/lib/libGL.dylib /usr/local/lib/libOpenGL.dylib + # find /usr/local/lib/ -iname '*gl*.dylib' + + # The Apple-provided OpenAL is deprecated as of macOS 10.15 + - name: Optionally install homebrewed OpenAL + if: ${{ matrix.homebrew-al }} + run: brew install openal-soft + + - name: Check out repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 + with: + fetch-depth: 2 + submodules: false + + - name: Extract tag name and short SHA + shell: bash + run: | + echo "TAG_NAME=$(echo ${GITHUB_REF#refs/tags/} | sed 's/\//_/g')" >> $GITHUB_ENV + echo "SHORT_SHA=`git rev-parse --short HEAD`" >> $GITHUB_ENV + - name: Test tag name and short SHA + run: | + echo "${TAG_NAME}" + echo "${SHORT_SHA}" + + - name: Build it + env: + MY_OS_NAME: macos + COMPILER: ${{ matrix.compiler }} + FLAGS: -DCMAKE_FIND_FRAMEWORK=LAST + OPENALDIR: "/usr/local/opt/openal-soft" + IS_RELEASE: 1 + run: script/cibuild $FLAGS + + - name: Test + working-directory: ${{github.workspace}}/build + env: + GTEST_OUTPUT: xml + GTEST_COLOR: 1 + run: ctest -V + + - name: Upload the artifacts + uses: skx/github-action-publish-binaries@44887b225ceca96efd8a912d39c09ad70312af31 # master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ARTIFACT_EXT: ${{ matrix.ARTIFACT_EXT }} + with: + args: "packages/*.${{ matrix.ARTIFACT_EXT }}" diff --git a/script/build.ps1 b/script/build.ps1 index b4515adca4..940271d176 100644 --- a/script/build.ps1 +++ b/script/build.ps1 @@ -23,7 +23,10 @@ param( [String]$Generator = "VS2019Win64", # Other options include "ninja" and "VS2022Win64" [Boolean]$EnablePIE = $false, - [String]$BuildType = "Release" # You can also specify "Debug" + [String]$BuildType = "Release", # You can also specify "Debug" + [Boolean]$IsRelease = $false, + [String]$GitTag = "" # Git Tag, default empty string for PR builds + [String]$GitSha = "" # Git Short SHA Reference, default empty string for PR builds ) [String]$cmakePresetName = "" @@ -67,3 +70,7 @@ $aPossibleBinaryDirs | ForEach-Object { Copy-Item -Force -Verbose $_\*.* .\bin } } + +if ($IsRelease) { + Compress-Archive .\bin\* "VegaStrike_${GitTag}_${GitSha}.zip" +} From 13570936ed4b69c4abf6516e88629881d210efd9 Mon Sep 17 00:00:00 2001 From: Benjamen Meyer Date: Sun, 24 Mar 2024 00:45:06 -0400 Subject: [PATCH 2/3] Bug Fix: hack around powershell not allowing empty string parameters --- script/build.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/script/build.ps1 b/script/build.ps1 index 940271d176..292885a1c7 100644 --- a/script/build.ps1 +++ b/script/build.ps1 @@ -25,10 +25,18 @@ param( [Boolean]$EnablePIE = $false, [String]$BuildType = "Release", # You can also specify "Debug" [Boolean]$IsRelease = $false, - [String]$GitTag = "" # Git Tag, default empty string for PR builds - [String]$GitSha = "" # Git Short SHA Reference, default empty string for PR builds + [String]$GitTag = "not-applicable" # Git Tag, default empty string for PR builds + [String]$GitSha = "not-applicable" # Git Short SHA Reference, default empty string for PR builds ) +# Hack around PowerShell not allowing empty string parameters +if ($GitTag -ieq "not-applicable") { + $GitTag = "" +} +if ($GitSha -ieq "not-applicable" ) { + $GitSha = "" +} + [String]$cmakePresetName = "" if ($Generator -ieq "Ninja") { $cmakePresetName += "windows-ninja" From 824926269dd9a42bb7fdbb5374f32e7a985a7a9b Mon Sep 17 00:00:00 2001 From: Benjamen Meyer Date: Mon, 25 Mar 2024 00:15:42 -0400 Subject: [PATCH 3/3] Bug Fix: missing comma --- script/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/build.ps1 b/script/build.ps1 index 292885a1c7..1d19a3ebb2 100644 --- a/script/build.ps1 +++ b/script/build.ps1 @@ -25,7 +25,7 @@ param( [Boolean]$EnablePIE = $false, [String]$BuildType = "Release", # You can also specify "Debug" [Boolean]$IsRelease = $false, - [String]$GitTag = "not-applicable" # Git Tag, default empty string for PR builds + [String]$GitTag = "not-applicable", # Git Tag, default empty string for PR builds [String]$GitSha = "not-applicable" # Git Short SHA Reference, default empty string for PR builds )