Add .gitea/workflows/appimage.yml
This commit is contained in:
1 parent
42052916f2
commit
463a9069b7
1 file changed
+111
@@ -0,0 +1,111 @@
|
||||
name: Desktop AppImage
|
||||
on:
|
||||
schedule:
|
||||
- cron: '23 */6 * * *' # every 6 hours, off the hour
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
MIRROR: pascal/AIOStreams # the pull mirror
|
||||
PACKAGING: pascal/aiostreams-packaging # this repo
|
||||
UPSTREAM: Viren070/AIOStreams
|
||||
OWNER: pascal # registry owner
|
||||
|
||||
jobs:
|
||||
appimage:
|
||||
runs-on: [self-hosted, cachyos] # match YOUR runner's label
|
||||
container: archlinux:base-devel # remove if your runner executes on the host
|
||||
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=$(curl -fsSL "https://api.github.com/repos/${{ env.UPSTREAM }}/tags?per_page=100" \
|
||||
| jq -r '[.[].name | select(startswith("desktop-v"))][0]')
|
||||
if [ -z "$tag" ]; then echo "no desktop tag found" >&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: Catch the mirror up 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 60); do
|
||||
if git ls-remote "${{ gitea.server_url }}/${{ env.MIRROR }}.git" \
|
||||
"refs/tags/${{ env.TAG }}" | grep -q .; then exit 0; fi
|
||||
sleep 10
|
||||
done
|
||||
echo "the mirror never received ${{ env.TAG }}" >&2; exit 1
|
||||
# private instance? use https://oauth2:${{ secrets.PUBLISH_TOKEN }}@<host>/... above
|
||||
|
||||
- name: Check out the mirror at the tag
|
||||
if: env.SKIP != '1'
|
||||
run: |
|
||||
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
|
||||
# carry make-appimage.sh until it lands upstream
|
||||
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 --filter "@aiostreams/web..."
|
||||
pnpm -F @aiostreams/web build:standalone
|
||||
|
||||
- name: Build the AppImage
|
||||
if: env.SKIP != '1'
|
||||
working-directory: src
|
||||
run: 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"
|
||||
Reference in new issue
Block a user