-
Notifications
You must be signed in to change notification settings - Fork 0
224 lines (196 loc) · 7.02 KB
/
build_and_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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
name: Build and Release for Windows and Linux
# TODO: Add MacOS
on:
push:
tags:
- "v*.*.*"
pull_request:
branches:
- main
env:
CARGO_TERM_COLOR: always
GITHUB_TOKEN: ${{ secrets.token }}
jobs:
release_cli:
if: github.event.pull_request.head.ref !~ 'dependabot/.*'
strategy:
matrix:
platform:
- target: x86_64-unknown-linux-gnu
cli_bin: rustbee
gui_bin: rustbee-gui
daemon_bin: rustbee-daemon
os_name: Linux-x86_64
os: ubuntu-latest
- target: x86_64-pc-windows-gnu
cli_bin: rustbee.exe
# houseabsolute/actions-rust-release@v0 perl script automatically adds .exe
cli_bin_no_ext: rustbee
gui_bin: rustbee-gui.exe
gui_bin_no_ext: rustbee-gui
daemon_bin: rustbee-daemon.exe
os_name: Windows-x86_64
os: windows-latest
# TODO: Respect Mac users, maybe ?
# - target: x86_64-apple-darwin
# bin: rustbee
# os_name: MacOS-x86_64
# os: macOS-latest
runs-on: ${{ matrix.platform.os }}
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.platform.target }}
override: true
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
- name: Install dependencies
if: ${{ matrix.platform.os == 'ubuntu-latest' }}
run: |
sudo apt install libdbus-1-dev pkg-config
- name: Build CLI
uses: houseabsolute/actions-rust-cross@v0
with:
working-directory: .
command: build
target: ${{ matrix.platform.target }}
args: "--locked --release"
- name: Build Daemon
uses: houseabsolute/actions-rust-cross@v0
with:
working-directory: ./rustbee-daemon
command: build
target: ${{ matrix.platform.target }}
args: "--locked --release"
# Note that it releases when is a tag and prefix is "v" or custom with "release-tag-prefix"
# https://github.com/houseabsolute/actions-rust-release/blob/v0/action.yml#L122
# TODO: Change author to houseabsolute if/when PR https://github.com/houseabsolute/actions-rust-release/pull/2
# is merged. Don't forget below one too
- name: Publish artifacts and release
uses: houseabsolute/actions-rust-release@v3
with:
working-directory: .
executable-name: ${{ matrix.platform.cli_bin_no_ext || matrix.platform.cli_bin }}
changes-file: CHANGELOG.md
target: ${{ matrix.platform.target }}
extra-files: |
rustbee-daemon/target/${{ matrix.platform.target }}/release/${{ matrix.platform.daemon_bin }}
README.md
Justfile
release_gui:
if: github.event.pull_request.head.ref !~ 'dependabot/.*'
# Copy of the above strategy
strategy:
matrix:
platform:
- target: x86_64-unknown-linux-gnu
cli_bin: rustbee
gui_bin: rustbee-gui
daemon_bin: rustbee-daemon
os_name: Linux-x86_64
os: ubuntu-latest
- target: x86_64-pc-windows-gnu
cli_bin: rustbee.exe
cli_bin_no_ext: rustbee
gui_bin: rustbee-gui.exe
gui_bin_no_ext: rustbee-gui
daemon_bin: rustbee-daemon.exe
os_name: Windows-x86_64
os: windows-latest
runs-on: ${{ matrix.platform.os }}
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.platform.target }}
override: true
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
- name: Install dependencies
if: ${{ matrix.platform.os == 'ubuntu-latest' }}
run: |
sudo apt install libdbus-1-dev pkg-config
- name: Build GUI
uses: houseabsolute/actions-rust-cross@v0
with:
working-directory: ./rustbee-gui
command: build
target: ${{ matrix.platform.target }}
args: "--locked --release"
- name: Build Daemon
uses: houseabsolute/actions-rust-cross@v0
with:
working-directory: ./rustbee-daemon
command: build
target: ${{ matrix.platform.target }}
args: "--locked --release"
- name: Publish artifacts and release
uses: houseabsolute/actions-rust-release@v3
with:
working-directory: ./rustbee-gui
executable-name: ${{ matrix.platform.gui_bin_no_ext || matrix.platform.gui_bin }}
changes-file: ../CHANGELOG.md
target: ${{ matrix.platform.target }}
extra-files: |
../rustbee-daemon/target/${{ matrix.platform.target }}/release/${{ matrix.platform.daemon_bin }}
../README.md
../Justfile
release_c_lib:
if: github.event.pull_request.head.ref !~ 'dependabot/.*'
# Copy of the above strategy
strategy:
matrix:
platform:
- target: x86_64-unknown-linux-gnu
os_name: Linux-x86_64
os: ubuntu-latest
- target: x86_64-pc-windows-gnu
os_name: Windows-x86_64
os: windows-latest
runs-on: ${{ matrix.platform.os }}
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.platform.target }}
override: true
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
- name: Install dependencies
if: ${{ matrix.platform.os == 'ubuntu-latest' }}
run: |
sudo apt install libdbus-1-dev pkg-config
- name: Build C dynamic library
run: |
cd rustbee-common
rustup target add ${{ matrix.platform.target }}
cargo rustc --release --features ffi --crate-type=cdylib --target ${{ matrix.platform.target }}
mkdir artifacts
cp librustbee.h artifacts
cp target/${{ matrix.platform.target }}/release/*rustbee* artifacts
- name: Remove the _common extensions for consistency
continue-on-error: true
run: |
set +e
cd rustbee-common/artifacts
mv rustbee_common.dll rustbee.dll
mv rustbee_common.d rustbee.d
mv librustbee_common.dll.a librustbee.dll.a
mv librustbee_common.so librustbee.so
mv librustbee_common.d librustbee.d
- name: Publish artifacts
uses: actions/upload-artifact@v4
with:
name: librustbee-${{ matrix.platform.os_name }}-gnu
path: rustbee-common/artifacts
- name: Publish GitHub release
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
uses: softprops/action-gh-release@v2
with:
draft: true
files: rustbee-common/artifacts
body_path: CHANGELOG.md