-
-
Notifications
You must be signed in to change notification settings - Fork 1
216 lines (185 loc) · 7.43 KB
/
Copy pathci-flatpak.yml
File metadata and controls
216 lines (185 loc) · 7.43 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
---
name: CI-Flatpak
permissions: {}
on:
workflow_call:
inputs:
release_commit:
required: true
type: string
release_version:
required: true
type: string
env:
APP_ID: dev.lizardbyte.app.Koko
FREEDESKTOP_SDK_VERSION: "25.08"
NODE_VERSION: "24"
PYTHON_VERSION: "3.14"
jobs:
flatpak:
name: ${{ matrix.arch }}
env:
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-24.04-arm
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Setup uv
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
with:
enable-cache: true
- name: Sync Python tools
run: |
uv sync --locked --only-group flatpak \
--python "${PYTHON_VERSION}" \
--no-python-downloads \
--no-install-project
- name: Setup Flatpak dependencies
run: |
flatpak_user_install() {
local attempt
local max_attempts=5
local wait_seconds
for ((attempt = 1; attempt <= max_attempts; attempt++)); do
if flatpak --user install -y --or-update flathub "$@"; then
return 0
fi
if [ "${attempt}" -eq "${max_attempts}" ]; then
return 1
fi
wait_seconds=$((attempt * 15))
echo "Flatpak install failed; retrying in ${wait_seconds}s (${attempt}/${max_attempts})"
sleep "${wait_seconds}"
done
}
sudo apt-get update -y
sudo apt-get install -y flatpak
flatpak --user remote-add --if-not-exists flathub \
https://flathub.org/repo/flathub.flatpakrepo
flatpak_user_install \
"org.flatpak.Builder" \
"org.freedesktop.Platform/${MATRIX_ARCH}/${FREEDESKTOP_SDK_VERSION}" \
"org.freedesktop.Sdk/${MATRIX_ARCH}/${FREEDESKTOP_SDK_VERSION}" \
"org.freedesktop.Sdk.Extension.node${NODE_VERSION}/${MATRIX_ARCH}/${FREEDESKTOP_SDK_VERSION}" \
"org.freedesktop.Sdk.Extension.rust-stable/${MATRIX_ARCH}/${FREEDESKTOP_SDK_VERSION}"
flatpak run org.flatpak.Builder --version
- name: Generate Flatpak Node sources
run: |
uv run --locked --no-sync python -m flatpak_node_generator \
npm crates/client-web/package-lock.json \
--node-sdk-extension "org.freedesktop.Sdk.Extension.node${NODE_VERSION}//${FREEDESKTOP_SDK_VERSION}" \
--output generated-node-sources.json
- name: Generate Flatpak Cargo sources
run: |
uv run --locked --no-sync python \
./packaging/linux/flatpak/deps/flatpak-builder-tools/cargo/flatpak-cargo-generator.py \
Cargo.lock \
--output generated-cargo-sources.json
- name: Configure Flatpak manifest
env:
INPUT_RELEASE_COMMIT: ${{ inputs.release_commit }}
INPUT_RELEASE_VERSION: ${{ inputs.release_version }}
PR_CLONE_URL: ${{ github.event.pull_request.head.repo.clone_url }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
REPOSITORY_CLONE_URL: ${{ github.event.repository.clone_url }}
run: |
set -euo pipefail
clone_url="${REPOSITORY_CLONE_URL}"
commit="${INPUT_RELEASE_COMMIT}"
if [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then
echo "This is a PR event"
clone_url="${PR_CLONE_URL}"
commit="${PR_HEAD_SHA}"
git fetch --no-tags --depth=1 "${clone_url}" "${commit}"
fi
build_date="$(git show -s --format=%cs "${commit}")"
mkdir -p build artifacts
cp generated-node-sources.json build/
cp generated-cargo-sources.json build/
cp -r packaging/linux/flatpak/deps/shared-modules build/shared-modules
cp -r packaging/linux/flatpak/modules build/modules
cp "packaging/linux/flatpak/${APP_ID}.yml" "build/${APP_ID}.yml"
cp "packaging/linux/flatpak/${APP_ID}.metainfo.xml" "build/${APP_ID}.metainfo.xml"
sed -i \
-e "s|@BUILD_DATE@|${build_date}|g" \
-e "s|@BUILD_VERSION@|${INPUT_RELEASE_VERSION}|g" \
-e "s|@GITHUB_CLONE_URL@|${clone_url}|g" \
-e "s|@GITHUB_COMMIT@|${commit}|g" \
"build/${APP_ID}.yml"
sed -i \
-e "s|@BUILD_DATE@|${build_date}|g" \
-e "s|@BUILD_VERSION@|${INPUT_RELEASE_VERSION}|g" \
"build/${APP_ID}.metainfo.xml"
- name: Debug manifest
working-directory: build
run: cat "${APP_ID}.yml"
- 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: Build Linux Flatpak
working-directory: build
run: |
sudo su "$(whoami)" -c "flatpak run org.flatpak.Builder \
--arch=${MATRIX_ARCH} \
--force-clean \
--repo=repo \
--sandbox \
build-koko ${APP_ID}.yml"
sudo su "$(whoami)" -c "flatpak build-bundle \
--arch=${MATRIX_ARCH} \
./repo \
../artifacts/koko_${MATRIX_ARCH}.flatpak ${APP_ID}"
- name: Lint Flatpak
working-directory: build
run: |
exceptions_file="${GITHUB_WORKSPACE}/packaging/linux/flatpak/exceptions.json"
flatpak run --command=flatpak-builder-lint org.flatpak.Builder \
--exceptions \
--user-exceptions "${exceptions_file}" \
manifest \
"${APP_ID}.yml"
flatpak run --command=flatpak-builder-lint org.flatpak.Builder \
--exceptions \
--user-exceptions "${exceptions_file}" \
repo \
repo
- name: Package Flathub repo archive
if: matrix.arch == 'x86_64'
run: |
mkdir -p flathub/modules
cp "./build/generated-cargo-sources.json" "./flathub/"
cp "./build/generated-node-sources.json" "./flathub/"
cp "./build/${APP_ID}.yml" "./flathub/"
cp "./packaging/linux/flatpak/${APP_ID}.desktop" "./flathub/"
cp "./build/${APP_ID}.metainfo.xml" "./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
tar -czf ./artifacts/flathub.tar.gz -C ./flathub .
- name: Upload Artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
if-no-files-found: error
name: koko-flatpak-${{ matrix.arch }}
path: artifacts/