CI/Flatpak: Use flatpak-github-actions

This commit is contained in:
Stenzek 2024-03-01 01:01:22 +10:00 committed by Connor McLaughlin
parent 96f29d9b99
commit a5de489d6f
2 changed files with 20 additions and 75 deletions

View File

@ -282,40 +282,52 @@ jobs:
linux-flatpak-build:
runs-on: ubuntu-22.04
container:
image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.6
options: --privileged
timeout-minutes: 120
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
set-safe-directory: ${{ env.GITHUB_WORKSPACE }}
- name: Install packages
# Work around container ownership issue
- name: Set Safe Directory
shell: bash
run: scripts/flatpak/install-packages.sh
run: git config --global --add safe.directory "*"
- name: Generate AppStream XML
run: |
scripts/generate-metainfo.sh scripts/flatpak
cat scripts/flatpak/org.duckstation.DuckStation.metainfo.xml
flatpak run org.freedesktop.appstream-glib validate scripts/flatpak/org.duckstation.DuckStation.metainfo.xml
- name: Validate AppStream XML
run: flatpak-builder-lint appstream scripts/flatpak/org.duckstation.DuckStation.metainfo.xml
- name: Validate manifest
run: flatpak-builder-lint manifest scripts/flatpak/org.duckstation.DuckStation.json
- name: Build Flatpak
uses: flatpak/flatpak-github-actions/flatpak-builder@v6.3
uses: flathub-infra/flatpak-github-actions/flatpak-builder@23796715b3dfa4c86ddf50cf29c3cc8b3c82dca8
with:
bundle: duckstation-x64.flatpak
upload-artifact: false
manifest-path: scripts/flatpak/org.duckstation.DuckStation.json
arch: x86_64
build-bundle: true
verbose: true
#mirror-screenshots-url: https://dl.flathub.org/repo/screenshots
#mirror-screenshots-url: https://dl.flathub.org/media
#branch: ${{ inputs.branch }}
branch: master
cache: true
restore-cache: true
cache-key: flatpak-x64-${{ hashFiles('.scripts/flatpak/**/*.json') }}
# - name: Commit screenshots to OSTree
# run: |
# ostree commit --repo=repo --canonical-permissions --branch=screenshots/x86_64 flatpak_app/screenshots
# fails due to screenshots..
#- name: Validate build
# run: |
# flatpak-builder-lint repo repo
- name: Upload Flatpak
uses: actions/upload-artifact@v1

View File

@ -1,67 +0,0 @@
#!/bin/bash
set -e
SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}")
function retry_command {
# Package servers tend to be unreliable at times..
# Retry a bunch of times.
local RETRIES=10
for i in $(seq 1 "$RETRIES"); do
"$@" && break
if [ "$i" == "$RETRIES" ]; then
echo "Command \"$@\" failed after ${RETRIES} retries."
exit 1
fi
done
}
ARCH=x86_64
KDE_BRANCH=6.6
BRANCH=23.08
FLAT_MANAGER_CLIENT_DIR="$HOME/.local/bin"
# Build packages. Mostly needed for flat-manager-client.
declare -a BUILD_PACKAGES=(
"flatpak"
"flatpak-builder"
"appstream-util"
"python3-aiohttp"
"python3-tenacity"
"python3-gi"
"gobject-introspection"
"libappstream-glib8"
"libappstream-glib-dev"
"libappstream-dev"
"gir1.2-ostree-1.0"
)
# Flatpak runtimes and SDKs.
declare -a FLATPAK_PACKAGES=(
"org.kde.Platform/${ARCH}/${KDE_BRANCH}"
"org.kde.Sdk/${ARCH}/${KDE_BRANCH}"
"org.freedesktop.Sdk.Extension.llvm17/${ARCH}/${BRANCH}"
"org.freedesktop.appstream-glib/${ARCH}/stable"
)
retry_command sudo apt-get -qq update
# Install packages needed for building
echo "Will install the following packages for building - ${BUILD_PACKAGES[*]}"
retry_command sudo apt-get -y install "${BUILD_PACKAGES[@]}"
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
# Install packages needed for building
echo "Will install the following packages for building - ${FLATPAK_PACKAGES[*]}"
retry_command sudo flatpak -y install "${FLATPAK_PACKAGES[@]}"
echo "Downloading flat-manager-client"
mkdir -p "$FLAT_MANAGER_CLIENT_DIR"
pushd "$FLAT_MANAGER_CLIENT_DIR"
aria2c -Z "https://raw.githubusercontent.com/flatpak/flat-manager/9401efbdc0d6bd489507d8401c567ba219d735d5/flat-manager-client"
chmod +x flat-manager-client
echo "$FLAT_MANAGER_CLIENT_DIR" >> $GITHUB_PATH
popd