new build infrastructure

This commit is contained in:
MatthieuCoder 2023-01-20 19:32:03 +04:00
parent a6b9dd778f
commit 81dff65713
10 changed files with 73 additions and 124 deletions

32
.ci/build.sh Executable file
View file

@ -0,0 +1,32 @@
#!/bin/bash
N=4
i=0
TARGETS=(
# Linux builds
"linux-arm64-gnuc:aarch64-unknown-linux-gnu"
"linux-arm64-musl:aarch64-unknown-linux-musl"
"linux-armv7-gnuc:armv7-unknown-linux-gnueabi"
"linux-armv7-musl:armv7-unknown-linux-musleabi"
"linux-86_64-gnuc:x86_64-unknown-linux-gnu"
"linux-86_64-musl:x86_64-unknown-linux-musl"
# windows builds
"windows-86_64-gnu:x86_64-pc-windows-gnu"
)
for thing in "${TARGETS[@]}"; do
KEY=${thing%%:*}
VALUE=${thing#*:}
echo "* BUILDING FOR $VALUE"
cross build --release --target $VALUE
# Copy intol folders
mkdir -p ./build/$KEY/
cp target/$VALUE/release/* ./build/$KEY/
rm ./build/$KEY/*.{d,rlib}
done
wait < <(jobs -p)

View file

@ -66,45 +66,13 @@ jobs:
name: macos
path: build/*
build_windows:
name: 'Build for Windows'
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: msys2/setup-msys2@v2
with:
install: git mingw-w64-x86_64-go mingw-w64-x86_64-make mingw-w64-x86_64-protobuf mingw-w64-x86_64-rust mingw-w64-x86_64-gcc mingw-w64-x86_64-dlfcn
- name: Build all
run: |
export CGO_LDFLAGS='-lntdll -lWs2_32 -lcrypt32 -lSecur32 -luserenv -lNcrypt -lbcrypt'
mingw32-make.exe all
- uses: actions/upload-artifact@v3
with:
name: windows
path: build/*
build_linux:
name: 'Build for Linux'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker-practice/actions-setup-docker@master
timeout-minutes: 12
- uses: actions/cache@v3
with:
path: |
@ -113,47 +81,11 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: ATiltedTree/setup-rust@v1
with:
rust-version: stable
- uses: actions/setup-go@v3
with:
go-version: '1.18.4'
key: ${{ runner.os }}-cargo
- name: Build all
run: |
make all
./.ci/build.sh
- uses: actions/upload-artifact@v3
with:
name: linux
name: release
path: build/*
release:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v3
with:
name: windows
path: windows
- uses: actions/download-artifact@v3
with:
name: linux_glibc
path: linux_glibc
- uses: actions/download-artifact@v3
with:
name: macos
path: macos
- uses: ncipollo/release-action@v1
with:
artifacts: "windows/*,macos/*,linux_glibc/*"
draft: true
generateReleaseNotes: true
skipIfReleaseExists: true

58
Cargo.lock generated
View file

@ -471,15 +471,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "338089f42c427b86394a5ee60ff321da23a5c89c9d89514c829687b26359fcff"
[[package]]
name = "crc32fast"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
dependencies = [
"cfg-if",
]
[[package]]
name = "criterion"
version = "0.4.0"
@ -750,17 +741,6 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
[[package]]
name = "flate2"
version = "1.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841"
dependencies = [
"crc32fast",
"libz-sys",
"miniz_oxide",
]
[[package]]
name = "fnv"
version = "1.0.7"
@ -1097,6 +1077,7 @@ dependencies = [
"rustls-native-certs",
"tokio",
"tokio-rustls",
"webpki-roots",
]
[[package]]
@ -1234,17 +1215,6 @@ version = "0.2.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
[[package]]
name = "libz-sys"
version = "1.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf"
dependencies = [
"cc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "linked-hash-map"
version = "0.5.6"
@ -1719,12 +1689,6 @@ dependencies = [
"zeroize",
]
[[package]]
name = "pkg-config"
version = "0.3.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
[[package]]
name = "plotters"
version = "0.3.4"
@ -2708,11 +2672,11 @@ dependencies = [
"futures-util",
"log",
"rustls",
"rustls-native-certs",
"tokio",
"tokio-rustls",
"tungstenite",
"webpki",
"webpki-roots",
]
[[package]]
@ -2979,11 +2943,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba43f8e8dc9f92f61c9ac4d339f7a8483c3ebef2b4f56fe62fb19e151dc79dae"
dependencies = [
"bitflags",
"flate2",
"futures-util",
"leaky-bucket-lite",
"rustls",
"rustls-native-certs",
"serde",
"serde_json",
"tokio",
@ -2993,6 +2955,7 @@ dependencies = [
"twilight-http",
"twilight-model",
"url",
"webpki-roots",
]
[[package]]
@ -3138,12 +3101,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "version_check"
version = "0.9.4"
@ -3276,6 +3233,15 @@ dependencies = [
"untrusted",
]
[[package]]
name = "webpki-roots"
version = "0.22.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87"
dependencies = [
"webpki",
]
[[package]]
name = "which"
version = "4.3.0"

6
Cross.toml Normal file
View file

@ -0,0 +1,6 @@
[build]
pre-build = [
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update && apt-get --assume-yes install libc6-dev",
]
dockerfile = "Dockerfile.cross"

13
Dockerfile.cross Normal file
View file

@ -0,0 +1,13 @@
ARG CROSS_BASE_IMAGE
FROM debian as db
WORKDIR /dl
RUN apt-get update && apt-get install -y curl zip
RUN curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protoc-21.12-linux-x86_64.zip && \
unzip protoc-21.12-linux-x86_64.zip -d protoc3
FROM $CROSS_BASE_IMAGE
COPY --from=db /dl/protoc3 /dl/
RUN mv /dl/bin/* /usr/local/bin/ && \
mv /dl/include/* /usr/local/include/

View file

@ -18,7 +18,7 @@ serde = { workspace = true }
serde_json = { workspace = true }
tokio-stream = "0.1.11"
twilight-gateway = { version = "0.14" }
twilight-gateway = { default-features = false, features = ["rustls-webpki-roots"], version = "0.14" }
twilight-model = "0.14"
bytes = "1.3.0"
async-nats = "0.26.0"

View file

@ -133,7 +133,7 @@ where
.recv()
.await;
#[cfg(not(unix))]
return tokio::signal::ctrl_c().await.unwrap();
tokio::signal::ctrl_c().await.unwrap();
stop.send(()).unwrap();
shutdown_tracer_provider();