-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (120 loc) · 3.97 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
name: Deploy unix
on: [push, pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1.0.1
with:
toolchain: stable
override: true
- name: Check style
run: cargo fmt -- --check
- name: Check tag with toml
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')}}
run: |
VERSION_TAG="$(git describe --tags --abbrev=0)"
echo "Version tag: $VERSION_TAG"
echo "Checking if toml is updated.."
grep ${VERSION_TAG:1} Cargo.toml
- name: Install libraries
run: |
sudo apt update
sudo apt install --yes libudev-dev
- name: Build
run: cargo build --verbose
build-x86_64:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1.0.1
with:
toolchain: stable
override: true
- name: Install linux libraries
run: |
uname -a
sudo apt update
sudo apt install -y libudev-dev
- uses: actions-rs/cargo@v1
with:
command: build
args: --verbose --release
- name: Rename
run: cp target/release/linux2rest linux2rest-x86_64
- uses: actions/upload-artifact@master
with:
name: linux2rest-x86_64
path: linux2rest-x86_64
- uses: svenstaro/upload-release-action@v2
name: Upload binaries to release
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')}}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: linux2rest-x86_64
asset_name: linux2rest-x86_64
tag: ${{ github.ref }}
overwrite: true
build-armv7:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1.0.0
- name: Restore cache
uses: actions/cache@v2
id: cache
with:
path: /tmp/.cache
key: ${{ runner.os }}-cargo-armv7-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-armv7-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}
${{ runner.os }}-cargo-armv7-${{ hashFiles('Cargo.toml') }}
${{ runner.os }}-cargo-armv7
- uses: uraimo/run-on-arch-action@v2.7.1
id: runcmd
with:
arch: armv7
distro: ubuntu18.04
githubToken: ${{ github.token }}
setup: |
mkdir -p /tmp/.cache
install: |
uname -a
apt update
apt install -y libudev-dev curl gcc
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y
export PATH="$HOME/.cargo/bin:$PATH"
cargo install sccache --no-default-features
dockerRunArgs: |
--volume "/tmp/.cache:/tmp/.cache"
run: |
export SCCACHE_DIR=/tmp/.cache
export PATH="$HOME/.cargo/bin:$PATH"
apt install -y pkg-config libudev-dev libssl-dev openssl git
sccache --show-stats
# Fix issues related to git unable to use current directory since its not from current user
git config --global --add safe.directory '*'
RUSTC_WRAPPER=sccache cargo build --verbose --release --features raspberry
sccache --show-stats
- name: Rename
run: |
cp target/release/linux2rest linux2rest-armv7
- name: Fix cache owner
run: |
sudo chown $(whoami) -R /tmp/.cache
- uses: actions/upload-artifact@master
with:
name: linux2rest-armv7
path: linux2rest-armv7
- uses: svenstaro/upload-release-action@v2
name: Upload binaries to release
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')}}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: linux2rest-armv7
asset_name: linux2rest-armv7
tag: ${{ github.ref }}
prerelease: true
overwrite: true