Skip to content

Commit 46d4ad3

Browse files
committed
Add build-packages.yml
Copied from AiraForce project, in which the Mac package build actions/upload-artifact@v4 hangs. See actions/upload-artifact#527 (comment)
1 parent 8467296 commit 46d4ad3

File tree

3 files changed

+150
-1
lines changed

3 files changed

+150
-1
lines changed

.github/workflows/build-packages.yml

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# Build release packages for all platforms
2+
# Based on "CMake on multiple platforms" starter workflows https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
3+
4+
name: Build Packages
5+
6+
# This is an expensive workflow, so only run on demand.
7+
# Building on Windows costs x2 and MacOS costs x10!
8+
on: workflow_dispatch
9+
10+
env:
11+
build_type: Release
12+
13+
jobs:
14+
build:
15+
runs-on: ${{ matrix.os }}
16+
17+
strategy:
18+
# 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.
19+
fail-fast: false
20+
21+
# Set up a matrix to run the following 3 configurations:
22+
# 1. Windows, x64, latest MSVC compiler toolchain on the default runner image, default generator
23+
# 2. Windows, win32, latest MSVC compiler toolchain on the default runner image, default generator
24+
# 3. Linux, x64, latest Clang compiler toolchain on the default runner image, default generator
25+
# 4. MacOS, Intel Silicon, x64, latest Clang compiler toolchain on the default runner image, default generator
26+
# TODO: 5. MacOS, Apple Silicon (macos-14/latest), x64, latest Clang compiler toolchain on the default runner image, default generator
27+
matrix:
28+
os: [windows-latest, ubuntu-latest, macos-13]
29+
architecture: [x64, win32]
30+
include:
31+
# - os: windows-latest
32+
# c_compiler: cl
33+
# cpp_compiler: cl
34+
# architecture: x64
35+
# - os: windows-latest
36+
# c_compiler: cl
37+
# cpp_compiler: cl
38+
# architecture: win32
39+
# - os: ubuntu-latest
40+
# c_compiler: clang
41+
# cpp_compiler: clang++
42+
# architecture: x64
43+
- os: macos-13
44+
c_compiler: clang
45+
cpp_compiler: clang++
46+
exclude:
47+
- os: ubuntu-latest
48+
#architecture: win32 # TEMP: Disable ubuntu while https://gitlab.freedesktop.org is down
49+
- os: macos-13
50+
architecture: win32
51+
- os: windows-latest # TEMP: Disable windows while testing mac
52+
53+
steps:
54+
55+
- name: Update packages
56+
if: runner.os == 'Linux'
57+
run: sudo apt-get update
58+
59+
- name: Install packages
60+
if: runner.os == 'Linux'
61+
run: sudo apt-get install -y libgl1-mesa-dev #TODO: May require --fix-missing
62+
63+
- name: Checkout repository
64+
uses: actions/checkout@master
65+
66+
- name: Checkout submodules
67+
run: git submodule update --init --recursive
68+
69+
# Workaround for "ubuntu-latest runners have an incompatible combination of clang and libstdc++" https://github.com/actions/runner-images/issues/8659
70+
# From: https://github.com/actions/runner-images/discussions/9446#discussioncomment-8668540
71+
- name: ubuntu clang/libstdc++ workaround
72+
uses: mjp41/workaround8649@c8550b715ccdc17f89c8d5c28d7a48eeff9c94a8
73+
with:
74+
os: ${{ matrix.os }}
75+
76+
- name: Set reusable strings
77+
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
78+
id: strings
79+
shell: bash
80+
run: |
81+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
82+
echo "package-dir=${{ github.workspace }}/packages" >> "$GITHUB_OUTPUT"
83+
84+
# Configure CMake in a 'build' subdirectory.
85+
# `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
86+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
87+
# -T and -A are only required for the Visual Studio generator to use the 64-bit toolset to build either 64 or 32 bit builds
88+
- name: Configure CMake (Windows)
89+
if: runner.os == 'Windows'
90+
run: >
91+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
92+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
93+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
94+
-S ${{ github.workspace }}
95+
-T host=x64
96+
-A ${{ matrix.architecture }}
97+
98+
- name: Configure CMake (not Windows)
99+
if: runner.os != 'Windows'
100+
run: >
101+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
102+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
103+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
104+
-DCMAKE_BUILD_TYPE=${{ env.build_type }}
105+
-S ${{ github.workspace }}
106+
107+
# Set version environment variable
108+
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
109+
# n.b. VERSION.txt is generated by the Configure CMake step, so this must be called subsequently
110+
# n.b. GitHub actions uses pwsh (PowerShell) as the default shell on Windows (not CMD)
111+
- name: Set version env var (PowerShell)
112+
if: runner.os == 'Windows'
113+
run: |
114+
$Env:VER = Get-Content VERSION.txt
115+
echo "VERSION=$Env:VER" >> $env:GITHUB_ENV
116+
117+
- name: Set version env var (Bash)
118+
if: runner.os != 'Windows'
119+
run: |
120+
VER=$(cat VERSION.txt)
121+
echo "VERSION=$VER" >> $GITHUB_ENV
122+
123+
- name: Print version
124+
run: echo VERSION=${{ env.VERSION }}
125+
126+
- name: Build
127+
# Build your program with the given configuration.
128+
# --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
129+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ env.build_type }}
130+
131+
- name: Test
132+
working-directory: ${{ steps.strings.outputs.build-output-dir }}
133+
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
134+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
135+
run: ctest --build-config ${{ env.build_type }}
136+
137+
# Build package into the build/out/ directory
138+
- name: Package
139+
run: cpack --config build/CPackConfig.cmake -C ${{ env.build_type }}
140+
141+
- name: Upload package
142+
uses: actions/upload-artifact@v4
143+
with:
144+
name: packages-${{ env.VERSION }}-${{ runner.os }}-${{ matrix.architecture }} # name given to uploaded artifact e.g. packages-0.6.3-Windows-x64
145+
path: |
146+
build/out
147+
!build/out/_CPack_Packages/
148+
overwrite: true

.github/workflows/githubci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: CI
22

3-
on: [push]
3+
on: workflow_dispatch
44

55
jobs:
66
build:

VERSION.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.2.3

0 commit comments

Comments
 (0)