Files

127 lines
5.3 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: Find the newest desktop release
run: |
set -euo pipefail
tag=$(git ls-remote --tags "https://github.com/${{ env.UPSTREAM }}.git" 'refs/tags/desktop-v*' \
| sed 's|.*refs/tags/||; s/\^{}$//' \
| sort -uV | tail -n 1)
if [ -z "$tag" ] || [ "$tag" = "null" ]; then
echo "no desktop-v* tag on ${{ env.UPSTREAM }}" >&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: Sync the mirror and wait for the tag
if: env.SKIP != '1'
run: |
set -euo pipefail
curl -fsSL -X POST -H "Authorization: token ${{ secrets.PUBLISH_TOKEN }}" \
"${{ gitea.server_url }}/api/v1/repos/${{ env.MIRROR }}/mirror-sync"
for i in $(seq 1 24); do
if git ls-remote --tags "${{ gitea.server_url }}/${{ env.MIRROR }}.git" \
"refs/tags/${{ env.TAG }}" | grep -q .; then
echo "the mirror has ${{ env.TAG }}"
exit 0
fi
sleep 5
done
echo "the mirror never received ${{ env.TAG }}" >&2
exit 1
- 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
id builder >/dev/null 2>&1 || useradd -m builder
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"
# the filename is whatever pkgver-pkgrel the PKGBUILD declares;
# [0-9] keeps the -debug package out of the match
pkgfile=$(ls aiostreams-desktop-bin-[0-9]*.pkg.tar.zst)
curl --user "${{ env.OWNER }}:${{ secrets.PUBLISH_TOKEN }}" \
--upload-file "$pkgfile" \
"${{ gitea.server_url }}/api/packages/${{ env.OWNER }}/arch/aiostreams"