Repository navigation
302 lines (262 loc) · 10.7 KB
/
Copy pathci-flatpak.yml
File metadata and controls
302 lines (262 loc) · 10.7 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
---
name: CI-Flatpak
permissions: {}
on:
workflow_call:
inputs:
release_commit:
required: true
type: string
release_version:
required: true
type: string
env:
PYTHON_VERSION: '3.14'
jobs:
build_linux_flatpak:
name: ${{ matrix.arch }}
env:
APP_ID: dev.lizardbyte.app.Sunshine
MATRIX_ARCH: ${{ matrix.arch }}
permissions:
contents: read
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
runner: ubuntu-22.04
- arch: aarch64
runner: ubuntu-22.04-arm
steps:
- name: More space
if: matrix.arch == 'x86_64'
uses: LizardByte/actions/actions/more_space@0528b495e6af82b4d698ec6c907a9b1842622068 # v2026.1029.234422
with:
analyze-space-savings: true
clean-all: true
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive
- name: Setup python
id: python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Setup uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
enable-cache: true
- name: Sync Python tools
run: |
uv_sync_args=(
--locked
--only-group flatpak
--python "${PYTHON_VERSION}"
--no-python-downloads
--no-install-project
)
# uv.lock pins external artifacts; reviewed local Flatpak generator build hooks are required.
uv sync "${uv_sync_args[@]}" # NOSONAR(githubactions:S8541, githubactions:S8544)
- name: Read Flatpak SDK versions
run: |
uv run --locked --no-build --no-sync python - <<'PY'
import os
import re
from pathlib import Path
import yaml
manifest_path = Path("packaging/linux/flatpak/dev.lizardbyte.app.Sunshine.yml")
manifest = yaml.safe_load(manifest_path.read_text(encoding="utf-8"))
kde_platform_version = str(manifest["runtime-version"])
node_extensions = [
(match.group(1), config)
for name, config in manifest["add-build-extensions"].items()
if (match := re.fullmatch(r"org\.freedesktop\.Sdk\.Extension\.node(\d+)", name))
]
if len(node_extensions) != 1:
raise ValueError(f"Expected one Node SDK extension, found {len(node_extensions)}")
node_version, node_extension = node_extensions[0]
freedesktop_sdk_version = str(node_extension["version"])
version_pattern = re.compile(r"\d+(?:\.\d+)*")
versions = {
"FREEDESKTOP_SDK_VERSION": freedesktop_sdk_version,
"KDE_PLATFORM_VERSION": kde_platform_version,
"NODE_VERSION": node_version,
}
for name, version in versions.items():
if not version_pattern.fullmatch(version):
raise ValueError(f"Invalid {name}: {version!r}")
with Path(os.environ["GITHUB_ENV"]).open("a", encoding="utf-8") as github_env:
for name, version in versions.items():
print(f"{name}={version}", file=github_env)
PY
- name: Setup Dependencies Linux Flatpak
run: |
sudo apt-get update -y
sudo apt-get install -y \
cmake \
flatpak
sudo su "$(whoami)" -c "flatpak --user remote-add --if-not-exists flathub \
https://flathub.org/repo/flathub.flatpakrepo
"
sudo su "$(whoami)" -c "flatpak --user install -y flathub \
org.flatpak.Builder \
org.kde.Platform/${MATRIX_ARCH}/${KDE_PLATFORM_VERSION} \
org.kde.Sdk/${MATRIX_ARCH}/${KDE_PLATFORM_VERSION} \
org.freedesktop.Sdk.Extension.node${NODE_VERSION}/${MATRIX_ARCH}/${FREEDESKTOP_SDK_VERSION} \
"
flatpak run org.flatpak.Builder --version
- name: flatpak node generator
# https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md
run: uv run --locked --no-build --no-sync python -m flatpak_node_generator npm package-lock.json
- name: Debug generated-sources.json
run: cat generated-sources.json
- name: flatpak pip generator
# generates glad-dependencies.json for PyPI build-time dependencies (e.g. jinja2 for glad)
run: |
uv export \
--quiet \
--locked \
--only-group glad \
--no-emit-project \
--no-emit-local \
--no-header \
--output-file glad-requirements.txt
# Install all exported Python dependencies under /app without modifying the SDK.
ignore_installed="$(
uv run --locked --no-build --no-sync python - <<'PY'
from pathlib import Path
import requirements
with Path("glad-requirements.txt").open(encoding="utf-8") as requirements_file:
packages = requirements.parse(requirements_file)
print(",".join(sorted({package.name.casefold() for package in packages if package.name})))
PY
)"
uv run --locked --no-build --no-sync python \
./packaging/linux/flatpak/deps/flatpak-builder-tools/pip/flatpak-pip-generator.py \
--runtime="org.kde.Sdk//${KDE_PLATFORM_VERSION}" \
--output glad-dependencies \
--build-only \
--ignore-installed="${ignore_installed}" \
--requirements-file=glad-requirements.txt
# Copy generated pip sources into build dir alongside the manifest
mkdir -p build
cp glad-dependencies.json build/
- name: Cache Flatpak build
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ./build/.flatpak-builder
key: flatpak-${{ matrix.arch }}-${{ github.sha }}
restore-keys: |
flatpak-${{ matrix.arch }}-
- name: Configure Flatpak Manifest
env:
INPUT_RELEASE_VERSION: ${{ inputs.release_version }}
INPUT_RELEASE_COMMIT: ${{ inputs.release_commit }}
PR_CLONE_URL: ${{ github.event.pull_request.head.repo.clone_url }}
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
REPOSITORY_CLONE_URL: ${{ github.event.repository.clone_url }}
run: |
# variables for manifest
branch="${GITHUB_REF}"
build_version="${INPUT_RELEASE_VERSION}"
commit="${INPUT_RELEASE_COMMIT}"
clone_url="${REPOSITORY_CLONE_URL}"
if [ "${GITHUB_EVENT_NAME}" == "push" ]; then
echo "This is a PUSH event"
branch="${GITHUB_REF_NAME}"
elif [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then
echo "This is a PR event"
branch="${PR_HEAD_REF}"
commit="${PR_HEAD_SHA}"
clone_url="${PR_CLONE_URL}"
fi
echo "Branch: ${branch}"
echo "Commit: ${commit}"
echo "Clone URL: ${clone_url}"
export BRANCH=${branch}
export BUILD_VERSION=${build_version}
export CLONE_URL=${clone_url}
export COMMIT=${commit}
mkdir -p build
mkdir -p artifacts
cmake -DGITHUB_CLONE_URL="${clone_url}" \
-B build \
-S . \
-DSUNSHINE_CONFIGURE_FLATPAK_MAN=ON \
-DSUNSHINE_CONFIGURE_ONLY=ON
- name: Debug Manifest
working-directory: build
run: cat "${APP_ID}.yml"
- name: Build Linux Flatpak
working-directory: build
run: |
echo "::add-matcher::.github/matchers/gcc-strip3.json"
sudo su "$(whoami)" -c "flatpak run org.flatpak.Builder \
--arch=${MATRIX_ARCH} \
--force-clean \
--repo=repo \
--sandbox \
--stop-at=cuda build-sunshine ${APP_ID}.yml"
cp -r .flatpak-builder copy-of-flatpak-builder
sudo su "$(whoami)" -c "flatpak run org.flatpak.Builder \
--arch=${MATRIX_ARCH} \
--force-clean \
--mirror-screenshots-url=https://dl.flathub.org/media \
--compose-url-policy=full \
--repo=repo \
--sandbox \
build-sunshine ${APP_ID}.yml"
rm -rf .flatpak-builder
mv copy-of-flatpak-builder .flatpak-builder
sudo su "$(whoami)" -c "flatpak build-bundle \
--arch=${MATRIX_ARCH} \
./repo \
../artifacts/sunshine_${MATRIX_ARCH}.flatpak ${APP_ID}"
sudo su "$(whoami)" -c "flatpak build-bundle \
--runtime \
--arch=${MATRIX_ARCH} \
./repo \
../artifacts/sunshine_debug_${MATRIX_ARCH}.flatpak ${APP_ID}.Debug"
echo "::remove-matcher owner=gcc-strip3::"
- name: Lint Flatpak
working-directory: build
run: |
exceptions_file="${GITHUB_WORKSPACE}/packaging/linux/flatpak/exceptions.json"
echo "Linting flatpak manifest"
flatpak run --command=flatpak-builder-lint org.flatpak.Builder \
--exceptions \
--user-exceptions "${exceptions_file}" \
manifest \
"${APP_ID}.yml"
echo "Linting flatpak repo"
flatpak run --command=flatpak-builder-lint org.flatpak.Builder \
--exceptions \
--user-exceptions "${exceptions_file}" \
repo \
repo
- name: Package Flathub repo archive
# copy files required to generate the Flathub repo
if: matrix.arch == 'x86_64'
run: |
mkdir -p flathub/modules
cp "./build/generated-sources.json" "./flathub/"
cp "./build/glad-dependencies.json" "./flathub/"
cp "./build/${APP_ID}.yml" "./flathub/"
cp "./build/${APP_ID}.metainfo.xml" "./flathub/"
cp "./package-lock.json" "./flathub/"
cp "./packaging/linux/flatpak/README.md" "./flathub/"
cp "./packaging/linux/flatpak/flathub.json" "./flathub/"
cp -r "./packaging/linux/flatpak/modules/." "./flathub/modules/"
# submodules will need to be handled in the workflow that creates the PR
# create the archive
tar -czf ./artifacts/flathub.tar.gz -C ./flathub .
- name: Upload Artifacts
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: build-Linux-Flatpak-${{ matrix.arch }}
path: artifacts/
if-no-files-found: error