-
Notifications
You must be signed in to change notification settings - Fork 10
141 lines (117 loc) · 3.74 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
131
132
133
134
135
136
137
138
139
140
141
name: Build
on:
pull_request:
branches:
- master
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"
runs-on: ubuntu-20.04
steps:
- name: Install common libs
run: |
sudo apt-get update
sudo apt-get install pkg-config libssl-dev lintian libpqxx-dev libxmlsec1-dev libclang-9-dev
- name: Install Rust
uses: actions-rs/[email protected]
with:
profile: minimal
toolchain: stable
override: true
target: ${{ matrix.target }}
- name: Checkout
uses: actions/[email protected]
- name: Restore cache
uses: Swatinem/[email protected]
with:
key: ${{ matrix.target }}
- name: Install Cargo Deb
uses: actions-rs/[email protected]
with:
command: install
args: cargo-deb --vers=${{ env.CARGO_DEB_VER }} --locked
- name: Create package
uses: actions-rs/[email protected]
with:
command: deb
args: -p akr --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 asset
uses: actions/[email protected]
with:
name: akr-deb
path: target/${{ matrix.target }}/debian/*.deb
rpm:
name: RPM package
env:
CARGO_GENERATE_RPM_VER: 0.7.0
strategy:
matrix:
image:
- "centos:7"
- "alvistack/centos-9-stream"
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 Rust
uses: actions-rs/[email protected]
with:
profile: minimal
toolchain: stable
override: true
- name: Checkout
uses: actions/[email protected]
- name: Restore cache
uses: Swatinem/[email protected]
with:
key: ${{ matrix.image }}
- name: Delete previous RPM
run: rm -f target/generate-rpm/*.rpm
- name: Install Cargo Generate RPM
uses: actions-rs/[email protected]
with:
command: install
args: cargo-generate-rpm --vers=${{ env.CARGO_GENERATE_RPM_VER }} --locked
- name: Build binary
uses: actions-rs/[email protected]
with:
command: build
args: --release
- name: Remove all symbol and relocation information
run: strip -s target/release/akr
- 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/[email protected]
with:
command: generate-rpm
args: -p crates/kr ${{ env.CENTOS_BUILD_FLAGS }}
- name: Verify package
run: |
# do not use exit codes while errors occured
rpmlint target/generate-rpm/akr-*.rpm || true
- name: Upload RPM
uses: actions/[email protected]
with:
name: akr-${{ matrix.image == 'centos:7' && 'centos-7' || 'centos-9-stream' }}
path: target/generate-rpm/*.rpm