-
Notifications
You must be signed in to change notification settings - Fork 2
169 lines (144 loc) · 4.45 KB
/
release.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
name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
RUST_BACKTRACE: short
PKG_CONFIG_ALLOW_CROSS: 1
jobs:
# First run the same checks as in CI
check:
name: Check
uses: ./.github/workflows/ci.yml
build-deb:
name: Build Debian Package
needs: check
runs-on: ubuntu-latest
strategy:
matrix:
target:
- armv7-unknown-linux-gnueabihf
- aarch64-unknown-linux-gnu
- x86_64-unknown-linux-gnu
include:
- target: armv7-unknown-linux-gnueabihf
arch: armhf
- target: aarch64-unknown-linux-gnu
arch: arm64
- target: x86_64-unknown-linux-gnu
arch: amd64
steps:
- uses: actions/checkout@v4
- name: Install system dependencies
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: |
sudo apt-get update && \
sudo apt-get install -y libudev-dev && \
find /usr -name libudev.pc
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-${{ matrix.target }}-
- name: Install cross
uses: taiki-e/install-action@cross
- name: Install cargo-deb
uses: taiki-e/install-action@cargo-deb-v1
- name: Build
run: |
if [ "${{ matrix.target }}" = "x86_64-unknown-linux-gnu" ]; then
cargo build --release --target ${{ matrix.target }}
else
cross build --release --target ${{ matrix.target }}
fi
- name: Build deb package
run: cargo deb --target ${{ matrix.target }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: deb-${{ matrix.arch }}
path: target/${{ matrix.target }}/debian/*.deb
build-arch:
name: Build Arch Package
needs: check
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
include:
- target: x86_64-unknown-linux-gnu
arch: x86_64
- target: aarch64-unknown-linux-gnu
arch: aarch64
- target: armv7-unknown-linux-gnueabihf
arch: armv7h
container:
image: archlinux:base-devel
options: --privileged
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
pacman -Syu --noconfirm
pacman -S --noconfirm git rust cargo systemd pkg-config
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-arch-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install cross
uses: taiki-e/install-action@cross
- name: Prepare PKGBUILD
run: |
VERSION=$(grep -m1 'version =' Cargo.toml | cut -d '"' -f2)
sed -i "s/pkgver=.*/pkgver=$VERSION/" dist/arch/PKGBUILD
cp -r . "/tmp/modbus-relay"
cd /tmp
tar czf "modbus-relay.tar.gz" "modbus-relay"
- name: Build package
run: |
cd /tmp
mkdir -p pkg
cd pkg
mv ../modbus-relay.tar.gz .
cp /github/workspace/dist/arch/PKGBUILD .
CARCH=${{ matrix.arch }} makepkg -s --noconfirm
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: pkg-${{ matrix.arch }}
path: /tmp/pkg/*.pkg.tar.zst
create-release:
name: Create Release
needs: [build-deb, build-arch]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: deb-*/*.deb pkg-*/*.pkg.tar.zst
generate_release_notes: true