Files
aiostreams-packaging/.gitea/workflows/appimage.yml
T

120 lines
5.2 KiB
YAML

name: Desktop AppImage
on:
schedule:
- cron: '23 */6 * * *'
workflow_dispatch:
env:
MIRROR: pascalyazid/AIOStreams
PACKAGING: pascalyazid/aiostreams-packaging
UPSTREAM: Viren070/AIOStreams
OWNER: pascalyazid
jobs:
appimage:
runs-on: [cachyos]
container: archlinux:base-devel
steps:
- name: Install the toolchain
run: |
set -euo pipefail
pacman -Syu --noconfirm git curl jq nodejs pnpm rust meson ninja \
gtk4 webkitgtk-6.0 ffmpeg libass uchardet luajit lcms2 libjpeg-turbo \
mesa libva libvdpau libdrm libdisplay-info libx11 libxext libxrandr libxss \
libxpresent wayland wayland-protocols libxkbcommon alsa-lib libpulse \
pipewire dconf gdk-pixbuf2
- name: Sync the mirror and find the newest desktop release
run: |
set -euo pipefail
mirror="${{ gitea.server_url }}/${{ env.MIRROR }}.git"
latest() {
git ls-remote --tags "$mirror" 'refs/tags/desktop-v*' \
| sed 's|.*refs/tags/||; s/\^{}$//' \
| sort -uV | tail -n 1
}
prev=$(latest)
# force a sync so a just-published tag isn't missed
curl -fsSL -X POST -H "Authorization: token ${{ secrets.PUBLISH_TOKEN }}" \
"${{ gitea.server_url }}/api/v1/repos/${{ env.MIRROR }}/mirror-sync"
# wait briefly for the sync to land; if nothing new arrives, the
# current latest is still correct (the skip-check will bail)
tag=$prev
for i in $(seq 1 12); do
tag=$(latest)
if [ "$tag" != "$prev" ]; then break; fi
sleep 10
done
if [ -z "$tag" ] || [ "$tag" = "null" ]; then
echo "no desktop-v* tags on the mirror" >&2; exit 1
fi
echo "TAG=$tag" >> "$GITHUB_ENV"
echo "VERSION=${tag#desktop-v}" >> "$GITHUB_ENV"
- name: Skip if this release is already built
run: |
code=$(curl -s -o /dev/null -w '%{http_code}' \
-H "Authorization: token ${{ secrets.PUBLISH_TOKEN }}" \
"${{ gitea.server_url }}/api/v1/repos/${{ env.PACKAGING }}/releases/tags/appimage-${{ env.TAG }}")
if [ "$code" = 200 ]; then
echo "already built"; echo "SKIP=1" >> "$GITHUB_ENV"
fi
- name: Check out the mirror at the tag
if: env.SKIP != '1'
run: |
set -euo pipefail
git clone --depth 1 --branch "${{ env.TAG }}" \
"${{ gitea.server_url }}/${{ env.MIRROR }}.git" src
- name: Install the script and build the web app
if: env.SKIP != '1'
working-directory: src
run: |
set -euo pipefail
# the web bundle doesn't need the native addons; skipping their
# builds also avoids the lto-wrapper/pnpm '=' path breakage
mkdir -p packages/desktop/scripts
git clone "${{ gitea.server_url }}/${{ env.PACKAGING }}.git" /tmp/packaging
install -m755 /tmp/packaging/make-appimage.sh packages/desktop/scripts/
pnpm install --frozen-lockfile --ignore-scripts --filter "@aiostreams/web..."
pnpm -F @aiostreams/web build:standalone
- name: Build the AppImage
if: env.SKIP != '1'
working-directory: src
run: |
perl -0pi -e 's/^version = "[^"]*"/version = "$ENV{VERSION}"/m' packages/desktop/Cargo.toml
sh packages/desktop/scripts/make-appimage.sh
- name: Publish the AppImage as a Gitea release
if: env.SKIP != '1'
run: |
set -euo pipefail
auth="Authorization: token ${{ secrets.PUBLISH_TOKEN }}"
appimage="src/packages/desktop/appimage/io.github.viren070.aiostreams.AppImage"
release=$(curl -fsSL -H "$auth" -H 'Content-Type: application/json' \
-d "{\"tag_name\":\"appimage-${{ env.TAG }}\",\"name\":\"AppImage ${{ env.TAG }}\"}" \
"${{ gitea.server_url }}/api/v1/repos/${{ env.PACKAGING }}/releases")
id=$(echo "$release" | jq -r '.id')
curl -fsSL -H "$auth" -F "attachment=@$appimage" \
"${{ gitea.server_url }}/api/v1/repos/${{ env.PACKAGING }}/releases/$id/assets?name=aiostreams-desktop-linux-x64-${{ env.VERSION }}.AppImage"
- name: Publish the pacman package
if: env.SKIP != '1'
run: |
set -euo pipefail
useradd -m builder # makepkg refuses to run as root
mkdir pkg && cd pkg
git clone "${{ gitea.server_url }}/${{ env.PACKAGING }}.git" .
cp ../src/packages/desktop/appimage/io.github.viren070.aiostreams.AppImage \
aiostreams-desktop-linux-x64.AppImage
sed -i -e "s/^pkgver=.*/pkgver=${{ env.VERSION }}/" \
-e "s/^sha256sums=.*/sha256sums=('$(sha256sum aiostreams-desktop-linux-x64.AppImage | cut -d' ' -f1)')/" \
PKGBUILD
chown -R builder:builder .
su builder -c "cd '$PWD' && makepkg -f"
curl --user "${{ env.OWNER }}:${{ secrets.PUBLISH_TOKEN }}" \
--upload-file "aiostreams-desktop-bin-${{ env.VERSION }}-1-x86_64.pkg.tar.zst" \
"${{ gitea.server_url }}/api/packages/${{ env.OWNER }}/arch/aiostreams"