-
Notifications
You must be signed in to change notification settings - Fork 40
140 lines (135 loc) · 4.86 KB
/
scheduled-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
name: release
on:
schedule:
# Runs "At 12:00." (see https://crontab.guru)
- cron: "0 12 * * *"
env:
CARGO_TERM_COLOR: always
defaults:
run:
# necessary for windows
shell: bash
jobs:
build:
if: ${{ false }} # disable for now
strategy:
fail-fast: false
matrix:
# a list of all the targets
include:
- TARGET: x86_64-unknown-linux-gnu
OS: ubuntu-latest
RUST: nightly
- TARGET: x86_64-unknown-linux-musl
OS: ubuntu-latest
RUST: nightly
- TARGET: aarch64-unknown-linux-gnu
OS: ubuntu-latest
RUST: nightly
# - TARGET: aarch64-unknown-linux-musl
# OS: ubuntu-latest
# RUST: nightly
# if: github.ref != 'refs/heads/master'
runs-on: ${{ matrix.OS }}
env:
TARGET: ${{ matrix.TARGET }}
OS: ${{ matrix.OS }}
# Disable full debug symbol generation to speed up CI build and keep memory down
# "1" means line tables only, which is useful for panic tracebacks.
RUSTFLAGS: "-C debuginfo=1"
steps:
- uses: actions/checkout@v2
- name: Cache Cargo
uses: actions/cache@v2
with:
# these represent dependencies downloaded by cargo
# and thus do not depend on the OS, arch nor rust version.
path: ~/.cargo
key: cargo-cache-
- name: Cache Rust dependencies
uses: actions/cache@v2
with:
# these represent compiled steps of both dependencies and arrow
# and thus are specific for a particular OS, arch and rust version.
path: target
key: ${{ runner.os }}-${{ matrix.TARGET }}-target-cache-${{ matrix.RUST }}-
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-01-20
override: true
components: rustfmt
# - name: update all third-party dependencies
# run: |
# cargo update
- name: Install and configure dependencies
run: |
# dependencies are only needed on ubuntu as that's the only place where
# we make cross-compilation
if [[ $OS =~ ^ubuntu.*$ ]]; then
sudo apt install musl-tools
sudo apt-get install -qq crossbuild-essential-arm64 crossbuild-essential-armhf
wget http://more.musl.cc/$(uname -m)-linux-musl/aarch64-linux-musl-cross.tgz
tar -xvf aarch64-linux-musl-cross.tgz
sudo mv aarch64-linux-musl-cross /opt/
echo 'export PATH=/opt/aarch64-linux-musl-cross/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
fi
# some additional configuration for cross-compilation on linux
cat >~/.cargo/config <<EOF
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
[target.aarch64-unknown-linux-musl]
linker = "/opt/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc"
ar = "/opt/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc-ar"
rustflags = [ "-L /opt/aarch64-linux-musl-cross/aarch64-linux-musl/lib", "-C", "link-arg=-lgcc", "-C", "link-arg=/opt/aarch64-linux-musl-cross/aarch64-linux-musl/lib/libc.a" ]
EOF
- name: Install rust target
run: rustup target add $TARGET
- name: Run build
run: |
rustup default nightly-2022-01-20
cargo build --release --verbose --target $TARGET --features "simd mimalloc"
env:
CARGO_HOME: "~/.cargo"
CARGO_TARGET_DIR: "target"
CC_aarch64-unknown-linux-musl: "/opt/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc"
- name: List target
run: find ./target || true
- name: Compress
run: |
mkdir -p ./artifacts
if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then
TAG=$GITHUB_REF_NAME
else
TAG=$GITHUB_SHA
fi
if [ "$TARGET" == "aarch64-unknown-linux-gnu" ]; then
aarch64-linux-gnu-strip --strip-all ./target/$TARGET/release/flock
else
strip --strip-all ./target/$TARGET/release/flock
fi
mv header license
tar -czf ./artifacts/flock-$TARGET-$TAG.tar.gz ./target/$TARGET/release/flock ./target/$TARGET/release/flock-cli license
- name: Archive artifact
uses: actions/upload-artifact@v2
with:
name: result
path: |
./artifacts
# deploys to github releases on tag
deploy:
if: startsWith(github.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: result
path: ./artifacts
- name: List
run: find ./artifacts || true
- name: Release
uses: softprops/action-gh-release@v1
with:
files: ./artifacts/*.tar.gz