generated from ThePythonator/SDL2-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (130 loc) · 4.67 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Build Github Action, to run a test build on all targets
# (Linux, Blit, MacOS, Visual Studio) when the project is checked in.
#
# Thanks in large part to the phenomenal examples of DaftFreak.
name: Build
on:
push:
pull_request:
release:
types: [created]
env:
BUILD_TYPE: Release
EM_VERSION: 2.0.18 # Emscripten version
EM_CACHE_FOLDER: 'emsdk-cache' # Cache for Emscripten libs
jobs:
build:
name: ${{matrix.name}}
strategy:
matrix:
include:
- os: ubuntu-20.04
name: Linux
release-suffix: LIN64
cmake-args: #-DSDL2_IMAGE_DIR=$GITHUB_WORKSPACE/main/SDL2
apt-packages: #libxmp-dev
can-fail: false
- os: ubuntu-20.04
name: Emscripten
release-suffix: WEB
cmake-args: #-DSDL2_IMAGE_DIR=$GITHUB_WORKSPACE/main/SDL2
cmake-prefix: emcmake
apt-packages: python3-setuptools
can-fail: true
- os: macos-latest
name: macOS
release-suffix: MACOS
cmake-args: #-DSDL2_IMAGE_DIR=$GITHUB_WORKSPACE/main/SDL2
brew-packages: #libxmp
can-fail: true
- os: windows-latest
name: Visual Studio
release-suffix: WIN64
cmake-args: #-DSDL2_DIR=$GITHUB_WORKSPACE/main/SDL2 -DSDL2_image_DIR=$GITHUB_WORKSPACE/main/SDL2
can-fail: false
runs-on: ${{matrix.os}}
continue-on-error: ${{ matrix.can-fail }}
env:
RELEASE_FILE: ${{github.event.repository.name}}-${{github.event.release.tag_name}}-${{matrix.release-suffix}}
steps:
# Check out the main repo
- name: Checkout
uses: actions/checkout@v2
with:
path: main
# Linux dependencies
- name: Install Linux deps
if: runner.os == 'Linux'
run: |
sudo apt update && sudo apt install ${{matrix.apt-packages}}
# MacOS dependencies
#- name: Install macOS deps
# if: runner.os == 'macOS'
# run: |
# brew install ${{matrix.brew-packages}}
# Windows dependencies
#- name: Install Windows deps
# if: runner.os == 'Windows'
# shell: bash
# run: |
# python -m pip install 32blit
# Emscripten SDK setup
- name: Setup Emscripten cache
if: matrix.name == 'Emscripten'
id: cache-system-libraries
uses: actions/cache@v2
with:
path: ${{env.EM_CACHE_FOLDER}}
key: ${{env.EM_VERSION}}-${{runner.os}}
- name: Setup Emscripten
if: matrix.name == 'Emscripten'
uses: mymindstorm/setup-emsdk@v7
with:
version: ${{env.EM_VERSION}}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
- name: Pre-build Emscripten ports
if: matrix.name == 'Emscripten'
run: embuilder.py build sdl2 sdl2-image-jpg
# Set up the cmake build environment
- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/main/build
# Ask cmake to build the makefiles
- name: Configure CMake
shell: bash
working-directory: ${{runner.workspace}}/main/build
run: ${{matrix.cmake-prefix}} cmake $GITHUB_WORKSPACE/main -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCPACK_PACKAGE_FILE_NAME=${{env.RELEASE_FILE}} ${{matrix.cmake-args}}
# And then run the build itself
- name: Build
working-directory: ${{runner.workspace}}/main/build
shell: bash
run: |
cmake --build . --config $BUILD_TYPE -j 2
# When it's a release, generate tar/zip files of the build
- name: Package Release
if: github.event_name == 'release' && matrix.release-suffix != ''
shell: bash
working-directory: ${{runner.workspace}}/main/build
run: |
cmake --build . --config $BUILD_TYPE --target package
# Push the tar file to the release
- name: Upload tar
if: github.event_name == 'release' && matrix.release-suffix != ''
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
asset_path: ${{runner.workspace}}/main/build/${{env.RELEASE_FILE}}.tar.gz
upload_url: ${{github.event.release.upload_url}}
asset_name: ${{env.RELEASE_FILE}}.tar.gz
asset_content_type: application/octet-stream
# Push the zip file to the release
- name: Upload zip
if: github.event_name == 'release' && matrix.release-suffix != ''
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
asset_path: ${{runner.workspace}}/main/build/${{env.RELEASE_FILE}}.zip
upload_url: ${{github.event.release.upload_url}}
asset_name: ${{env.RELEASE_FILE}}.zip
asset_content_type: application/zip