Skip to content

Commit ce228d6

Browse files
committed
replace expressions with env variables
1 parent 42d7ad3 commit ce228d6

File tree

1 file changed

+55
-53
lines changed

1 file changed

+55
-53
lines changed

.github/workflows/build.yml

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
platform:
18-
- { name: win-x64, os: windows-latest, flags: -A x64 }
19-
- { name: win-x86, os: windows-latest, flags: -A Win32 }
20-
- { name: win-arm64, os: windows-latest, flags: -A ARM64 }
21-
- { name: linux-x64, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":amd64" }
22-
- { name: linux-x86, os: ubuntu-20.04, flags: -GNinja, cmake_configure_env: CFLAGS=-m32 CXXFLAGS=-m32, target_apt_arch: ":i386" }
18+
- { name: win-x64, os: windows-latest, flags: -A x64 }
19+
- { name: win-x86, os: windows-latest, flags: -A Win32 }
20+
- { name: win-arm64, os: windows-latest, flags: -A ARM64 }
21+
- { name: linux-x64, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":amd64"}
22+
- { name: linux-x86, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":i386" }
2323
- { name: linux-arm64, os: ubuntu-20.04, container: arm64v8/ubuntu }
2424
- { name: linux-arm, os: ubuntu-20.04, container: arm32v7/ubuntu }
25-
- { name: osx-x64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.14" }
25+
- { name: osx-x64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.14" }
2626
# NOTE: macOS 11.0 is the first released supported by Apple Silicon.
27-
- { name: osx-arm64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_OSX_DEPLOYMENT_TARGET="11.0" }
27+
- { name: osx-arm64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_OSX_DEPLOYMENT_TARGET="11.0" }
2828
steps:
2929
- uses: actions/checkout@v4
3030
with:
@@ -44,7 +44,7 @@ jobs:
4444
uses: addnab/docker-run-action@v3
4545
with:
4646
image: ${{ matrix.platform.container }}
47-
options: -v ${{ github.workspace }}:/workspace
47+
options: -v ${{ github.workspace }}:/workspace -e NAME=${{ matrix.platform.name }} -e BUILD_TYPE=${{ env.BUILD_TYPE }}
4848
run: |
4949
apt update -y -qq
5050
apt install -y \
@@ -86,22 +86,28 @@ jobs:
8686
cmake --build build/ --config Release
8787
cmake --install build/ --prefix install_output --config Release
8888
89-
mkdir -p SDL3-CS/native/${{ matrix.platform.name }}
90-
cp install_output/lib/libSDL3.so SDL3-CS/native/${{ matrix.platform.name }}/libSDL3.so
89+
mkdir -p SDL3-CS/native/$NAME
90+
cp install_output/lib/libSDL3.so SDL3-CS/native/$NAME/libSDL3.so
9191
9292
- name: Build
9393
if: ${{ !contains(matrix.platform.container, 'arm') }}
9494
shell: bash
95+
env:
96+
NAME: ${{ matrix.platform.name }}
97+
TARGET_APT_ARCH: ${{ matrix.platform.target_apt_arch }}
98+
RUNNER_OS: ${{ runner.os }}
99+
FLAGS: ${{ matrix.platform.flags }}
100+
95101
run: |
96-
if [[ ${{ runner.os }} == 'Linux' ]]; then
102+
if [[ $RUNNER_OS == 'Linux' ]]; then
97103
# Setup Linux dependencies
98-
if [[ ${{ matrix.platform.target_apt_arch }} == :i386 ]]; then
104+
if [[ $TARGET_APT_ARCH == :i386 ]]; then
99105
sudo dpkg --add-architecture i386
100106
fi
101107
102108
sudo apt-get update -y -qq
103109
104-
if [[ ${{ matrix.platform.target_apt_arch }} == :i386 ]]; then
110+
if [[ $TARGET_APT_ARCH == :i386 ]]; then
105111
# Workaround GitHub's ubuntu-20.04 image issue <https://github.com/actions/virtual-environments/issues/4589>
106112
sudo apt-get install -y --allow-downgrades libpcre2-8-0=10.34-7
107113
fi
@@ -113,63 +119,59 @@ jobs:
113119
ninja-build \
114120
wayland-scanner++ \
115121
wayland-protocols \
116-
pkg-config${{ matrix.platform.target_apt_arch }} \
117-
libasound2-dev${{ matrix.platform.target_apt_arch }} \
118-
libdbus-1-dev${{ matrix.platform.target_apt_arch }} \
119-
libegl1-mesa-dev${{ matrix.platform.target_apt_arch }} \
120-
libgl1-mesa-dev${{ matrix.platform.target_apt_arch }} \
121-
libgles2-mesa-dev${{ matrix.platform.target_apt_arch }} \
122-
libglu1-mesa-dev${{ matrix.platform.target_apt_arch }} \
123-
libibus-1.0-dev${{ matrix.platform.target_apt_arch }} \
124-
libpulse-dev${{ matrix.platform.target_apt_arch }} \
125-
libsndio-dev${{ matrix.platform.target_apt_arch }} \
126-
libudev-dev${{ matrix.platform.target_apt_arch }} \
127-
libwayland-dev${{ matrix.platform.target_apt_arch }} \
128-
libx11-dev${{ matrix.platform.target_apt_arch }} \
129-
libxcursor-dev${{ matrix.platform.target_apt_arch }} \
130-
libxext-dev${{ matrix.platform.target_apt_arch }} \
131-
libxi-dev${{ matrix.platform.target_apt_arch }} \
132-
libxinerama-dev${{ matrix.platform.target_apt_arch }} \
133-
libxkbcommon-dev${{ matrix.platform.target_apt_arch }} \
134-
libxrandr-dev${{ matrix.platform.target_apt_arch }} \
135-
libxss-dev${{ matrix.platform.target_apt_arch }} \
136-
libxt-dev${{ matrix.platform.target_apt_arch }} \
137-
libxv-dev${{ matrix.platform.target_apt_arch }} \
138-
libxxf86vm-dev${{ matrix.platform.target_apt_arch }} \
139-
libdrm-dev${{ matrix.platform.target_apt_arch }} \
140-
libgbm-dev${{ matrix.platform.target_apt_arch }} \
141-
libpulse-dev${{ matrix.platform.target_apt_arch }}
122+
pkg-config$TARGET_APT_ARCH \
123+
libasound2-dev$TARGET_APT_ARCH \
124+
libdbus-1-dev$TARGET_APT_ARCH \
125+
libegl1-mesa-dev$TARGET_APT_ARCH \
126+
libgl1-mesa-dev$TARGET_APT_ARCH \
127+
libgles2-mesa-dev$TARGET_APT_ARCH \
128+
libglu1-mesa-dev$TARGET_APT_ARCH \
129+
libibus-1.0-dev$TARGET_APT_ARCH \
130+
libpulse-dev$TARGET_APT_ARCH \
131+
libsndio-dev$TARGET_APT_ARCH \
132+
libudev-dev$TARGET_APT_ARCH \
133+
libwayland-dev$TARGET_APT_ARCH \
134+
libx11-dev$TARGET_APT_ARCH \
135+
libxcursor-dev$TARGET_APT_ARCH \
136+
libxext-dev$TARGET_APT_ARCH \
137+
libxi-dev$TARGET_APT_ARCH \
138+
libxinerama-dev$TARGET_APT_ARCH \
139+
libxkbcommon-dev$TARGET_APT_ARCH \
140+
libxrandr-dev$TARGET_APT_ARCH \
141+
libxss-dev$TARGET_APT_ARCH \
142+
libxt-dev$TARGET_APT_ARCH \
143+
libxv-dev$TARGET_APT_ARCH \
144+
libxxf86vm-dev$TARGET_APT_ARCH \
145+
libdrm-dev$TARGET_APT_ARCH \
146+
libgbm-dev$TARGET_APT_ARCH \
147+
libpulse-dev$TARGET_APT_ARCH
142148
fi
143149
144150
# Configure CMake
145-
${{ matrix.platform.cmake_configure_env }} cmake -B build ${{ matrix.platform.flags }} -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSDL_SHARED_ENABLED_BY_DEFAULT=ON -DSDL_STATIC_ENABLED_BY_DEFAULT=ON
151+
cmake -B build $FLAGS -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSDL_SHARED_ENABLED_BY_DEFAULT=ON -DSDL_STATIC_ENABLED_BY_DEFAULT=ON -E
146152
147153
# Build
148154
cmake --build build/ --config Release
149155
150-
if [[ ${{ runner.os }} == 'Windows' ]]; then
156+
if [[ $RUNNER_OS == 'Windows' ]]; then
151157
# Install (Windows)
152158
cmake --install build/ --prefix install_output --config Release
153-
154-
# Prepare release directory (Windows)
155-
mkdir -Force SDL3-CS/native/${{ matrix.platform.name }}
156159
else
157160
# Install
158161
sudo cmake --install build/ --prefix install_output --config Release
159-
160-
# Prepare release directory
161-
mkdir -p SDL3-CS/native/${{ matrix.platform.name }}
162162
fi
163163
164-
if [[ ${{ runner.os }} == 'Windows' ]]; then
164+
mkdir -p SDL3-CS/native/$NAME
165+
166+
if [[ $RUNNER_OS == 'Windows' ]]; then
165167
# Prepare release (Windows)
166-
cp install_output/bin/SDL3.dll SDL3-CS/native/${{ matrix.platform.name }}/SDL3.dll
167-
elif [[ ${{ runner.os }} == 'Linux' ]]; then
168+
cp install_output/bin/SDL3.dll SDL3-CS/native/$NAME/SDL3.dll
169+
elif [[ $RUNNER_OS == 'Linux' ]]; then
168170
# Prepare release (Linux)
169-
cp install_output/lib/libSDL3.so SDL3-CS/native/${{ matrix.platform.name }}/libSDL3.so
170-
elif [[ ${{ runner.os }} == 'macOS' ]]; then
171+
cp install_output/lib/libSDL3.so SDL3-CS/native/$NAME/libSDL3.so
172+
elif [[ $RUNNER_OS == 'macOS' ]]; then
171173
# Prepare release (macOS)
172-
cp install_output/lib/libSDL3.dylib SDL3-CS/native/${{ matrix.platform.name }}/libSDL3.dylib
174+
cp install_output/lib/libSDL3.dylib SDL3-CS/native/$NAME/libSDL3.dylib
173175
fi
174176
175177
- name: Create pull request

0 commit comments

Comments
 (0)