-
Notifications
You must be signed in to change notification settings - Fork 5
159 lines (131 loc) · 5 KB
/
build.yml
File metadata and controls
159 lines (131 loc) · 5 KB
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
156
157
158
159
name: Build
env:
LIBRARY_VERSION: 1.1.0
on:
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-latest
triplet: x64-windows-static
name: windows-x64
- os: macos-latest
triplet: arm64-osx
name: macos-arm64
- os: macos-15-intel
triplet: x64-osx
name: macos-x64
- os: ubuntu-latest
triplet: x64-linux
name: linux-x64
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up nasm
if: matrix.os != 'windows-latest'
uses: ilammy/setup-nasm@v1
- name: Set up vcpkg
shell: bash
run: |
git clone https://github.com/Microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh
- name: Configure project (Windows)
if: matrix.os == 'windows-latest'
shell: cmd
run: |
cmake -B library\src\main\cpp\build -S library\src\main\cpp ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}\vcpkg\scripts\buildsystems\vcpkg.cmake ^
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
- name: Configure project (macOS ARM64)
if: matrix.os == 'macos-latest'
shell: bash
run: |
cmake -B library/src/main/cpp/build -S library/src/main/cpp \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
- name: Configure project (macOS Intel)
if: matrix.os == 'macos-15-intel'
shell: bash
run: |
cmake -B library/src/main/cpp/build -S library/src/main/cpp \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
- name: Configure project (Linux)
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
cmake -B library/src/main/cpp/build -S library/src/main/cpp \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SHARED_LINKER_FLAGS="-Wl,-Bsymbolic" \
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
- name: Build project (Windows)
if: matrix.os == 'windows-latest'
shell: cmd
run: |
cmake --build library\src\main\cpp\build --config Release --parallel
- name: Build project (non-Windows)
if: matrix.os != 'windows-latest'
shell: bash
run: |
cmake --build library/src/main/cpp/build --config Release --parallel
- name: Create resources folder
run: mkdir -p library/src/main/resources/bin
- name: Copy binaries (Windows)
if: matrix.os == 'windows-latest'
shell: bash
run: |
cp library/src/main/cpp/build/Release/klarity.dll library/src/main/resources/bin/klarity.dll
- name: Copy binaries (macOS)
if: matrix.os == 'macos-latest' || matrix.os == 'macos-15-intel'
shell: bash
run: |
cp library/src/main/cpp/build/libklarity.dylib library/src/main/resources/bin/klarity.dylib
- name: Copy binaries (Linux)
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
cp library/src/main/cpp/build/libklarity.so library/src/main/resources/bin/klarity.so
- name: Make binaries executable (non-Windows)
if: matrix.os != 'windows-latest'
shell: bash
run: |
chmod +x library/src/main/resources/bin/* || true
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17.0.15+6
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Make Gradle wrapper executable (non-Windows)
if: matrix.os != 'windows-latest'
shell: bash
run: |
chmod +x gradlew
- name: Make JARs
run: ./gradlew :library:jar -x test --no-daemon
- name: Clean up resources
shell: bash
run: rm -rf library/src/main/resources/bin
- name: Rename JAR
id: rename_jar
shell: bash
run: |
SRC="${{ github.workspace }}/library/build/libs/library-${{ env.LIBRARY_VERSION }}.jar"
NAME="klarity-${{ matrix.name }}-${{ env.LIBRARY_VERSION }}.jar"
DST="${{ github.workspace }}/library/build/libs/${NAME}"
mv "${SRC}" "${DST}"
echo "NAME=${NAME}" >> $GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: ${{ github.workspace }}/library/build/libs/${{ steps.rename_jar.outputs.NAME }}