-
Notifications
You must be signed in to change notification settings - Fork 5
166 lines (150 loc) · 5.34 KB
/
cicd.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: CICD
on:
pull_request:
jobs:
cicd:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
build:
- aarch64
- aarch64-musl
- armv7
- i686
- amd64-musl
include:
- build: aarch64
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
use-cross: true
features: "--no-default-features --features rustls"
- build: aarch64-musl
os: ubuntu-latest
target: aarch64-unknown-linux-musl
use-cross: true
features: "--no-default-features --features rustls"
- build: armv7
os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
use-cross: true
features: "--no-default-features --features rustls"
- build: i686
os: ubuntu-latest
target: i686-unknown-linux-gnu
use-cross: true
features: "--no-default-features --features rustls"
- build: amd64-musl
os: ubuntu-latest
target: x86_64-unknown-linux-musl
use-cross: true
features: "--no-default-features --features rustls"
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
fetch-depth: 0
- name: Install prerequisites
shell: bash
run: |
case ${{ matrix.target }} in
arm-unknown-linux-gnueabihf) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
armv7-unknown-linux-gnueabihf) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
aarch64-unknown-linux-musl) sudo apt-get -y update; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
esac
- name: Extract crate information
shell: bash
run: |
echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV
echo "PROJECT_MAINTAINER=$(sed -n 's/^authors = \["\(.*\)"\]/\1/p' Cargo.toml)" >> $GITHUB_ENV
echo "PROJECT_HOMEPAGE=$(sed -n 's/^homepage = "\(.*\)"/\1/p' Cargo.toml)" >> $GITHUB_ENV
PROJECT_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)"
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
if [[ $PROJECT_VERSION == *-pre ]]; then
echo "VERSION_SUFFIX=nightly" >> $GITHUB_ENV
else
echo "VERSION_SUFFIX=$PROJECT_VERSION" >> $GITHUB_ENV
fi
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
default: true
- name: Show version information (Rust, cargo, GCC)
shell: bash
run: |
gcc --version || true
rustup -V
rustup toolchain list
rustup default
cargo -V
rustc -V
- name: Check format
run: cargo fmt -- --check
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.use-cross }}
command: build
args: ${{ matrix.features }} --release --target=${{ matrix.target }}
cicd-win:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
default: true
- name: Extract crate information
shell: bash
run: |
echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV
PROJECT_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)"
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
if [[ $PROJECT_VERSION == *-pre ]]; then
echo "VERSION_SUFFIX=nightly" >> $GITHUB_ENV
else
echo "VERSION_SUFFIX=$PROJECT_VERSION" >> $GITHUB_ENV
fi
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: ${{ matrix.features }} --release
cicd-mac:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-apple-darwin
override: true
default: true
- name: Extract crate information
shell: bash
run: |
echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV
PROJECT_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)"
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
if [[ $PROJECT_VERSION == *-pre ]]; then
echo "VERSION_SUFFIX=nightly" >> $GITHUB_ENV
else
echo "VERSION_SUFFIX=$PROJECT_VERSION" >> $GITHUB_ENV
fi
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: ${{ matrix.features }} --release