-
Notifications
You must be signed in to change notification settings - Fork 14
162 lines (138 loc) · 4.66 KB
/
build-binaries.yml
File metadata and controls
162 lines (138 loc) · 4.66 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
160
161
162
# Authors:
#
# Sam Gold <https://github.com/goldsam>
# Sebastian Stehle <https://github.com/SebastianStehle>
# Lucas Viana <https://github.com/LSViana>
name: Build binaries
on:
workflow_dispatch:
workflow_call: # Makes this workflow reusable
env:
YRS_REPO: https://github.com/y-crdt/y-crdt
YRS_BRANCH: release-v0.19.1
CARGO_TERM_COLOR: always
jobs:
build-native-binaries:
runs-on: ${{matrix.os}}
strategy:
matrix:
include:
# Windows
- build: win-x64
os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc
linker: mingw-w64
cross: false
- build: win-arm64
os: windows-latest
rust: stable
target: aarch64-pc-windows-msvc
linker: mingw-arm64
cross: false
# Linux
- build: linux-x64
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-gnu
cross: false
- build: linux-x64-musl
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
cross: false
- build: linux-armv7
os: ubuntu-latest
rust: stable
target: armv7-unknown-linux-gnueabihf
linker: gcc-arm-linux-gnueabihf
cross: true
- build: linux-armv7-musl
os: ubuntu-latest
rust: stable
target: armv7-unknown-linux-musleabihf
linker: gcc-arm-linux-gnueabihf
cross: true
- build: linux-arm64
os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-gnu
linker: gcc-aarch64-linux-gnu
cross: true
- build: linux-arm64-musl
os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-musl
linker: gcc-aarch64-linux-gnu
cross: true
# macOS
- build: macos-x86_64
os: macos-latest
rust: stable
target: x86_64-apple-darwin
cross: false
- build: macos-aarch64
os: macos-latest
rust: stable
target: aarch64-apple-darwin
cross: false
steps:
- name: Checkout
uses: actions/checkout@v4
# Cache the built binaries based on yrs branch/commit
- name: Cache built binaries
id: cache-binaries
uses: actions/cache@v4
with:
path: yrs/target/${{ matrix.target }}/release/
key: yrs-${{ matrix.target }}-${{ env.YRS_BRANCH }}
- name: Install Cross
if: matrix.cross && steps.cache-binaries.outputs.cache-hit != 'true'
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Install musl tools
if: endsWith(matrix.build, '-musl') && steps.cache-binaries.outputs.cache-hit != 'true'
run: sudo apt install -y musl musl-dev musl-tools
- name: Install Linker
if: matrix.cross && steps.cache-binaries.outputs.cache-hit != 'true'
run: |
sudo apt update
sudo apt install ${{ matrix.linker }}
cat .cargo/config.github >> .cargo/config
- name: Install Rust
if: steps.cache-binaries.outputs.cache-hit != 'true'
run: |
rustup install ${{ matrix.rust }}
rustup target add ${{ matrix.target }}
rustup show
- name: Clone Yrs
if: steps.cache-binaries.outputs.cache-hit != 'true'
run: |
git clone ${YRS_REPO} --branch ${YRS_BRANCH} --single-branch yrs
shell: bash
- name: Patch build (Git)
if: steps.cache-binaries.outputs.cache-hit != 'true' && false
run: |
cd yrs
git apply ../native/build.patch
shell: bash
- name: Build (Cargo)
if: ${{ !matrix.cross && steps.cache-binaries.outputs.cache-hit != 'true' }}
run: |
cd yrs
RUSTFLAGS="-C target-feature=-crt-static" cargo build --release --target ${{ matrix.target }}
shell: bash
- name: Build (Cross)
if: matrix.cross && steps.cache-binaries.outputs.cache-hit != 'true'
run: |
cd yrs
RUSTFLAGS="-C target-feature=-crt-static" cross build --release --target ${{ matrix.target }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.build }}
path: |
yrs/target/${{ matrix.target }}/release/*yrs.dll
yrs/target/${{ matrix.target }}/release/*yrs.so
yrs/target/${{ matrix.target }}/release/*yrs.dylib