-
Notifications
You must be signed in to change notification settings - Fork 1
243 lines (225 loc) · 7.85 KB
/
build-client.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
name: Build client
on:
push:
branches:
- '*'
paths:
- .github/actions/version/action.yml
- .github/workflows/build-client.yml
- client/**
- server/constants.json
tags:
- 'v*'
workflow_dispatch:
env:
CLIENT_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || 'preview' }}
NODE_VERSION: 20
concurrency:
group: client-build-${{ github.ref_type }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.os }}
name: Build ${{ matrix.title }}
strategy:
matrix:
include:
-
title: macOS
os: macos-13
arch: universal
platform: darwin
out_path: "*.dmg"
filename_suffix: macos.dmg
-
title: Windows
os: windows-2022
arch: x64
platform: win32
out_path: squirrel.windows/x64/*.exe
filename_suffix: windows.exe
-
title: Linux (amd64)
os: ubuntu-22.04
arch: x64
platform: linux
out_path: deb/x64/*.deb
filename_suffix: linux_amd64.deb
-
title: Linux (arm64)
os: ubuntu-22.04
arch: arm64
platform: linux
out_path: deb/arm64/*.deb
filename_suffix: linux_arm64.deb
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Get version
id: version
uses: ./.github/actions/version
-
name: Set variables
shell: bash
run: |
echo "CLIENT_FILENAME=tomato-client-${{ env.CLIENT_VERSION }}-${{ matrix.filename_suffix }}" | tee -a "${GITHUB_ENV}"
if [ "${{ github.ref_type }}" != 'tag' -a "${{ github.ref_name}}" != main ]; then
echo "EXTRA_BUILD_INFO=Branch: ${{ github.ref_name}}" | tee -a "${GITHUB_ENV}"
fi
-
name: Setup Node v${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
-
# macOS: appears to fix https://github.com/electron/forge/issues/2807
name: Fix macOS build
uses: actions/setup-python@v5
if: matrix.platform == 'darwin'
with:
python-version: '3.11'
-
name: Build package
shell: bash
run: |
echo "Building Tomato for ${{ matrix.title }} (${{ steps.version.outputs.version }})"
cd client
echo "Settings package.json version to ${{ steps.version.outputs.version-short }}"
jq '.version = "${{ steps.version.outputs.version-short }}"' package.json > package.json.tmp
mv -v package.json.tmp package.json
if [ "${{ matrix.platform }}" = "win32" ]; then
npm config set script-shell $(which bash)
fi
npm clean-install
TOMATO_VERSION=${{ steps.version.outputs.version }} TOMATO_EXTRA_BUILD_INFO="${EXTRA_BUILD_INFO}" npm run build
npx electron-forge make --arch ${{ matrix.arch }} --platform ${{ matrix.platform }}
mkdir ../client-build-files
mv -v out/make/${{ matrix.out_path }} ../client-build-files/${{ env.CLIENT_FILENAME }}
if [ "${{ matrix.platform }}" = "linux" -a "${{ matrix.arch }}" = "x64" ]; then
mv -v out/make/AppImage/x64/*.AppImage ../client-build-files/${CLIENT_FILENAME%.*}.AppImage
fi
-
name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: client-build-files-${{ matrix.platform }}-${{ matrix.arch }}
path: client-build-files
compression-level: 0
retention-days: 2
tag:
runs-on: ubuntu-22.04
name: Tag release
if: github.ref_type == 'tag' || github.ref_name == 'main'
needs: build
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Get version
id: version
uses: ./.github/actions/version
-
name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: client-build-files-*
path: client-build-files
merge-multiple: true
-
name: Remove old preview release
uses: dev-drprasad/[email protected]
if: github.ref_type != 'tag'
with:
delete_release: true
tag_name: preview-build
github_token: ${{ secrets.GITHUB_TOKEN }}
-
name: Wait for last preview deletion
shell: bash
if: github.ref_type != 'tag'
run: |
sleep 15s
-
name: Tag and upload preview release
uses: ncipollo/release-action@v1
if: github.ref_type != 'tag'
with:
artifacts: "./client-build-files/*"
name: 'Tomato Preview Build (${{ steps.version.outputs.version }})'
body: |
_**This development preview build may not be safe: use it at your own risk!**_
* Release version: `${{ steps.version.outputs.version }}`
* Protocol version: `${{ steps.version.outputs.protocol }}`
tag: 'preview-build'
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
-
name: Tag and upload release
uses: ncipollo/release-action@v1
if: github.ref_type == 'tag'
with:
artifacts: "./client-build-files/*"
name: 'Tomato Release ${{ steps.version.outputs.version }}'
body: |
Choose a client to download below. Server containers [can be found here](https://github.com/dtcooper/tomato/pkgs/container/tomato-server).
* Release version: `${{ steps.version.outputs.version }}`
* Protocol version: `${{ steps.version.outputs.protocol }}`
tag: ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
generateReleaseNotes: true
aur:
runs-on: ubuntu-22.04
name: Publish to AUR
if: github.ref_type == 'tag'
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Get version
id: version
uses: ./.github/actions/version
-
name: Publish to Arch User Repository (AUR)
shell: bash
run: |
# Set up ssh key and git
mkdir -p ~/.ssh
chmod 0700 ~/.ssh
ssh-keyscan -t 'rsa,ecdsa,ed25519' aur.archlinux.org | tee -a ~/.ssh/known_hosts
echo "${{ secrets.AUR_SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 0600 ~/.ssh/id_ed25519
git config set --global user.name "${{ secrets.AUR_NAME }}"
git config set --global user.email "${{ secrets.AUR_EMAIL }}"
# Clone to AUR repo
git clone ssh://[email protected]/tomato-radio-automation.git aur
cd aur
# Update versions
sed -i "s/^pkgver=.*/pkgver=${{ steps.version.outputs.version }}/" PKGBUILD
sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD
# Run in an arch docker container
docker run -i --rm -v "$PWD:/aur" archlinux:base-devel /bin/bash -e <<'EOF'
# Exit on failure
set -e
# Install deps
pacman -Sy --noconfirm --needed pacman-contrib rsync sudo
# Add user, copy over package build files
useradd builduser -m
echo 'builduser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
cd ~builduser
sudo -u builduser rsync -vr --exclude=.git /aur .
# Update checksums and .SRCINFO
cd aur
sudo -u builduser updpkgsums
sudo -u builduser makepkg --printsrcinfo > .SRCINFO
rm -fv *.tar.gz
# Copy back updated files
rsync -vr ~builduser/aur/ /aur
EOF
# Push changes to AUR
git add -A
git commit -m "Moved to version ${{ steps.version.outputs.version }}"
git push