-
Notifications
You must be signed in to change notification settings - Fork 18
106 lines (100 loc) · 3.18 KB
/
build-macos.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
name: Build macOS
on:
push:
branches: [ main ]
paths:
- 'src/**'
- 'Cargo.lock'
- 'Cargo.toml'
- 'rustfmt.toml'
- 'config/**'
- '.github/workflows/**'
pull_request:
branches: [ main ]
paths:
- 'src/**'
- 'Cargo.lock'
- 'Cargo.toml'
- 'rustfmt.toml'
- 'config/**'
- '.github/workflows/**'
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
TDLIB_VERSION: 2589c3fd46925f5d57e4ec79233cd1bd0f5d0c09
API_HASH: a3406de8d171bb422bb6ddf3bbd800e2
API_ID: 94575
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
# - os: macos-14 # arm64 (M1)
- os: macos-13 # Intel
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore cache TDLib
id: cache-tdlib-restore
uses: actions/cache/restore@v4
with:
path: td/
key: ${{ runner.os }}-TDLib-${{ env.TDLIB_VERSION }}
- name: Build TDLib
if: steps.cache-tdlib-restore.outputs.cache-hit != 'true'
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install gperf cmake openssl
git clone https://github.com/tdlib/td.git
cd td
git checkout $TDLIB_VERSION
rm -rf build
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=${{ runner.arch == 'ARM64' && '/opt/homebrew/opt/openssl/' || '/usr/local/opt/openssl/' }} -DCMAKE_INSTALL_PREFIX:PATH=../tdlib ..
cmake --build . --target install
- name: Save cache TDLib
uses: actions/cache/save@v4
if: steps.cache-tdlib-restore.outputs.cache-hit != 'true'
with:
path: td/
key: ${{ steps.cache-tdlib-restore.outputs.cache-primary-key }}
- name: Extract TDLib
run: |
cp -r ./td/tdlib ./
cp ./tdlib/lib/libtdjson.*.dylib /usr/local/lib/
- name: Set environment variables
run: |
echo "PKG_CONFIG_PATH=$(pwd)/tdlib/lib/pkgconfig" >> $GITHUB_ENV
echo "DYLD_LIBRARY_PATH=$(pwd)/tdlib/lib" >> $GITHUB_ENV
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: clippy, rustfmt
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Run cargo build
run: cargo build --verbose
- name: Run cargo test
run: cargo test --verbose -- --nocapture --test-threads=1
- name: Run cargo clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run cargo fmt
run: cargo +nightly fmt --all -- --check
# - name: Upload artifact
# uses: actions/upload-artifact@v4
# with:
# name: ${{ runner.os }}-artifact
# path: ./
# overwrite: true