-
Notifications
You must be signed in to change notification settings - Fork 0
187 lines (158 loc) · 5.26 KB
/
pkg.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: Packaging
on:
workflow_dispatch:
workflow_call:
push:
paths:
- ".github/workflows/pkg.yml"
branches:
- master
pull_request:
paths:
- ".github/workflows/pkg.yml"
jobs:
deb:
name: Deb package
env:
CARGO_DEB_VER: 1.38.2
DEBIAN_FRONTEND: noninteractive
PKG_CONFIG_ALLOW_CROSS: 1
strategy:
matrix:
target:
- "x86_64-unknown-linux-gnu"
- "armv7-unknown-linux-gnueabihf"
runs-on: ubuntu-20.04
steps:
- name: Install common libs
run: |
sudo apt-get update
sudo apt-get install pkg-config libssl-dev lintian
- name: Install libs for ARMv7
if: matrix.target == 'armv7-unknown-linux-gnueabihf'
run: |
sudo dpkg --add-architecture armhf
sudo sed 's/deb http/deb \[arch=amd64,i386\] http/' -i /etc/apt/sources.list
sudo tee -a /etc/apt/sources.list > /dev/null <<EOF
deb [arch=armhf] http://ports.ubuntu.com/ focal main universe restricted multiverse
deb [arch=armhf] http://ports.ubuntu.com/ focal-updates main universe restricted multiverse
deb [arch=armhf] http://ports.ubuntu.com/ focal-security main universe restricted multiverse
EOF
sudo apt-get update
sudo apt-get install -y libssl-dev:armhf gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: ${{ matrix.target }}
- name: Checkout
uses: actions/checkout@v3
- name: Restore cache
uses: Swatinem/rust-cache@v1
with:
key: ${{ matrix.target }}
- name: Install Cargo Deb
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-deb --vers=${{ env.CARGO_DEB_VER }} --locked
- name: Create debian changelog
run: |
python scripts/kac2debian_changelog.py --input CHANGELOG.md --output pkg/doc/changelog --package-name alerter --author ultram4rine --email ultramarine730@gmail.com
- name: Generate man page
uses: actions-rs/cargo@v1
with:
command: run
args: --bin=mangen
- name: Create package
uses: actions-rs/cargo@v1
with:
command: deb
args: --target=${{ matrix.target }}
- name: Verify package
run: |
# do not use exit codes while errors occured
lintian -v target/${{ matrix.target }}/debian/*.deb || true
- name: Upload package
uses: actions/upload-artifact@v3
with:
name: alerter-deb
path: |
target/${{ matrix.target }}/debian/*.deb
rpm:
name: RPM package
env:
CARGO_GENERATE_RPM_VER: 0.6.0
strategy:
matrix:
image:
- "centos:7"
- "fedora:34"
runs-on: ubuntu-20.04
container:
image: ${{ matrix.image }}
steps:
- name: Install libs on CentOS
if: startsWith(matrix.image, 'centos')
run: |
yum update -y && yum install -y epel-release && yum install -y gcc make cmake3 gcc-c++ openssl-devel gzip rpmlint
ln -s /usr/bin/cmake3 /usr/bin/cmake
- name: Install libs on Fedora
if: startsWith(matrix.image, 'fedora')
run: dnf install --refresh -y gcc cmake gcc-c++ openssl-devel gzip rpmlint
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Checkout
uses: actions/checkout@v3
- name: Restore cache
uses: Swatinem/rust-cache@v1
with:
key: ${{ matrix.image }}
- name: Delete previous RPM
run: rm -f target/generate-rpm/*.rpm
- name: Install Cargo Generate RPM
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-generate-rpm --vers=${{ env.CARGO_GENERATE_RPM_VER }} --locked
- name: Generate man page
uses: actions-rs/cargo@v1
with:
command: run
args: --bin=mangen
- name: Compress man page
run: |
gzip -c pkg/doc/alerter.1 > pkg/doc/alerter.1.gz
- name: Build binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: Remove all symbol and relocation information
run: strip -s target/release/alerter
- name: Set compress type for CentOS 7
if: matrix.image == 'centos:7'
run: echo "CENTOS_BUILD_FLAGS=--payload-compress=gzip" >> $GITHUB_ENV
- name: Add dist to release
run: dist=$(rpm --eval %{?dist}); sed -i -e 's/release = "\(.*\)"/release = "\1'$dist'"/g' Cargo.toml
- name: Create package
uses: actions-rs/cargo@v1
with:
command: generate-rpm
args: ${{ env.CENTOS_BUILD_FLAGS }}
- name: Verify package
run: |
# do not use exit codes while errors occured
rpmlint target/generate-rpm/alerter-*.rpm || true
- name: Upload package
uses: actions/upload-artifact@v3
with:
name: alerter-rpm
path: |
target/generate-rpm/alerter-*.rpm