From 5c41ce5aaecb5d611e1ded8eb4e6a642d6667f15 Mon Sep 17 00:00:00 2001 From: Georg Thiesen Date: Sun, 10 Mar 2024 17:57:17 +0100 Subject: [PATCH 01/12] Create cmake-multi-platform-make-release.yml --- .../cmake-multi-platform-make-release.yml | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .github/workflows/cmake-multi-platform-make-release.yml diff --git a/.github/workflows/cmake-multi-platform-make-release.yml b/.github/workflows/cmake-multi-platform-make-release.yml new file mode 100644 index 0000000..2933665 --- /dev/null +++ b/.github/workflows/cmake-multi-platform-make-release.yml @@ -0,0 +1,90 @@ +name: CMake on multiple platforms + +on: [push] + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. + fail-fast: false + + # Set up a matrix to run the following 3 configurations: + # 1. + # 2. + # 3. + # + # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. + matrix: + os: [ubuntu-latest, windows-latest] + build_type: [Release] + c_compiler: [gcc, clang, cl] + include: + - os: windows-latest + c_compiler: cl + cpp_compiler: cl + - os: ubuntu-latest + c_compiler: gcc + cpp_compiler: g++ + - os: ubuntu-latest + c_compiler: clang + cpp_compiler: clang++ + exclude: + - os: windows-latest + c_compiler: gcc + - os: windows-latest + c_compiler: clang + - os: ubuntu-latest + c_compiler: cl + + steps: + - uses: actions/checkout@v3 + + - name: Set reusable strings + # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: Install development libraries (Ubuntu/Debian) + if: matrix.os == 'ubuntu-latest' + run: sudo apt update && sudo apt install libopenal-dev libxcursor-dev libfreetype6-dev libx11-dev libxrandr-dev libudev-dev libglu1-mesa-dev libflac-dev libogg-dev libvorbis-dev + + - uses: actions/cache@v3 + with: + path: ${{ steps.strings.outputs.build-output-dir }} + key: ${{ runner.os }}-build-${{ matrix.build_type }} + restore-keys: | + ${{ runner.os }}-build- + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/Release + -S ${{ github.workspace }} + - name: Build + # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --target install + + - uses: actions/upload-artifact@v3 # Upload build artifacts + with: + name: built-project # Name for the artifact cache + path: ${{ github.workspace }}/Release # Path containing built artifacts + + - name: Create Release # Create release on merge + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.sha }} # Use the commit SHA for the tag + release_name: "Pre-Alpha-Demo ${{ github.sha }}" + body: | # Optional release body content + This release corresponds to commit ${{ github.sha }}. + asset_name: "${{ github.event.repository.name }}-${{ matrix.os }}.zip" # Filename for the artifact archive + asset_path: ./built-project # Path to the downloaded artifacts From 26fdeaa8680759ca23f0cad71034339316224562 Mon Sep 17 00:00:00 2001 From: Georg Thiesen Date: Sun, 10 Mar 2024 18:12:24 +0100 Subject: [PATCH 02/12] Update cmake-multi-platform-make-release.yml --- .github/workflows/cmake-multi-platform-make-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake-multi-platform-make-release.yml b/.github/workflows/cmake-multi-platform-make-release.yml index 2933665..b708926 100644 --- a/.github/workflows/cmake-multi-platform-make-release.yml +++ b/.github/workflows/cmake-multi-platform-make-release.yml @@ -66,7 +66,7 @@ jobs: -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/Release + -DCMAKE_INSTALL_PREFIX=~/.local/myproject -S ${{ github.workspace }} - name: Build # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). @@ -75,7 +75,7 @@ jobs: - uses: actions/upload-artifact@v3 # Upload build artifacts with: name: built-project # Name for the artifact cache - path: ${{ github.workspace }}/Release # Path containing built artifacts + path: ~/.local/myproject # Path containing built artifacts - name: Create Release # Create release on merge uses: actions/create-release@v1 From 34f81b20701160c944368a4b33527f98fa22e57e Mon Sep 17 00:00:00 2001 From: Georg Thiesen Date: Sun, 10 Mar 2024 18:29:51 +0100 Subject: [PATCH 03/12] Update cmake-multi-platform-make-release.yml --- .../cmake-multi-platform-make-release.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cmake-multi-platform-make-release.yml b/.github/workflows/cmake-multi-platform-make-release.yml index b708926..2aee559 100644 --- a/.github/workflows/cmake-multi-platform-make-release.yml +++ b/.github/workflows/cmake-multi-platform-make-release.yml @@ -77,14 +77,20 @@ jobs: name: built-project # Name for the artifact cache path: ~/.local/myproject # Path containing built artifacts - - name: Create Release # Create release on merge + - name: Create Release # Create the release on GitHub uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ github.sha }} # Use the commit SHA for the tag - release_name: "Pre-Alpha-Demo ${{ github.sha }}" - body: | # Optional release body content - This release corresponds to commit ${{ github.sha }}. - asset_name: "${{ github.event.repository.name }}-${{ matrix.os }}.zip" # Filename for the artifact archive + tag_name: ${{ github.ref }} # Use the commit SHA for the tag + release_name: "Pre-Alpha-Demo ${{ github.ref }}" # Release name + prerelease: false # Set to true for pre-releases (optional) + + - name: Upload Release # Create release on merge + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: "${{ github.event.repository.name }}_${{ matrix.os }}.zip" # Filename for the artifact archive asset_path: ./built-project # Path to the downloaded artifacts From b3c072b6b6a939acb1782565c6d708ad5fd52cb8 Mon Sep 17 00:00:00 2001 From: Georg Thiesen Date: Sun, 10 Mar 2024 18:44:08 +0100 Subject: [PATCH 04/12] Update cmake-multi-platform-make-release.yml --- .github/workflows/cmake-multi-platform-make-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake-multi-platform-make-release.yml b/.github/workflows/cmake-multi-platform-make-release.yml index 2aee559..95fb863 100644 --- a/.github/workflows/cmake-multi-platform-make-release.yml +++ b/.github/workflows/cmake-multi-platform-make-release.yml @@ -82,8 +82,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ github.ref }} # Use the commit SHA for the tag - release_name: "Pre-Alpha-Demo ${{ github.ref }}" # Release name + tag_name: ${{ github.sha }} # Use the commit SHA for the tag + release_name: "Pre-Alpha-Demo ${{ github.sha }}" # Release name prerelease: false # Set to true for pre-releases (optional) - name: Upload Release # Create release on merge From a3a23721a2cf34e4c2b1c05ea0599743f91ba658 Mon Sep 17 00:00:00 2001 From: Georg Thiesen Date: Sun, 10 Mar 2024 18:55:56 +0100 Subject: [PATCH 05/12] Update cmake-multi-platform-make-release.yml --- .github/workflows/cmake-multi-platform-make-release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake-multi-platform-make-release.yml b/.github/workflows/cmake-multi-platform-make-release.yml index 95fb863..bb1e1fa 100644 --- a/.github/workflows/cmake-multi-platform-make-release.yml +++ b/.github/workflows/cmake-multi-platform-make-release.yml @@ -1,6 +1,8 @@ name: CMake on multiple platforms -on: [push] +on: + pull_request: + branches: release jobs: build: From 0375f3771a5a9a377a5869d9f42ac16fe41a747d Mon Sep 17 00:00:00 2001 From: Georg Thiesen Date: Sun, 10 Mar 2024 19:04:22 +0100 Subject: [PATCH 06/12] Update cmake-multi-platform.yml --- .github/workflows/cmake-multi-platform.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 79a359b..570b1e1 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -69,6 +69,7 @@ jobs: -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DCMAKE_INSTALL_PREFIX=~/.local/myproject -S ${{ github.workspace }} - name: Build From ab5d632b62c4d71758b95ec6b3d547269badb723 Mon Sep 17 00:00:00 2001 From: Georg Thiesen Date: Sun, 10 Mar 2024 19:13:29 +0100 Subject: [PATCH 07/12] Update cmake-multi-platform-make-release.yml --- .../cmake-multi-platform-make-release.yml | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake-multi-platform-make-release.yml b/.github/workflows/cmake-multi-platform-make-release.yml index bb1e1fa..c4b1d49 100644 --- a/.github/workflows/cmake-multi-platform-make-release.yml +++ b/.github/workflows/cmake-multi-platform-make-release.yml @@ -60,9 +60,22 @@ jobs: key: ${{ runner.os }}-build-${{ matrix.build_type }} restore-keys: | ${{ runner.os }}-build- - - name: Configure CMake + - name: Configure CMake (on Linux) # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + if: runner.os == 'Linux' + run: > + sudo cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DCMAKE_INSTALL_PREFIX=~/.local/myproject + -S ${{ github.workspace }} + + - name: Configure CMake (on Windows) + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + if: runner.os == 'Windows' run: > cmake -B ${{ steps.strings.outputs.build-output-dir }} -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} @@ -70,8 +83,15 @@ jobs: -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=~/.local/myproject -S ${{ github.workspace }} - - name: Build + + - name: Build (Linux) + # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + if: runner.os == 'Linux' + run: sudo cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --target install + + - name: Build (Windows) # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + if: runner.os == 'Windows' run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --target install - uses: actions/upload-artifact@v3 # Upload build artifacts From 6f3bce366730ed8bfc0a7d27d5280b08367bcda5 Mon Sep 17 00:00:00 2001 From: Georg Thiesen Date: Sun, 10 Mar 2024 20:06:19 +0100 Subject: [PATCH 08/12] Update cmake-multi-platform-make-release.yml --- .github/workflows/cmake-multi-platform-make-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake-multi-platform-make-release.yml b/.github/workflows/cmake-multi-platform-make-release.yml index c4b1d49..75c08bb 100644 --- a/.github/workflows/cmake-multi-platform-make-release.yml +++ b/.github/workflows/cmake-multi-platform-make-release.yml @@ -102,7 +102,7 @@ jobs: - name: Create Release # Create the release on GitHub uses: actions/create-release@v1 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} with: tag_name: ${{ github.sha }} # Use the commit SHA for the tag release_name: "Pre-Alpha-Demo ${{ github.sha }}" # Release name @@ -111,7 +111,7 @@ jobs: - name: Upload Release # Create release on merge uses: actions/upload-release-asset@v1 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_name: "${{ github.event.repository.name }}_${{ matrix.os }}.zip" # Filename for the artifact archive From f42bba2f257698c035952543515dbeee10afb132 Mon Sep 17 00:00:00 2001 From: Georg Thiesen Date: Sun, 10 Mar 2024 20:10:23 +0100 Subject: [PATCH 09/12] Update cmake-multi-platform-make-release.yml --- .github/workflows/cmake-multi-platform-make-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake-multi-platform-make-release.yml b/.github/workflows/cmake-multi-platform-make-release.yml index 75c08bb..6bd2595 100644 --- a/.github/workflows/cmake-multi-platform-make-release.yml +++ b/.github/workflows/cmake-multi-platform-make-release.yml @@ -104,8 +104,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} with: - tag_name: ${{ github.sha }} # Use the commit SHA for the tag - release_name: "Pre-Alpha-Demo ${{ github.sha }}" # Release name + tag_name: v1.0.0 # Use the commit SHA for the tag + release_name: "Pre-Alpha-Demo v1.0.0" # Release name prerelease: false # Set to true for pre-releases (optional) - name: Upload Release # Create release on merge From 2de548ac93a8e26a856f83cd21861f74e15dd395 Mon Sep 17 00:00:00 2001 From: Georg Thiesen Date: Sun, 10 Mar 2024 20:29:33 +0100 Subject: [PATCH 10/12] Update cmake-multi-platform-make-release.yml --- .github/workflows/cmake-multi-platform-make-release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cmake-multi-platform-make-release.yml b/.github/workflows/cmake-multi-platform-make-release.yml index 6bd2595..2a9ec9f 100644 --- a/.github/workflows/cmake-multi-platform-make-release.yml +++ b/.github/workflows/cmake-multi-platform-make-release.yml @@ -100,6 +100,7 @@ jobs: path: ~/.local/myproject # Path containing built artifacts - name: Create Release # Create the release on GitHub + id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} @@ -109,6 +110,7 @@ jobs: prerelease: false # Set to true for pre-releases (optional) - name: Upload Release # Create release on merge + id: upload-release-asset uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} From d93a497f000b159785de87c54fec916ad285c2a2 Mon Sep 17 00:00:00 2001 From: Georg Thiesen Date: Sun, 10 Mar 2024 20:36:18 +0100 Subject: [PATCH 11/12] Update cmake-multi-platform-make-release.yml --- .github/workflows/cmake-multi-platform-make-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cmake-multi-platform-make-release.yml b/.github/workflows/cmake-multi-platform-make-release.yml index 2a9ec9f..ab2e996 100644 --- a/.github/workflows/cmake-multi-platform-make-release.yml +++ b/.github/workflows/cmake-multi-platform-make-release.yml @@ -118,3 +118,4 @@ jobs: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_name: "${{ github.event.repository.name }}_${{ matrix.os }}.zip" # Filename for the artifact archive asset_path: ./built-project # Path to the downloaded artifacts + asset_content_type: application/zip From 4ca271997ca4a1ddb997c4393799a7bf9dd365ea Mon Sep 17 00:00:00 2001 From: Georg Thiesen Date: Sun, 10 Mar 2024 21:05:35 +0100 Subject: [PATCH 12/12] Update cmake-multi-platform-make-release.yml --- .github/workflows/cmake-multi-platform-make-release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cmake-multi-platform-make-release.yml b/.github/workflows/cmake-multi-platform-make-release.yml index ab2e996..c1f7631 100644 --- a/.github/workflows/cmake-multi-platform-make-release.yml +++ b/.github/workflows/cmake-multi-platform-make-release.yml @@ -94,6 +94,9 @@ jobs: if: runner.os == 'Windows' run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --target install + - name: Create Build Output Directory + run: mkdir ./built-project + - uses: actions/upload-artifact@v3 # Upload build artifacts with: name: built-project # Name for the artifact cache