Skip to content

Commit 5b1da1c

Browse files
ci(workflows): refactor ci (#4025)
1 parent 65f14e1 commit 5b1da1c

12 files changed

+1234
-1146
lines changed

.github/workflows/CI.yml

Lines changed: 0 additions & 1088 deletions
This file was deleted.

.github/workflows/_docker.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/ci-flatpak.yml

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
---
2+
name: CI-Flatpak
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
release_commit:
10+
required: true
11+
type: string
12+
release_tag:
13+
required: true
14+
type: string
15+
16+
jobs:
17+
build_linux_flatpak:
18+
name: ${{ matrix.arch }}
19+
env:
20+
APP_ID: dev.lizardbyte.app.Sunshine
21+
NODE_VERSION: "20"
22+
PLATFORM_VERSION: "23.08"
23+
runs-on: ${{ matrix.runner }}
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
include:
28+
- arch: x86_64
29+
runner: ubuntu-22.04
30+
- arch: aarch64
31+
runner: ubuntu-22.04-arm
32+
steps:
33+
- name: Maximize build space
34+
if: matrix.arch == 'x86_64'
35+
uses: easimon/maximize-build-space@v10
36+
with:
37+
root-reserve-mb: 10240
38+
remove-dotnet: 'true'
39+
remove-android: 'true'
40+
remove-haskell: 'true'
41+
remove-codeql: 'true'
42+
remove-docker-images: 'true'
43+
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
with:
47+
submodules: recursive
48+
49+
- name: Setup node
50+
id: node
51+
uses: actions/setup-node@v4
52+
with:
53+
node-version: ${{ env.NODE_VERSION }}
54+
55+
- name: Install npm dependencies
56+
run: npm install --package-lock-only
57+
58+
- name: Debug package-lock.json
59+
run: cat package-lock.json
60+
61+
- name: Setup python
62+
id: python
63+
uses: actions/setup-python@v5
64+
with:
65+
python-version: '3.12'
66+
67+
- name: Setup Dependencies Linux Flatpak
68+
run: |
69+
python -m pip install ./packaging/linux/flatpak/deps/flatpak-builder-tools/node
70+
71+
sudo apt-get update -y
72+
sudo apt-get install -y \
73+
cmake \
74+
flatpak
75+
76+
sudo su $(whoami) -c "flatpak --user remote-add --if-not-exists flathub \
77+
https://flathub.org/repo/flathub.flatpakrepo"
78+
79+
sudo su $(whoami) -c "flatpak --user install -y flathub \
80+
org.flatpak.Builder \
81+
org.freedesktop.Platform/${{ matrix.arch }}/${PLATFORM_VERSION} \
82+
org.freedesktop.Sdk/${{ matrix.arch }}/${PLATFORM_VERSION} \
83+
org.freedesktop.Sdk.Extension.node${NODE_VERSION}/${{ matrix.arch }}/${PLATFORM_VERSION} \
84+
"
85+
86+
flatpak run org.flatpak.Builder --version
87+
88+
- name: flatpak node generator
89+
# https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md
90+
run: flatpak-node-generator npm package-lock.json
91+
92+
- name: Debug generated-sources.json
93+
run: cat generated-sources.json
94+
95+
- name: Cache Flatpak build
96+
uses: actions/cache@v4
97+
with:
98+
path: ./build/.flatpak-builder
99+
key: flatpak-${{ matrix.arch }}-${{ github.sha }}
100+
restore-keys: |
101+
flatpak-${{ matrix.arch }}-
102+
103+
- name: Configure Flatpak Manifest
104+
run: |
105+
# variables for manifest
106+
branch="${{ github.head_ref }}"
107+
commit=${{ inputs.release_commit }}
108+
109+
# check the branch variable
110+
if [ -z "$branch" ]
111+
then
112+
echo "This is a PUSH event"
113+
branch=${{ github.ref_name }}
114+
build_version=${{ inputs.release_tag }}
115+
clone_url=${{ github.event.repository.clone_url }}
116+
else
117+
echo "This is a PR event"
118+
clone_url=${{ github.event.pull_request.head.repo.clone_url }}
119+
fi
120+
echo "Branch: ${branch}"
121+
echo "Commit: ${commit}"
122+
echo "Clone URL: ${clone_url}"
123+
124+
mkdir -p build
125+
mkdir -p artifacts
126+
127+
cmake -DGITHUB_CLONE_URL=${clone_url} \
128+
-B build \
129+
-S . \
130+
-DBUILD_VERSION=${build_version} \
131+
-DGITHUB_BRANCH=${branch} \
132+
-DGITHUB_COMMIT=${commit} \
133+
-DSUNSHINE_CONFIGURE_FLATPAK_MAN=ON \
134+
-DSUNSHINE_CONFIGURE_ONLY=ON
135+
136+
- name: Debug Manifest
137+
working-directory: build
138+
run: cat ${APP_ID}.yml
139+
140+
- name: Build Linux Flatpak
141+
working-directory: build
142+
run: |
143+
sudo su $(whoami) -c "flatpak run org.flatpak.Builder \
144+
--arch=${{ matrix.arch }} \
145+
--force-clean \
146+
--repo=repo \
147+
--sandbox \
148+
--stop-at=cuda build-sunshine ${APP_ID}.yml"
149+
cp -r .flatpak-builder copy-of-flatpak-builder
150+
sudo su $(whoami) -c "flatpak run org.flatpak.Builder \
151+
--arch=${{ matrix.arch }} \
152+
--force-clean \
153+
--repo=repo \
154+
--sandbox \
155+
build-sunshine ${APP_ID}.yml"
156+
rm -rf .flatpak-builder
157+
mv copy-of-flatpak-builder .flatpak-builder
158+
sudo su $(whoami) -c "flatpak build-bundle \
159+
--arch=${{ matrix.arch }} \
160+
./repo \
161+
../artifacts/sunshine_${{ matrix.arch }}.flatpak ${APP_ID}"
162+
sudo su $(whoami) -c "flatpak build-bundle \
163+
--runtime \
164+
--arch=${{ matrix.arch }} \
165+
./repo \
166+
../artifacts/sunshine_debug_${{ matrix.arch }}.flatpak ${APP_ID}.Debug"
167+
168+
- name: Lint Flatpak
169+
working-directory: build
170+
run: |
171+
exceptions_file="${{ github.workspace }}/packaging/linux/flatpak/exceptions.json"
172+
173+
echo "Linting flatpak manifest"
174+
flatpak run --command=flatpak-builder-lint org.flatpak.Builder \
175+
--exceptions \
176+
--user-exceptions "${exceptions_file}" \
177+
manifest \
178+
${APP_ID}.yml
179+
180+
echo "Linting flatpak repo"
181+
# TODO: add arg
182+
# --mirror-screenshots-url=https://dl.flathub.org/media \
183+
flatpak run --command=flatpak-builder-lint org.flatpak.Builder \
184+
--exceptions \
185+
--user-exceptions "${exceptions_file}" \
186+
repo \
187+
repo
188+
189+
- name: Package Flathub repo archive
190+
# copy files required to generate the Flathub repo
191+
if: matrix.arch == 'x86_64'
192+
run: |
193+
mkdir -p flathub/modules
194+
cp ./build/generated-sources.json ./flathub/
195+
cp ./build/package-lock.json ./flathub/
196+
cp ./build/${APP_ID}.yml ./flathub/
197+
cp ./build/${APP_ID}.metainfo.xml ./flathub/
198+
cp ./packaging/linux/flatpak/README.md ./flathub/
199+
cp ./packaging/linux/flatpak/flathub.json ./flathub/
200+
cp -r ./packaging/linux/flatpak/modules/. ./flathub/modules/
201+
# submodules will need to be handled in the workflow that creates the PR
202+
203+
# create the archive
204+
tar -czf ./artifacts/flathub.tar.gz -C ./flathub .
205+
206+
- name: Upload Artifacts
207+
uses: actions/upload-artifact@v4
208+
with:
209+
name: build-Linux-Flatpak-${{ matrix.arch }}
210+
path: artifacts/
211+
if-no-files-found: error

0 commit comments

Comments
 (0)