-
Notifications
You must be signed in to change notification settings - Fork 1
168 lines (144 loc) · 4.71 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
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Build
on:
push:
paths:
- 'rapidyenc/**'
- '.github/workflows/build.yml'
jobs:
build_macos:
name: Build macOS
runs-on: macos-13
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build
run: |
export ZERO_AR_DATE=1
cmake -S rapidyenc -B rapidyenc/build \
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 \
-DCMAKE_C_COMPILER=/Applications/Xcode_15.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc \
-DCMAKE_CXX_COMPILER=/Applications/Xcode_15.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ \
-DCMAKE_AR=/Applications/Xcode_15.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar
cmake --build rapidyenc/build --target rapidyenc_static -j$(sysctl -n hw.ncpu)
cp rapidyenc/build/rapidyenc_static/librapidyenc.a librapidyenc_darwin.a
- name: Upload static library
uses: actions/upload-artifact@v3
with:
name: static
path: librapidyenc_darwin.a
build_windows:
name: Build Windows x64
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
pacboy: >-
gcc:p
cmake:p
ninja:p
- name: Build
run: |
cmake -S rapidyenc -B rapidyenc/build -G Ninja
cmake --build rapidyenc/build --config Release --target rapidyenc_static
cp rapidyenc/build/rapidyenc_static/librapidyenc.a librapidyenc_windows_amd64.a
- name: Upload shared library
uses: actions/upload-artifact@v3
with:
name: static
path: librapidyenc_windows_amd64.a
build_linux:
name: Build ${{ matrix.platform }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- platform: linux/amd64
library: librapidyenc_linux_amd64.a
- platform: linux/arm64
library: librapidyenc_linux_arm64.a
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
if: matrix.platform == 'linux/arm64'
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build cross-compilation environment
uses: docker/build-push-action@v4
with:
context: .
tags: builder/${{ matrix.platform }}:latest
platforms: ${{ matrix.platform }}
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
push: false
- name: Build with Docker
uses: addnab/docker-run-action@v3
with:
image: builder/${{ matrix.platform }}:latest
options: |
--platform ${{ matrix.platform }}
--volume ${{ github.workspace }}:/workspace
--workdir /workspace
run: |
cmake -S rapidyenc -B rapidyenc/build \
-D CMAKE_BUILD_TYPE=Release
cmake --build rapidyenc/build --target rapidyenc_static -j$(sysctl -n hw.ncpu)
cp rapidyenc/build/rapidyenc_static/librapidyenc.a ${{ matrix.library }}
- name: Upload static library
uses: actions/upload-artifact@v3
with:
name: static
path: ${{ matrix.library }}
test:
name: Test ${{ matrix.os }} go/${{ matrix.go }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go: [1.21]
runs-on: ${{ matrix.os }}
needs: [build_linux, build_macos, build_windows]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go ${{ matrix.go }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- uses: actions/download-artifact@v3
with:
name: static
path: lib
- name: Run tests
run: go test -v
publish:
name: Publish rapidyenc build
runs-on: ubuntu-latest
needs: [test]
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: actions/download-artifact@v3
with:
name: static
path: lib
- uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: 'lib/*.a'
commit_message: Built rapidyenc