|
| 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 | + ssh-keyscan "${SSH_HOST}" >> "${HOME}/.ssh/known_hosts" |
| 36 | + echo "SSH_AUTH_SOCK=${SSH_AUTH_SOCK}" >> "${GITHUB_ENV}" |
| 37 | +
|
| 38 | + - name: Check out repository |
| 39 | + if: ${{ inputs.update_repo }} |
| 40 | + uses: actions/checkout@v6 |
| 41 | + |
| 42 | + - name: "Prepare" |
| 43 | + id: prepare |
| 44 | + shell: bash |
| 45 | + env: |
| 46 | + REF: ${{ inputs.ref }} |
| 47 | + run: | |
| 48 | + sudo apt-get update |
| 49 | + sudo apt-get install -y flatpak ostree |
| 50 | + # Download rsync wrapper to safely update ostree |
| 51 | + wget https://raw.githubusercontent.com/ostreedev/ostree-releng-scripts/621f7637ba6b8e0a8b761ce643c16a1511d04f6b/rsync-repos |
| 52 | + chmod +x rsync-repos |
| 53 | +
|
| 54 | + if [[ "$REF" =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 55 | + echo "commit_summary=Stable build for 2.5" >> $GITHUB_OUTPUT |
| 56 | + echo "branch=stable" >> $GITHUB_OUTPUT |
| 57 | + elif [ "$REF" = "refs/heads/2.6" ]; then |
| 58 | + echo "commit_summary=Beta build for 2.6" >> $GITHUB_OUTPUT |
| 59 | + echo "branch=beta" >> $GITHUB_OUTPUT |
| 60 | + echo "expiry=30 days" >> $GITHUB_OUTPUT |
| 61 | + elif [ "$REF" = "refs/heads/main" ]; then |
| 62 | + echo "commit_summary=Nightly build for 2.7" >> $GITHUB_OUTPUT |
| 63 | + echo "branch=nightly" >> $GITHUB_OUTPUT |
| 64 | + echo "expiry=14 days" >> $GITHUB_OUTPUT |
| 65 | + else |
| 66 | + echo "::error:: The git reference is unsupported for publication to the Flatpak repo." |
| 67 | + exit 1 |
| 68 | + fi |
| 69 | +
|
| 70 | + - name: "Download bundles" |
| 71 | + env: |
| 72 | + GH_TOKEN: ${{ github.token }} |
| 73 | + RUN_ID: ${{ inputs.run_id }} |
| 74 | + shell: bash |
| 75 | + run: | |
| 76 | + mkdir -p bundles |
| 77 | + # Work around https://github.com/cli/cli/issues/13012 |
| 78 | + gh api \ |
| 79 | + -H "Accept: application/vnd.github+json" \ |
| 80 | + -H "X-GitHub-Api-Version: 2026-03-10" \ |
| 81 | + "/repos/mixxxdj/mixxx/actions/runs/$RUN_ID/artifacts" | jq -r '.artifacts[] | select(.name | test("\\.flatpak$")) | [.name, .archive_download_url] | @tsv' | |
| 82 | + while IFS=$'\t' read -r name url; do |
| 83 | + url=$(echo "$url" | cut -d/ -f 4-) |
| 84 | + echo "Downloading artifact $name from $url" |
| 85 | + gh api \ |
| 86 | + -H "Accept: application/vnd.github+json" \ |
| 87 | + -H "X-GitHub-Api-Version: 2026-03-10" \ |
| 88 | + "$url" > "bundles/$name" |
| 89 | + done |
| 90 | + if [ ! `find bundles/ -name '*x86_64.flatpak' | wc -l` -eq 1 ]; then |
| 91 | + echo "At least a x86_64 build is expected. Current bundles:" |
| 92 | + find bundles/ -type f |
| 93 | + exit 1 |
| 94 | + fi |
| 95 | + version=$(find bundles/ -name '*x86_64.flatpak' | cut -d- -f 2- | rev | cut -d- -f 2- | rev) |
| 96 | + echo "VERSION=${version}" >> $GITHUB_ENV |
| 97 | +
|
| 98 | + - name: "[Ubuntu] Import PPA GPG key" |
| 99 | + run: gpg --import <(echo "${RRYAN_AT_MIXXX_DOT_ORG_GPG_PRIVATE_KEY}") |
| 100 | + env: |
| 101 | + RRYAN_AT_MIXXX_DOT_ORG_GPG_PRIVATE_KEY: ${{ secrets.RRYAN_AT_MIXXX_DOT_ORG_GPG_PRIVATE_KEY }} |
| 102 | + |
| 103 | + - name: "Import bundle to repo" |
| 104 | + env: |
| 105 | + GPG_KEY_ID: rryan@mixxx.org |
| 106 | + COMMIT_SUMMARY: ${{ steps.prepare.outputs.commit_summary }} |
| 107 | + BRANCH: ${{ steps.prepare.outputs.branch }} |
| 108 | + shell: bash |
| 109 | + run: | |
| 110 | + set -x |
| 111 | +
|
| 112 | + function import_to_repo { |
| 113 | + file=$1 |
| 114 | + id=$2 |
| 115 | + arch=$3 |
| 116 | + type=$4 |
| 117 | +
|
| 118 | + flatpak build-import-bundle -v --gpg-sign=$GPG_KEY_ID repo.tmp "$file" |
| 119 | + checksum=$(ostree --repo=repo.tmp rev-parse "${type}/${id}/${arch}/master") |
| 120 | + metadata=$(ostree --repo=repo.tmp show --print-metadata-key=xa.metadata "${type}/${id}/${arch}/master") |
| 121 | + ostree --repo=repo pull --depth=-1 --mirror "upstream:${type}/${id}/${arch}/${BRANCH}" || true |
| 122 | + ostree --repo=repo pull-local repo.tmp "${checksum}" |
| 123 | + ostree --repo=repo commit \ |
| 124 | + --gpg-sign=$GPG_KEY_ID \ |
| 125 | + -b "${type}/${id}/${arch}/${BRANCH}" \ |
| 126 | + -s "$COMMIT_SUMMARY" \ |
| 127 | + "--add-metadata-string=version=$VERSION" \ |
| 128 | + "--add-metadata-string=xa.metadata=$(printf "%b" "${metadata:1:-1}")" \ |
| 129 | + "--tree=ref=${checksum}" |
| 130 | + ostree --repo=repo show --print-metadata-key=xa.metadata "${type}/${id}/${arch}/${BRANCH}" |
| 131 | + } |
| 132 | +
|
| 133 | + # Prepare local repos |
| 134 | + ostree --repo=repo.tmp init --mode=archive-z2 |
| 135 | + ostree --repo=repo init --mode=archive-z2 |
| 136 | +
|
| 137 | + # Hook publish repo to the remote |
| 138 | + ostree --repo=repo remote add upstream https://downloads.mixxx.org/flatpak/ |
| 139 | +
|
| 140 | + for arch in "x86_64" "aarch64"; do |
| 141 | + import_to_repo "bundles/Mixxx-${VERSION}-${arch}.flatpak" org.mixxx.Mixxx ${arch} app |
| 142 | + if [ -f "bundles/Mixxx-${VERSION}-${arch}.Debug.flatpak" ]; then |
| 143 | + import_to_repo "bundles/Mixxx-${VERSION}-${arch}.Debug.flatpak" org.mixxx.Mixxx.Debug ${arch} runtime |
| 144 | + else |
| 145 | + echo "No debug extension for ${arch}" |
| 146 | + fi |
| 147 | + done |
| 148 | +
|
| 149 | + - name: "Cleanup old builds" |
| 150 | + if: ${{ steps.prepare.outputs.expiry != null }} |
| 151 | + shell: bash |
| 152 | + env: |
| 153 | + EXPIRY: ${{ steps.prepare.outputs.expiry }} |
| 154 | + run: | |
| 155 | + ostree --repo=repo prune --refs-only --keep-younger-than="$EXPIRY ago" |
| 156 | + - name: "Push the updated repo" |
| 157 | + env: |
| 158 | + SSH_HOST: downloads-hostgator.mixxx.org |
| 159 | + SSH_USER: mixxx |
| 160 | + GPG_KEY_ID: rryan@mixxx.org |
| 161 | + shell: bash |
| 162 | + run: | |
| 163 | + ostree --repo=repo summary -u --gpg-sign=$GPG_KEY_ID |
| 164 | + flatpak build-update-repo --gpg-sign=$GPG_KEY_ID repo |
| 165 | + ./rsync-repos --src "repo/" --dest "${SSH_USER}@${SSH_HOST}:public_html/downloads/flatpak" --rsync-opts "--verbose --recursive --checksum --times --delay-updates" |
| 166 | +
|
| 167 | + - name: "Update the repo manifest" |
| 168 | + if: ${{ inputs.update_repo }} |
| 169 | + env: |
| 170 | + SSH_HOST: downloads-hostgator.mixxx.org |
| 171 | + SSH_USER: mixxx |
| 172 | + shell: bash |
| 173 | + run: | |
| 174 | + rsync --verbose "packaging/flatpak/repo.flatpakrepo" "${SSH_USER}@${SSH_HOST}:public_html/downloads/flatpak/repo.flatpakrepo" |
| 175 | +
|
| 176 | + # TODO we could also publish a .flatpakref file to allow one-click install a version and publish this as a comment to the PR. |
0 commit comments