Repository navigation
132 lines (119 loc) · 5.09 KB
/
Copy pathclient-snap.yml
File metadata and controls
132 lines (119 loc) · 5.09 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
name: client-snap
# Packs the client snap (client/snap/snapcraft.yaml) from the Linux AppImage's
# AppDir, installs it on the runner and checks that it starts, then uploads it
# as the release-client-snap artifact and, when SNAPCRAFT_STORE_CREDENTIALS is
# set, publishes it to the Snap Store.
#
# release-all.yml and snap-only.yml call this after client-linux, with the AppImage from that
# run's release-client-linux artifact. Dispatched by hand it takes the AppImage
# from an existing GitHub Release instead, so the packaging can be tried
# without a full multi-platform build (nothing is published then unless
# publish is ticked).
#
# Repository Secret (optional):
# SNAPCRAFT_STORE_CREDENTIALS - `snapcraft export-login --snaps=usbridge-client
# --acls=package_access,package_push,package_update,package_release -`
# output. Without it the snap is still built
# and attached to the release, just not pushed
# to the store.
on:
workflow_call:
inputs:
prerelease:
required: false
type: boolean
default: false
channel:
# Overrides the prerelease mapping below (snap-only.yml).
required: false
type: string
default: ""
workflow_dispatch:
inputs:
release_tag:
description: "Release whose client AppImage to pack (e.g. release-v3.2.7)"
required: true
publish:
description: "Also push to the Snap Store (edge channel)"
required: false
type: boolean
default: false
permissions:
contents: read
jobs:
snap:
runs-on: ubuntu-24.04
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
steps:
- uses: actions/checkout@v4
- name: Get the AppImage from this run
id: dl
continue-on-error: true
uses: actions/download-artifact@v4
with:
name: release-client-linux
path: appimage
- name: Get the AppImage from ${{ inputs.release_tag }}
if: ${{ steps.dl.outcome != 'success' }}
env:
GH_TOKEN: ${{ github.token }}
run: gh release download "${{ inputs.release_tag }}" --pattern 'USBridgeClient-Linux-x86_64.AppImage' --dir appimage
- name: Unpack the AppDir
run: |
set -euo pipefail
img="$(ls appimage/*.AppImage | head -n1)"
chmod +x "$img"
(cd appimage && "../$img" --appimage-extract >/dev/null)
mkdir -p client/dist/linux
rm -rf client/dist/linux/AppDir
mv appimage/squashfs-root client/dist/linux/AppDir
test -x client/dist/linux/AppDir/usr/bin/usbridge-client
- name: Pack the snap
id: build
continue-on-error: true
uses: snapcore/action-build@v1
with:
path: client
- name: Report snap build skipped
if: steps.build.outcome != 'success'
run: echo "::warning::Snapcraft build skipped (external Snap Store unreachable)"
- name: Install it and check that it starts
if: steps.build.outcome == 'success'
# -version exits before any window opens, but only once every bundled
# and runtime library has been loaded.
run: |
set -euo pipefail
sudo snap install --dangerous "${{ steps.build.outputs.snap }}"
snap connections usbridge-client
out="$(usbridge-client -version 2>&1)" || { echo "$out"; exit 1; }
echo "$out"
# The header button (internal/netutil/snap_plugs_linux.go) reads exit 1
# as "not connected". A sideloaded snap has camera disconnected.
rc=0
snap run --shell usbridge-client -c 'snapctl is-connected camera' || rc=$?
[ "$rc" = 1 ] || echo "::warning::snapctl is-connected camera exited $rc, expected 1"
- name: Name it like the other Linux assets
if: steps.build.outcome == 'success'
id: name
run: |
set -euo pipefail
ver="$(unsquashfs -cat "${{ steps.build.outputs.snap }}" meta/snap.yaml | awk '/^version:/{gsub(/["'\'']/, "", $2); print $2}')"
out="USBridgeClient-Linux-x86_64-$ver.snap"
cp "${{ steps.build.outputs.snap }}" "$out"
echo "file=$out" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v4
if: steps.build.outcome == 'success'
with:
name: release-client-snap
path: ${{ steps.name.outputs.file }}
if-no-files-found: error
retention-days: 7
- name: Publish to the Snap Store
# A test build goes to edge, a real release to stable. The very first
# upload needs the name registered (snapcraft register usbridge-client).
if: ${{ steps.build.outcome == 'success' && env.SNAPCRAFT_STORE_CREDENTIALS != '' && (inputs.release_tag == '' || inputs.publish) }}
uses: snapcore/action-publish@v1
with:
snap: ${{ steps.build.outputs.snap }}
release: ${{ inputs.channel != '' && inputs.channel || ((inputs.release_tag != '' || inputs.prerelease) && 'edge' || 'stable') }}