-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (121 loc) · 3.46 KB
/
action.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: Test all targets
on: [push, pull_request]
permissions:
contents: write
jobs:
quick-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/[email protected]
with:
toolchain: stable
override: true
- name: Check Type
run: cargo fmt -- --check
- name: Check Clippy
run: cargo clippy
- name: Build
run: cargo build
build-bin:
needs: quick-tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- TARGET: armv7-unknown-linux-gnueabihf
- TARGET: aarch64-unknown-linux-gnu
- TARGET: armv7-unknown-linux-musleabihf
- TARGET: aarch64-unknown-linux-musl
steps:
- name: Building ${{ matrix.TARGET }}
run: echo "${{ matrix.TARGET }}"
- uses: actions/checkout@v3
- name: Rust Setup
uses: actions-rs/[email protected]
with:
toolchain: stable
target: ${{ matrix.TARGET }}
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: "rust-cache"
shared-key: "build-bin-${{ matrix.TARGET }}"
- name: Rust Cross Build
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --verbose --release --target=${{ matrix.TARGET }}
- name: Move to it's target
run: |
mkdir dist
mkdir "dist/${{ matrix.TARGET }}"
mv $(find "./target" -type f -name "navigator-webassistant") "dist/${{ matrix.TARGET }}"
- name: Upload bin
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.TARGET }}
path: dist/${{ matrix.TARGET }}
- name: Upload bin
uses: actions/upload-artifact@v3
with:
name: bin
path: dist
test-local:
needs: build-bin
runs-on: raspbian-armv7-kernel-5.10.33
steps:
- uses: actions/checkout@master
- name: Download bin
uses: actions/download-artifact@v3
with:
name: armv7-unknown-linux-gnueabihf
path: dist
- name: Run in background
run: |
chmod +x ./dist/navigator-webassistant
./dist/navigator-webassistant > navigator.log 2>&1 &
PID=$!
sleep 10
if ps -p $PID > /dev/null; then
echo "navigator-webassistant started successfully with PID $PID."
else
echo "Error: navigator-webassistant failed to start."
exit 1
fi
kill $PID
release-assets:
needs: ["test-local"]
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
strategy:
fail-fast: false
matrix:
include:
- TARGET: armv7-unknown-linux-gnueabihf
- TARGET: aarch64-unknown-linux-gnu
- TARGET: armv7-unknown-linux-musleabihf
- TARGET: aarch64-unknown-linux-musl
steps:
- name: Download ${{ matrix.TARGET }} artifacts
uses: actions/download-artifact@v2
with:
name: ${{ matrix.TARGET }}
path: ${{ matrix.TARGET }}
- name: Compress Asset
run: |
sudo apt update
sudo apt install -y zip
cd ${{ matrix.TARGET }}
chmod +x ./navigator-webassistant
zip -rT ../${{ matrix.TARGET }}.zip *
- name: Upload assets to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ matrix.TARGET }}.zip
tag: ${{ github.ref }}
asset_name: ${{ matrix.TARGET }}.zip