-
Notifications
You must be signed in to change notification settings - Fork 7
154 lines (134 loc) · 5.06 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
name: Build
on:
push:
branches-ignore:
- gh-readonly-queue/**
pull_request:
merge_group:
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
include:
- os: ubuntu-latest
features-debug: "bundled_data_dir,ffmpeg,microphone"
features: "bundled_data_dir,ffmpeg,microphone"
bin: ddnet-rs
server-bin: server
- os: macOS-latest
features-debug: "bundled_data_dir,ffmpeg,microphone"
features: "bundled_data_dir,ffmpeg,microphone"
bin: ddnet-rs
server-bin: server
- os: windows-latest
# ffmpeg takes years on win
features-debug: "bundled_data_dir,microphone"
features: "bundled_data_dir,ffmpeg,microphone"
bin: ddnet-rs.exe
server-bin: server.exe
runs-on: ${{ matrix.os }}
defaults:
run:
shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash {0}' }}
steps:
- name: Prepare Windows (msys2)
uses: msys2/setup-msys2@v2
if: contains(matrix.os, 'windows')
with:
msystem: MINGW64
- name: Configure Windows Path for msys2
shell: powershell {0}
if: contains(matrix.os, 'windows')
run: |
$env:PATH = "${{ steps.msys2.outputs.msys2-location }}/usr/bin;" + [System.Environment]::GetEnvironmentVariable("Path", "User")
[System.Environment]::SetEnvironmentVariable("Path", $env:PATH, "User")
- name: Configure rustup for msys2
if: contains(matrix.os, 'windows')
run: |
export PATH="/c/users/$(whoami)/.cargo/bin:$PATH"
echo -e "export PATH=\"/c/users/$(whoami)/.cargo/bin:\$PATH\"\n" >> ~/.bash_profile
echo -e "export MINGW_ARCH=mingw64\n" >> ~/.bash_profile
- uses: actions/checkout@v4
with:
submodules: true
- run: |
rustup toolchain install stable --profile minimal
- name: Prepare Linux
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt update -y
sudo apt install rustc cargo gcc libwayland-dev libasound2-dev nasm -y
# for ffmpeg
sudo apt install -y clang libavcodec-dev libavformat-dev libavutil-dev libx264-dev
- name: Prepare macOS
if: contains(matrix.os, 'macOS')
run: |
brew update || true
brew install pkg-config autoconf automake || true
# for ffmpeg
brew install ffmpeg || true
- name: Prepare msys dependencies
if: contains(matrix.os, 'windows')
run: |
# important detail: mingw-w64-x86_64-libx264 is installed for the package config files!
pacman --noconfirm -S git make mingw-w64-x86_64-libx264 mingw-w64-x86_64-toolchain mingw-w64-x86_64-clang mingw-w64-x86_64-gcc mingw-w64-x86_64-nasm mingw-w64-x86_64-opus
# self compile for now
# https://github.com/msys2/MINGW-packages/issues/8824
git clone --depth=1 https://github.com/mirror/x264 /c/x264
- name: Setup cache for x264 (Windows)
if: contains(matrix.os, 'windows')
uses: actions/cache@v4
id: x264-cache-compiled
with:
path: C:\build-x264
key: ${{ runner.os }}-buildx264-${{ hashFiles('/c/x264') }}
- name: Compile x264 (Windows)
if: contains(matrix.os, 'windows') && steps.x264-cache-compiled.outputs.cache-hit != 'true'
run: |
(
mkdir /c/build-x264
cd /c/build-x264
/c/x264/configure --enable-static
make -j$(nproc)
)
- name: Prepare msys
if: contains(matrix.os, 'windows')
run: |
rm /mingw64/lib/libx264.dll.a
cp /c/build-x264/libx264.a /mingw64/lib/libx264.a
rustup target add x86_64-pc-windows-gnu
rustup update stable
rustup set default-host x86_64-pc-windows-gnu
rustup default stable-x86_64-pc-windows-gnu
- uses: Swatinem/rust-cache@v2
- name: Build debug
# disable windows for now, since it's the slowest build
if: contains(matrix.os, 'windows') == false
run: cargo build --verbose --features ${{ matrix.features-debug }}
- name: Build release
run: cargo build --release --verbose --features ${{ matrix.features }}
- name: Build server release
run: cargo build -p server --release --verbose --features bundled_data_dir
- name: Prepare artifacts
run: |
mkdir bin-artifacts || true
mv target/release/${{ matrix.bin }} bin-artifacts
mv target/release/${{ matrix.server-bin }} bin-artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ddnet-rs-${{ matrix.os }}
path: bin-artifacts
- name: Build release with steam
run: cargo build --release --verbose --features ${{ matrix.features }},enable_steam
- name: Prepare artifacts
run: |
mkdir bin-artifacts || true
mv target/release/${{ matrix.bin }} bin-artifacts
- name: Upload Artifacts steam
uses: actions/upload-artifact@v4
with:
name: ddnet-rs-${{ matrix.os }}-steam
path: bin-artifacts