Skip to content

Commit 28d91c0

Browse files
committed
chore: add CI to publish Flatpak to Mixxx repo
1 parent ea97894 commit 28d91c0

3 files changed

Lines changed: 173 additions & 6 deletions

File tree

.github/workflows/flatpak.yml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: Flatpak
2+
on:
3+
workflow_call:
4+
inputs:
5+
update_repo:
6+
type: boolean
7+
default: false
8+
run_id:
9+
type: string
10+
required: true
11+
ref:
12+
type: string
13+
required: true
14+
secrets:
15+
DOWNLOADS_HOSTGATOR_DOT_MIXXX_DOT_ORG_KEY:
16+
required: false
17+
RRYAN_AT_MIXXX_DOT_ORG_GPG_PRIVATE_KEY:
18+
required: false
19+
20+
jobs:
21+
publish-flatpak:
22+
name: Publish Flatpak
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: "Set up SSH Agent"
26+
shell: bash
27+
env:
28+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
29+
SSH_PRIVATE_KEY: ${{ secrets.DOWNLOADS_HOSTGATOR_DOT_MIXXX_DOT_ORG_KEY }}
30+
SSH_HOST: downloads-hostgator.mixxx.org
31+
run: |
32+
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
33+
ssh-add - <<< "${SSH_PRIVATE_KEY}"
34+
mkdir -p "${HOME}/.ssh"
35+
cat >> "${HOME}/.ssh/known_hosts" <<EOF
36+
${SSH_HOST} ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDQtz9VUh6ZindK6DiHQ108KUVI8yQX/PQSUSrMZJ0kWD56yi/mzpZ9Q6hB9E2Gd94CmoDQwnAHQiV6k8461Qv4wGK1ykFwsUG3iOXm/gPOP1Sd1u6GI9SF/ixh/a+WatzzjdC8Y8c0BuuYufV7/Hox6IHvoVsrRWQQwXcK/tpCOzgwgUBzoDxhmS5lFtTfOK6JIOcXbOFmiKWzBVnXCawBKZBEeajkvyTqhLCCu7xbhqXIsBP/UTMeFNsyzIqvJvqHgEm5MPo04PtX1Myvnzv15/cT23PQDGNKANCrMSrUAWtqSFMZdWSehS2R0BbCJ1TJIgsG1Zc+BBDL8vYOesm8TpkXvUdMKWSuptEawYMDORQgjXerTHtsYzvpYNAV4Cm0ajJXngjM926++F1PvlvXs7sLhhOVzVTELgJYwiqFZcIBEdR8jgEkwLQ9Goig0h8lFJpcIket0pmFPTytzrev3gyWnymdZ9ScIo4wEmnwAKNGVMFArZ7O3Ckx/qXAyb8=
37+
${SSH_HOST} ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBC/q8hYkss2z4UhT43JRDq+yaUcE3P6VlmfQZWw/49GjwT+VbIuFmej3iLFn1y3YkzPLKYf+BVcXQixZGKNpKrA=
38+
${SSH_HOST} ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBJR4dlJQ4NmvJj63YZmxhcUOVkmTITCfCwrCiGRaNe4
39+
EOF
40+
echo "SSH_AUTH_SOCK=${SSH_AUTH_SOCK}" >> "${GITHUB_ENV}"
41+
42+
- name: Check out repository
43+
if: ${{ inputs.update_repo }}
44+
uses: actions/checkout@v6
45+
46+
- name: "Prepare"
47+
id: prepare
48+
shell: bash
49+
env:
50+
REF: ${{ inputs.ref }}
51+
run: |
52+
sudo apt-get update
53+
sudo apt-get install -y flatpak ostree
54+
# Download rsync wrapper to safely update ostree
55+
wget https://raw.githubusercontent.com/ostreedev/ostree-releng-scripts/621f7637ba6b8e0a8b761ce643c16a1511d04f6b/rsync-repos
56+
chmod +x rsync-repos
57+
58+
if [[ "$REF" =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
59+
echo "commit_summary=Stable build for 2.5" >> $GITHUB_OUTPUT
60+
echo "channel=stable" >> $GITHUB_OUTPUT
61+
elif [[ "$REF" == "refs/heads/2.6" ]]; then
62+
echo "commit_summary=Beta build for 2.6" >> $GITHUB_OUTPUT
63+
echo "channel=beta" >> $GITHUB_OUTPUT
64+
echo "expiry=30 days" >> $GITHUB_OUTPUT
65+
elif [[ "$REF" == "refs/heads/main" ]]; then
66+
echo "commit_summary=Alpha build for 2.7" >> $GITHUB_OUTPUT
67+
echo "channel=alpha" >> $GITHUB_OUTPUT
68+
echo "expiry=14 days" >> $GITHUB_OUTPUT
69+
fi
70+
71+
- name: "Download bundles"
72+
env:
73+
GH_TOKEN: ${{ github.token }}
74+
RUN_ID: ${{ inputs.run_id }}
75+
run: |
76+
gh --repo mixxxdj/mixxx run download $RUN_ID --pattern 'Flatpak *' -D bundles
77+
find bundles/ -name *.flatpak -exec mv {} bundles/ \;
78+
find bundles/ -mindepth 1 -type d -delete
79+
if [ ! `find bundles/ -name '*x86_64.flatpak | wc -l` -eq 1 ]; then
80+
echo "At least a x86_64 build is expected. Current bundles:"
81+
find bundles/ -type f
82+
exit 1
83+
fi
84+
version=$(find bundles/ -name '*x86_64.flatpak' | cut -d- -f 2- | rev | cut -d- -f 2- | rev)
85+
echo "VERSION=${version}" >> $GITHUB_ENV
86+
87+
- name: "[Ubuntu] Import PPA GPG key"
88+
run: gpg --import <(echo "${RRYAN_AT_MIXXX_DOT_ORG_GPG_PRIVATE_KEY}")
89+
env:
90+
RRYAN_AT_MIXXX_DOT_ORG_GPG_PRIVATE_KEY: ${{ secrets.RRYAN_AT_MIXXX_DOT_ORG_GPG_PRIVATE_KEY }}
91+
92+
- name: "Import bundle to repo"
93+
env:
94+
GPG_KEY_ID: rryan@mixxx.org
95+
COMMIT_SUMMARY: ${{ steps.prepare.outputs.commit_summary }}
96+
CHANNEL: ${{ steps.prepare.outputs.channel }}
97+
shell: bash
98+
run: |
99+
set -x
100+
101+
function import_to_repo {
102+
file=$1
103+
id=$2
104+
arch=$3
105+
type=$4
106+
107+
flatpak build-import-bundle -v --gpg-sign=$GPG_KEY_ID repo.tmp "$file"
108+
checksum=$(ostree --repo=repo.tmp rev-parse "${type}/${id}/${arch}/master")
109+
ostree --repo=repo pull --depth=-1 --mirror "upstream:${type}/${id}/${arch}/${CHANNEL}" || true
110+
ostree --repo=repo pull-local repo.tmp "${checksum}"
111+
ostree --repo=repo commit -b "${type}/${id}/${arch}/${CHANNEL}" -s "$COMMIT_SUMMARY" "--add-metadata-string=version=$VERSION" "--tree=ref=${checksum}"
112+
}
113+
114+
# Prepare local repos
115+
ostree --repo=repo.tmp init --mode=archive-z2
116+
ostree --repo=repo init --mode=archive-z2
117+
118+
# Hook publish repo to the remote
119+
ostree --repo=repo remote add --no-gpg-verify upstream https://downloads.mixxx.org/flatpak/
120+
121+
for arch in "x86_64" "aarch64"; do
122+
import_to_repo "bundles/Mixxx-${VERSION}-${arch}.flatpak" org.mixxx.Mixxx ${arch} app
123+
if [ -f "bundles/Mixxx-${VERSION}-${arch}.Debug.flatpak" ]; then
124+
import_to_repo "bundles/Mixxx-${VERSION}-${arch}.Debug.flatpak" org.mixxx.Mixxx.Debug ${arch} runtime
125+
else
126+
echo "No debug extension for ${arch}"
127+
fi
128+
done
129+
130+
- name: "Update the repo manifest"
131+
if: ${{ inputs.update_repo }}
132+
shell: bash
133+
run: |
134+
cp packaging/flatpak/repo.flatpakrepo repo/repo.flatpakrepo
135+
136+
- name: "Cleanup old builds"
137+
if: ${{ steps.prepare.outputs.expiry != null }}
138+
shell: bash
139+
env:
140+
EXPIRY: ${{ steps.prepare.outputs.expiry }}
141+
run: |
142+
ostree --repo=repo prune --refs-only --keep-younger-than="$EXPIRY ago"
143+
144+
- name: "Push the updated repo"
145+
env:
146+
SSH_HOST: downloads-hostgator.mixxx.org
147+
SSH_USER: mixxx
148+
shell: bash
149+
run: |
150+
ostree --repo=repo summary -u
151+
flatpak build-update-repo repo
152+
./rsync-repos --src "repo/" --dest "${SSH_USER}@${SSH_HOST}:public_html/downloads/flatpak" --rsync-opts "--verbose --recursive --checksum --times --delay-updates"
153+
154+
# TODO we could also publish a .flatpakref file to allow one-click install a version and publish this as a comment to the PR.

.github/workflows/release.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ on:
1111
- "[0-9].[0-9]-*"
1212
workflow_dispatch:
1313

14-
env:
15-
# This variable stores the map of Mixxx branches that still being developed. The key is the branch receiving support and the value is the next version in line
16-
# NOTE: this must be valid JSON!
17-
ACTIVE_VERSIONS: |-
18-
{"2.5": "2.6", "2.6": "main"}
19-
2014
# Global allowed scopes for all actions
2115
permissions:
2216
contents: write # to sync branches
@@ -48,6 +42,18 @@ jobs:
4842
NETLIFY_BUILD_HOOK: ${{ secrets.NETLIFY_BUILD_HOOK }}
4943
RRYAN_AT_MIXXX_DOT_ORG_GPG_PRIVATE_KEY: ${{ secrets.RRYAN_AT_MIXXX_DOT_ORG_GPG_PRIVATE_KEY }}
5044

45+
publish:
46+
needs:
47+
- build
48+
uses: ./.github/workflows/flatpak.yml
49+
with:
50+
ref: ${{ github.ref }}
51+
update_repo: ${{ github.ref_name == '2.5' }}
52+
run_id: ${{ github.run_id }}
53+
secrets:
54+
DOWNLOADS_HOSTGATOR_DOT_MIXXX_DOT_ORG_KEY: ${{ secrets.DOWNLOADS_HOSTGATOR_DOT_MIXXX_DOT_ORG_KEY }}
55+
RRYAN_AT_MIXXX_DOT_ORG_GPG_PRIVATE_KEY: ${{ secrets.RRYAN_AT_MIXXX_DOT_ORG_GPG_PRIVATE_KEY }}
56+
5157
sync:
5258
if: ${{ github.ref != 'refs/heads/main' && github.repository == 'mixxxdj/mixxx' }}
5359
uses: ./.github/workflows/sync_branches.yml

packaging/flatpak/repo.flatpakrepo

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[Flatpak Repo]
2+
Title=Mixxx
3+
Url=https://downloads.mixxx.org/flatpak/
4+
Homepage=https://mixxx.org/
5+
Comment=Flatpak repo for Mixxx releases and snapshots
6+
Description=Flatpak repo for Mixxx releases and snapshots
7+
Icon=https://mixxx.org/theme/images/mixxx-logo.svg

0 commit comments

Comments
 (0)