Repository navigation
344 lines (295 loc) · 13 KB
/
Copy pathclient-release.yml
File metadata and controls
344 lines (295 loc) · 13 KB
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
name: "Build and release desktop"
on:
workflow_dispatch:
inputs:
tagName:
required: false
type: string
description: "tagName to be associated with this release."
release:
types: [published]
# This workflow will trigger on each push to the `release` branch to create or update a GitHub release, build your app, and upload the artifacts to the release.
jobs:
publish-tauri:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: "macos-14" # for Arm based macs (M1 and above).
args: "--target aarch64-apple-darwin"
- platform: "macos-14" # for Intel based macs.
args: "--target x86_64-apple-darwin"
- platform: "ubuntu-22.04" # for Tauri v1 you could replace this with ubuntu-20.04.
args: ""
- platform: "ubuntu-22.04-arm"
args: "--target aarch64-unknown-linux-gnu"
- platform: "windows-latest"
args: ""
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: setup pnpm
uses: pnpm/action-setup@v6
with:
run_install: false
- name: setup node
uses: actions/setup-node@v7
with:
node-version: lts/*
cache: pnpm
- name: install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
targets: ${{ matrix.platform == 'macos-14' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: "./desktop/src-tauri -> target"
- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-22.04' || matrix.platform == 'ubuntu-22.04-arm' # This must match the platform value defined above.
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf xdg-utils
# webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2.
- name: Import Apple Developer Certificate
if: matrix.platform == 'macos-14'
env:
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
echo $APPLE_CERTIFICATE | base64 --decode > certificate.p12
security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
security set-keychain-settings -t 3600 -u build.keychain
# Add build.keychain to the user keychain search list so that codesign
# (invoked later by tauri-action WITHOUT an explicit --keychain) can
# resolve the signing identity from it.
security list-keychains -d user -s build.keychain $(security list-keychains -d user | tr -d '"')
echo "Created keychain"
curl https://droposs.org/drop.der --output drop.der
# swiftc libs/appletrust/add-certificate.swift
# ./add-certificate drop.der
# rm add-certificate
# echo "Added certificate to keychain using swift util"
## Script is equivalent to:
sudo security authorizationdb write com.apple.trust-settings.admin allow
sudo security add-trusted-cert -d -r trustRoot -k build.keychain -p codeSign -u -1 drop.der
sudo security authorizationdb remove com.apple.trust-settings.admin
security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
echo "Imported certificate"
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
security find-identity -v -p codesigning build.keychain
- name: Verify Certificate
if: matrix.platform == 'macos-14'
run: |
CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep "Drop OSS")
CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
echo "CERT_ID=$CERT_ID" >> $GITHUB_ENV
echo "Certificate imported. Using identity: $CERT_ID"
- name: install frontend dependencies
run: pnpm install # change this to npm, pnpm or bun depending on which one you use.
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Do NOT set APPLE_CERTIFICATE / APPLE_CERTIFICATE_PASSWORD here. Doing so
# makes tauri-action import the cert into its own throwaway keychain and
# look up the identity by Apple-only name prefixes (e.g.
# "Developer ID Application:"), which never matches our "Drop OSS" cert
# and fails with "failed to resolve signing identity". Instead we rely on
# the build.keychain prepared above and only pass the resolved identity.
APPLE_SIGNING_IDENTITY: ${{ env.CERT_ID }}
NO_STRIP: true
with:
releaseId: ${{ github.event.release.id || '' }}
tagName: ${{ github.event.release.tag_name || inputs.tagName || 'v__VERSION__' }} # the action automatically replaces \_\_VERSION\_\_ with the app version.
releaseName: "Auto-release v__VERSION__"
releaseBody: "See the assets to download this version and install. This release was created automatically."
releaseDraft: false
prerelease: true
args: ${{ matrix.args }}
projectPath: "./desktop"
prepare-release-packages:
needs: publish-tauri
runs-on: ubuntu-22.04
permissions:
contents: read
outputs:
release-tag: ${{ steps.release.outputs.tag }}
version: ${{ steps.release.outputs.version }}
prerelease: ${{ steps.release.outputs.prerelease }}
steps:
- uses: actions/checkout@v7
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: lts/*
- name: Prepare release package metadata
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ github.event.release.tag_name || inputs.tagName }}
run: |
set -euo pipefail
version="$(jq -r '.version' desktop/src-tauri/tauri.conf.json)"
tag="${RELEASE_TAG:-v${version}}"
[[ "$version" =~ ^[0-9]+(\.[0-9]+)*$ ]]
[[ "$tag" =~ ^[A-Za-z0-9._-]+$ ]]
prerelease="$(gh release view "$tag" \
--repo "$GITHUB_REPOSITORY" \
--json isPrerelease --jq '.isPrerelease')"
if [[ "$prerelease" != "true" && "$prerelease" != "false" ]]; then
echo "GitHub returned an invalid pre-release flag for $tag: $prerelease" >&2
exit 1
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "prerelease=$prerelease" >> "$GITHUB_OUTPUT"
deb_name="Drop.Desktop.Client_${version}_amd64.deb"
gh release download "$tag" \
--repo "$GITHUB_REPOSITORY" \
--pattern "$deb_name" \
--dir "$RUNNER_TEMP"
node packages/update-release-packages.mjs "$tag" "$version" "$RUNNER_TEMP/$deb_name"
- name: Upload prepared package metadata
uses: actions/upload-artifact@v7
with:
name: prepared-release-packages
path: |
packages/drop-oss-app/PKGBUILD
packages/drop-oss-app/.SRCINFO
packages/drop-oss-app-bin/PKGBUILD
packages/drop-oss-app-bin/.SRCINFO
packages/flatpak/org.droposs.client.json
if-no-files-found: error
include-hidden-files: true
retention-days: 1
publish-aur:
needs: prepare-release-packages
if: needs.prepare-release-packages.outputs.prerelease == 'false'
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- uses: actions/checkout@v7
- name: Download prepared package metadata
uses: actions/download-artifact@v8
with:
name: prepared-release-packages
path: packages
- name: Publish AUR packages
env:
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
RELEASE_VERSION: ${{ needs.prepare-release-packages.outputs.version }}
run: |
set -euo pipefail
if [[ -z "$AUR_SSH_PRIVATE_KEY" ]]; then
echo "AUR_SSH_PRIVATE_KEY is required to publish the AUR packages." >&2
exit 1
fi
mkdir -p "$HOME/.ssh"
chmod 700 "$HOME/.ssh"
printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > "$HOME/.ssh/aur"
chmod 600 "$HOME/.ssh/aur"
ssh-keyscan -H aur.archlinux.org >> "$HOME/.ssh/known_hosts"
eval "$(ssh-agent -s)"
ssh-add "$HOME/.ssh/aur"
for package in drop-oss-app-bin drop-oss-app; do
package_dir="$RUNNER_TEMP/$package"
git clone "ssh://aur@aur.archlinux.org/$package.git" "$package_dir"
cp "packages/$package/PKGBUILD" "$package_dir/PKGBUILD"
cp "packages/$package/.SRCINFO" "$package_dir/.SRCINFO"
git -C "$package_dir" config user.name "github-actions[bot]"
git -C "$package_dir" config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git -C "$package_dir" add PKGBUILD .SRCINFO
if ! git -C "$package_dir" diff --cached --quiet; then
git -C "$package_dir" commit -m "Update to $RELEASE_VERSION"
git -C "$package_dir" push origin HEAD:master
fi
done
publish-arch:
needs: prepare-release-packages
runs-on: ubuntu-24.04
container: archlinux:base
defaults:
run:
shell: bash
permissions:
contents: write
steps:
- name: Install Arch packaging tools
run: pacman -Syu --noconfirm --needed base-devel git libarchive github-cli
- uses: actions/checkout@v7
- name: Download prepared package metadata
uses: actions/download-artifact@v8
with:
name: prepared-release-packages
path: packages
- name: Build Arch package
working-directory: packages/drop-oss-app-bin
run: |
set -euo pipefail
useradd --create-home builder
chown -R builder:builder .
# Repackage the prebuilt Debian binary without installing its runtime dependencies.
runuser -u builder -- makepkg --nodeps --noconfirm
- name: Upload Arch package
working-directory: packages/drop-oss-app-bin
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ needs.prepare-release-packages.outputs.release-tag }}
run: |
set -euo pipefail
package_list="$(runuser -u builder -- makepkg --packagelist)"
mapfile -t packages <<< "$package_list"
if [[ "${#packages[@]}" -ne 1 || ! -f "${packages[0]}" ]]; then
echo "Expected one built Arch package, found: $package_list" >&2
exit 1
fi
gh release upload "$RELEASE_TAG" "${packages[@]}" \
--repo "$GITHUB_REPOSITORY" \
--clobber
publish-flatpak:
needs: prepare-release-packages
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- name: Download prepared package metadata
uses: actions/download-artifact@v8
with:
name: prepared-release-packages
path: packages
- name: Install Flatpak build tools
run: |
sudo apt-get update
sudo apt-get install -y flatpak flatpak-builder
- name: Add Flathub and install build dependencies
run: |
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install --user --noninteractive flathub org.gnome.Platform//50 org.gnome.Sdk//50
- name: Build and upload Flatpak bundle
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ needs.prepare-release-packages.outputs.release-tag }}
RELEASE_VERSION: ${{ needs.prepare-release-packages.outputs.version }}
run: |
set -euo pipefail
repo="$RUNNER_TEMP/flatpak-repo"
build_dir="$RUNNER_TEMP/flatpak-build"
bundle="$RUNNER_TEMP/Drop.Desktop.Client_${RELEASE_VERSION}_x86_64.flatpak"
flatpak-builder --user --force-clean --repo="$repo" \
"$build_dir" packages/flatpak/org.droposs.client.json
flatpak build-bundle \
--runtime-repo=https://flathub.org/repo/flathub.flatpakrepo \
"$repo" "$bundle" org.droposs.client master
gh release upload "$RELEASE_TAG" "$bundle" \
--repo "$GITHUB_REPOSITORY" \
--clobber