-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (185 loc) · 8.04 KB
/
libppuc.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: libppuc
on:
push:
pull_request:
defaults:
run:
shell: bash
jobs:
version:
name: Detect version
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: version
run: |
VERSION_MAJOR=$(grep -Eo "PPUC_VERSION_MAJOR\s+[0-9]+" src/PPUC.h | grep -Eo "[0-9]+")
VERSION_MINOR=$(grep -Eo "PPUC_VERSION_MINOR\s+[0-9]+" src/PPUC.h | grep -Eo "[0-9]+")
VERSION_PATCH=$(grep -Eo "PPUC_VERSION_PATCH\s+[0-9]+" src/PPUC.h | grep -Eo "[0-9]+")
TAG="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
echo "${TAG}"
echo "tag=${TAG}" >> $GITHUB_OUTPUT
build:
name: Build libppuc-${{ matrix.platform }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
needs: [ version ]
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
platform: win
arch: x64
- os: windows-latest
platform: win
arch: x86
- os: macos-latest
platform: macos
arch: arm64
- os: macos-latest
platform: macos
arch: x64
- os: ubuntu-latest
platform: linux
arch: x64
- os: ubuntu-latest
platform: linux
arch: aarch64
steps:
- uses: actions/checkout@v4
- if: (matrix.platform == 'win')
name: Add msbuild to path (win runner)
uses: microsoft/setup-msbuild@v2
- if: (matrix.platform == 'macos')
name: Add autoconf and automake (mac runner)
run: |
brew install autoconf automake libtool
- if: (!(matrix.platform == 'linux' && matrix.arch == 'aarch64'))
name: Build libppuc-${{ matrix.platform }}-${{ matrix.arch }}
run: |
./platforms/${{ matrix.platform }}/${{ matrix.arch }}/external.sh
if [[ "${{ matrix.platform }}" == "win" ]]; then
if [[ "${{ matrix.arch }}" == "x64" ]]; then
cmake -G "Visual Studio 17 2022" -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build
else
cmake -G "Visual Studio 17 2022" -A Win32 -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build
fi
cmake --build build --config Release
else
if [[ "$(uname)" == "Darwin" ]]; then
NUM_PROCS=$(sysctl -n hw.ncpu)
else
NUM_PROCS=$(nproc)
fi
cmake -DCMAKE_BUILD_TYPE=Release -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build
cmake --build build -- -j${NUM_PROCS}
fi
- if: (matrix.platform == 'linux' && matrix.arch == 'aarch64')
name: Build libppuc-${{ matrix.platform }}-${{ matrix.arch }} (arm runner)
uses: pguyot/arm-runner-action@v2
with:
base_image: raspios_lite_arm64:latest
image_additional_mb: 4096
cpu: cortex-a53
cpu_info: cpuinfo/raspberrypi_zero2_w_arm64
bind_mount_repository: true
commands: |
apt-get update -y --allow-releaseinfo-change
apt-get install --no-install-recommends -y pkg-config cmake autoconf automake libtool
./platforms/${{ matrix.platform }}/${{ matrix.arch }}/external.sh
NUM_PROCS=$(nproc)
cmake -DCMAKE_BUILD_TYPE=Release -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build
cmake --build build -- -j${NUM_PROCS}
- name: Prepare artifacts
id: artifacts
run: |
mkdir tmp
if [[ "${{ matrix.platform }}" == "win" ]]; then
ARTIFACT_PATH="tmp"
cp build/Release/*.lib tmp
cp build/Release/*.dll tmp
cp build/Release/*.exe tmp
else
ARTIFACT_PATH="libppuc-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz"
if [[ "${{ matrix.platform }}" == "macos" ]]; then
cp build/*.a tmp
cp build/*.dylib tmp
cp build/ppuc_test_s tmp
cp build/ppuc_test tmp
elif [[ "${{ matrix.platform }}" == "linux" ]]; then
cp build/*.a tmp
cp build/*.so.* tmp
cp build/ppuc_test_s tmp
cp build/ppuc_test tmp
fi
cd tmp
tar -czvf ../${ARTIFACT_PATH} *
fi
echo "artifact_path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: libppuc-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}
path: ${{ steps.artifacts.outputs.artifact_path }}
post-build:
runs-on: macos-latest
needs: [ version, build ]
name: Build libppuc-macos
steps:
- uses: actions/download-artifact@v4
- name: Unpack artifacts
run: |
cd libppuc-${{ needs.version.outputs.tag }}-macos-x64
tar -xzvf libppuc-${{ needs.version.outputs.tag }}-macos-x64.tar.gz
cd ..
cd libppuc-${{ needs.version.outputs.tag }}-macos-arm64
tar -xzvf libppuc-${{ needs.version.outputs.tag }}-macos-arm64.tar.gz
- name: Combine macos architectures
run: |
mkdir tmp
lipo -create -output tmp/libppuc-${{ needs.version.outputs.tag }}.dylib \
libppuc-${{ needs.version.outputs.tag }}-macos-arm64/libppuc.${{ needs.version.outputs.tag }}.dylib \
libppuc-${{ needs.version.outputs.tag }}-macos-x64/libppuc.${{ needs.version.outputs.tag }}.dylib
lipo -create -output tmp/libserialport.dylib \
libppuc-${{ needs.version.outputs.tag }}-macos-arm64/libserialport.dylib \
libppuc-${{ needs.version.outputs.tag }}-macos-x64/libserialport.dylib
lipo -create -output tmp/libyaml-cpp.0.8.0.dylib \
libppuc-${{ needs.version.outputs.tag }}-macos-arm64/libyaml-cpp.0.8.0.dylib \
libppuc-${{ needs.version.outputs.tag }}-macos-x64/libyaml-cpp.0.8.0.dylib
lipo -create -output tmp/ppuc_test \
libppuc-${{ needs.version.outputs.tag }}-macos-arm64/ppuc_test \
libppuc-${{ needs.version.outputs.tag }}-macos-x64/ppuc_test
lipo -create -output tmp/ppuc_test_s \
libppuc-${{ needs.version.outputs.tag }}-macos-arm64/ppuc_test_s \
libppuc-${{ needs.version.outputs.tag }}-macos-x64/ppuc_test_s
- name: Prepare artifacts
run: |
cd tmp
tar -czvf ../libppuc-${{ needs.version.outputs.tag }}-macos.tar.gz *
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: libppuc-${{ needs.version.outputs.tag }}-macos
path: libppuc-${{ needs.version.outputs.tag }}-macos.tar.gz
- name: Package
if: startsWith(github.ref, 'refs/tags/')
run: |
zip -r libppuc-${{ needs.version.outputs.tag }}-win-x64.zip libppuc-${{ needs.version.outputs.tag }}-win-x64
zip -r libppuc-${{ needs.version.outputs.tag }}-win-x86.zip libppuc-${{ needs.version.outputs.tag }}-win-x86
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: |
libppuc-${{ needs.version.outputs.tag }}-win-x64.zip
libppuc-${{ needs.version.outputs.tag }}-win-x86.zip
libppuc-${{ needs.version.outputs.tag }}-macos-arm64/libppuc-${{ needs.version.outputs.tag }}-macos-arm64.tar.gz
libppuc-${{ needs.version.outputs.tag }}-macos-x64/libppuc-${{ needs.version.outputs.tag }}-macos-x64.tar.gz
libppuc-${{ needs.version.outputs.tag }}-macos.tar.gz
libppuc-${{ needs.version.outputs.tag }}-linux-x64/libppuc-${{ needs.version.outputs.tag }}-linux-x64.tar.gz
libppuc-${{ needs.version.outputs.tag }}-linux-aarch64/libppuc-${{ needs.version.outputs.tag }}-linux-aarch64.tar.gz