-
-
Notifications
You must be signed in to change notification settings - Fork 0
301 lines (257 loc) · 11.4 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
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
name: Build
on:
workflow_dispatch:
push:
paths:
- '.github/workflows/build.yml'
- 'package.json'
- 'src-tauri/**/*'
- 'src/**/*'
pull_request:
paths:
- '.github/workflows/build.yml'
- 'package.json'
- 'src-tauri/**/*'
- 'src/**/*'
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
env:
CARGO_INCREMENTAL: 0
jobs:
build:
runs-on: ${{ matrix.config.platform }}
strategy:
fail-fast: false
matrix:
config:
- platform: ubuntu-latest
target: 'x86_64-unknown-linux-gnu'
- platform: ubuntu-latest
target: 'aarch64-unknown-linux-gnu'
- platform: ubuntu-latest
target: 'armv7-unknown-linux-gnueabihf'
- platform: macos-latest
target: 'x86_64-apple-darwin'
- platform: macos-latest
target: 'aarch64-apple-darwin'
- platform: windows-latest
target: 'x86_64-pc-windows-msvc'
- platform: windows-latest
target: 'aarch64-pc-windows-msvc'
steps:
- uses: actions-rust-lang/[email protected]
- uses: pnpm/action-setup@v3
with:
version: latest
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: latest
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
src-tauri/target/
key: ${{ runner.os }}-${{ matrix.config.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: (Linux) ARM sources.list
if: matrix.config.target == 'aarch64-unknown-linux-gnu' || matrix.config.target == 'armv7-unknown-linux-gnueabihf'
run: |
# Add [arch=amd64] to the initial entries of the sources.list
sudo sed -i 's/^deb /deb [arch=amd64] /' /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs) main restricted" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-updates main restricted" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs) universe" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-updates universe" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs) multiverse" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-updates multiverse" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-security main restricted" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-security universe" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-security multiverse" | sudo tee -a /etc/apt/sources.list
# ARM-linux related sources and dpkg config and such
- name: (Linux) ARM setup
if: matrix.config.target == 'aarch64-unknown-linux-gnu' || matrix.config.target == 'armv7-unknown-linux-gnueabihf'
run: |
sudo dpkg --add-architecture arm64
sudo dpkg --add-architecture armhf
sudo apt-get update
- name: (Linux) Install dependencies
if: matrix.config.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev \
libsoup-3.0-dev \
build-essential \
curl \
wget \
libssl-dev \
libgtk-3-dev \
librsvg2-dev
- name: (Linux) (ARMv7) Install dependencies
if: matrix.config.target == 'armv7-unknown-linux-gnueabihf'
run: |
sudo apt-get install -y \
libc6:armhf \
libwebkit2gtk-4.1-dev:armhf \
libssl-dev:armhf \
libsoup-3.0-dev:armhf \
gcc-arm-linux-gnueabihf
- name: (Linux) (ARM64) Install dependencies
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get install -y \
libc6:arm64 \
libwebkit2gtk-4.1-dev:arm64 \
libssl-dev:arm64 \
libsoup-3.0-dev:arm64 \
gcc-aarch64-linux-gnu
- name: Add target
run: rustup target add ${{ matrix.config.target }}
- name: Install dependencies
run: pnpm install
- name: Build injected JS
run: pnpm build:js
- name: (Most) Build
# If we are compiling for Windows ARM, we can only support NSIS
run: pnpm tauri build --target ${{ matrix.config.target }} ${{ matrix.config.target == 'aarch64-pc-windows-msvc' && '--bundles nsis' || '' }} ${{ matrix.config.target == 'x86_64-unknown-linux-gnu' && '--bundles deb' || '' }}
if: matrix.config.target != 'aarch64-unknown-linux-gnu' && matrix.config.target != 'armv7-unknown-linux-gnueabihf'
env:
RUSTFLAGS: -Awarnings
CC: clang
- name: (Linux) (ARMv7) Build
if: matrix.config.target == 'armv7-unknown-linux-gnueabihf'
run: pnpm tauri build --target ${{ matrix.config.target }} --bundles deb
env:
RUSTFLAGS: -Awarnings -L/usr/lib/arm-linux-gnueabihf
CC: arm-linux-gnueabihf-gcc
PKG_CONFIG_SYSROOT_DIR: /usr/lib/arm-linux-gnueabihf
PKG_CONFIG_PATH: /usr/lib/arm-linux-gnueabihf/pkgconfig
- name: (Linux) (ARM64) Build
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: pnpm tauri build --target ${{ matrix.config.target }} --bundles deb
env:
RUSTFLAGS: -Awarnings -L/usr/lib/aarch64-linux-gnu
CC: aarch64-linux-gnu-gcc
PKG_CONFIG_SYSROOT_DIR: /usr/lib/aarch64-linux-gnu
PKG_CONFIG_PATH: /usr/lib/aarch64-linux-gnu/pkgconfig
# For portable installs
- name: Create empty config.json
run: cd src-tauri/target/${{ matrix.config.target }}/release && echo {} > config.json
# paths:
# Windows:
# - src-tauri/target/${{ matrix.config.target }}/release/peapod.exe
# Ubuntu:
# - src-tauri/target/${{ matrix.config.target }}/release/peapod
# MacOS:
# - src-tauri/target/${{ matrix.config.target }}/release/bundle/macos/peapod.app
- name: (Windows) Compress build
if: matrix.config.platform == 'windows-latest'
run: cd src-tauri/target/${{ matrix.config.target }}/release && 7z a -tzip -mx9 peapod.zip
peapod.exe
config.json
- name: (Linux) Compress build
if: matrix.config.platform == 'ubuntu-latest'
run: cd src-tauri/target/${{ matrix.config.target }}/release && tar -czvf peapod.tar.gz peapod config.json
# Windows portable
- name: (Windows) Upload portable
if: matrix.config.platform == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: peapod_${{ matrix.config.target }}_portable
path: src-tauri/target/${{ matrix.config.target }}/release/peapod.zip
# Windows MSI
- name: (Windows) Upload .msi
if: matrix.config.platform == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: peapod_${{ matrix.config.target }}_msi
path: src-tauri/target/${{ matrix.config.target }}/release/bundle/msi/*.msi
# Windows ARM only supports NSIS right now, but we should upload that too
- name: (Windows) Upload NSIS
if: matrix.config.platform == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: peapod_${{ matrix.config.target }}_nsis
path: src-tauri/target/${{ matrix.config.target }}/release/bundle/nsis/*.exe
# Ubuntu portable
- name: (Linux) Upload portable
if: matrix.config.platform == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: peapod_${{ matrix.config.target }}_portable
path: src-tauri/target/${{ matrix.config.target }}/release/peapod.tar.gz
# Ubuntu deb
- name: (Linux) Upload .deb
if: matrix.config.platform == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: peapod_${{ matrix.config.target }}_deb
path: src-tauri/target/${{ matrix.config.target }}/release/bundle/deb/*.deb
# Redhat rpm
# - name: (Linux) Upload .rpm
# if: matrix.config.platform == 'ubuntu-latest'
# uses: actions/upload-artifact@v4
# with:
# name: peapod_${{ matrix.config.target }}_rpm
# path: src-tauri/target/${{ matrix.config.target }}/release/bundle/rpm/*.rpm
- name: (Linux) Upload .appimage
if: matrix.config.platform == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: peapod_${{ matrix.config.target }}_appimage
path: src-tauri/target/${{ matrix.config.target }}/release/bundle/appimage/*.AppImage
- name: (MacOS) Upload .dmg
if: matrix.config.platform == 'macos-latest'
uses: actions/upload-artifact@v4
with:
name: peapod_${{ matrix.config.target }}_dmg
path: src-tauri/target/${{ matrix.config.target }}/release/bundle/dmg/*.dmg
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'schedule'
steps:
- name: Checkout
uses: actions/checkout@v4
# Download all artifacts from the build job
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Rename executables to their folder names
run: |
# get the folder name
folder_name=artifacts
# get the list of inner folders
folders=$(ls $folder_name)
# loop through the files in each folder
for folder in $folders; do
# Get the list of files in the folder
files=$(ls "$folder_name/$folder")
for file in $files; do
# Get the filename without extension
filename="${file%.*}"
# Get the extension (everything after the last dot)
extension="${file##*.}"
# Build the new filename with parent folder name and extension
new_filename="$folder_name/$folder/$folder.$extension"
# Rename the file
mv "$folder_name/$folder/$file" "$new_filename"
done
done
- name: Create release using all artifacts
uses: softprops/action-gh-release@v2
with:
files: artifacts/**
token: ${{ secrets.GITHUB_TOKEN }}
# Release name is the tag name
name: ${{ github.ref_name }}
draft: false
generate_release_notes: true
prerelease: false