From cc9c9f940d97fbc99563d3f580efb23a4f9d580d Mon Sep 17 00:00:00 2001 From: SirBlobby Date: Wed, 22 Jul 2026 17:42:50 -0400 Subject: [PATCH] Add Arch PKGBUILD packaging, keep releases as manual GitHub uploads --- .gitea/workflows/build.yml | 73 +++++++++++++++------------- README.md | 20 +++----- packaging/arch/PKGBUILD | 55 +++++++++++++++++++++ packaging/arch/typst-desktop.desktop | 9 ++++ 4 files changed, 110 insertions(+), 47 deletions(-) create mode 100644 packaging/arch/PKGBUILD create mode 100644 packaging/arch/typst-desktop.desktop diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 475fbd1..f67b560 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -85,43 +85,48 @@ jobs: path: packages/* if-no-files-found: error - - name: Publish to Gitea release - if: startsWith(github.ref, 'refs/tags/v') - env: - TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITEA_URL: https://git.sirblob.co - REPOSITORY: sirblobby/typst-desktop - TAG: ${{ github.ref_name }} + build-arch: + runs-on: ubuntu-22.04 + container: + image: archlinux:base-devel + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + path: typst-desktop + + - name: Update pacman and install build dependencies run: | - set -euo pipefail + pacman -Syu --noconfirm + pacman -S --noconfirm --needed \ + git rust bun webkit2gtk-4.1 gtk3 openssl - api="$GITEA_URL/api/v1/repos/$REPOSITORY" - auth="Authorization: token $TOKEN" - json="Content-Type: application/json" + - name: Create unprivileged build user + run: | + useradd -m builder + chown -R builder:builder "$GITHUB_WORKSPACE" - existing=$(curl -sS -H "$auth" "$api/releases/tags/$TAG" | jq -r '.id // empty') + - name: Set package version from tag + if: startsWith(github.ref, 'refs/tags/v') + working-directory: typst-desktop/packaging/arch + run: sed -i "s/^pkgver=.*/pkgver=${TAG#v}/" PKGBUILD + env: + TAG: ${{ github.ref_name }} - if [ -n "$existing" ]; then - release_id=$existing - else - release_id=$(curl -sS -X POST -H "$auth" -H "$json" "$api/releases" \ - -d "$(jq -n --arg tag "$TAG" \ - '{tag_name: $tag, name: ("Typst Desktop " + $tag), body: "Download the package for your distribution below.", draft: true, prerelease: false}')" \ - | jq -r '.id') - fi + - name: Build package + working-directory: typst-desktop/packaging/arch + run: runuser -u builder -- env TYPST_COMMIT="$TYPST_COMMIT" makepkg --noconfirm - if [ -z "$release_id" ] || [ "$release_id" = "null" ]; then - echo "Could not create or find the release" - exit 1 - fi + - name: Collect package + run: | + mkdir -p packages + find typst-desktop/packaging/arch -maxdepth 1 -name "*.pkg.tar.zst" -exec cp {} packages/ \; + ls -la packages - for package in packages/*; do - name=$(basename "$package") - echo "Uploading $name" - curl -sS --fail -X POST -H "$auth" \ - -F "attachment=@$package" \ - "$api/releases/$release_id/assets?name=$name" \ - > /dev/null - done - - echo "Uploaded to the draft release for $TAG" + - name: Upload package + uses: actions/upload-artifact@v3 + with: + name: typst-desktop-arch-x86_64 + path: packages/* + if-no-files-found: error diff --git a/README.md b/README.md index eed1150..80500f5 100644 --- a/README.md +++ b/README.md @@ -44,24 +44,16 @@ Remove it with `sudo dnf remove typst-desktop`. ### Arch -There is no package in the AUR. Use the AppImage, which needs FUSE: - ```bash -sudo pacman -S fuse2 -wget "$BASE/typst-desktop_${VERSION}_amd64.AppImage" -chmod +x "typst-desktop_${VERSION}_amd64.AppImage" -./typst-desktop_${VERSION}_amd64.AppImage +wget "$BASE/typst-desktop-${VERSION}-1-x86_64.pkg.tar.zst" +sudo pacman -U "typst-desktop-${VERSION}-1-x86_64.pkg.tar.zst" ``` -To keep it on your `PATH`: +Remove it with `sudo pacman -R typst-desktop`. -```bash -sudo install -Dm755 "typst-desktop_${VERSION}_amd64.AppImage" /usr/local/bin/typst-desktop -``` +There is no AUR package; the `.pkg.tar.zst` above is attached to each release directly. Prefer it over the AppImage on Arch specifically — a [known WebKitGTK issue](https://bugs.webkit.org/show_bug.cgi?id=280239) on Wayland crashes the AppImage build (`Could not create default EGL display`) against Arch's current webkit2gtk version. The native package links against your system's webkit2gtk instead, which avoids it. -Remove it with `sudo rm /usr/local/bin/typst-desktop`. - -The AppImage runs on any distribution, so it also works as a fallback on Debian or Fedora. Building from source is covered under [Development](#development). +The AppImage runs on any distribution, so it also works as a fallback on Debian or Fedora — and on Arch too, but may hit the WebKitGTK/EGL crash described above there. Building from source is covered under [Development](#development). ## Features @@ -219,6 +211,8 @@ bun run build:linux Build on Ubuntu 22.04 (the CI baseline) rather than a rolling-release distro. glibc compatibility only works forward, so a binary is only guaranteed to run on distros with a glibc version equal to or newer than the one it was built against. This won't cover musl-based distros like Alpine, or glibc-based distros older than the build machine. +On Arch, `packaging/arch/PKGBUILD` builds and installs a native package via `makepkg -si` from within `packaging/arch/`, instead of `bun run build:linux`. + ## License Apache License 2.0. See [LICENSE](LICENSE). diff --git a/packaging/arch/PKGBUILD b/packaging/arch/PKGBUILD new file mode 100644 index 0000000..80f3dac --- /dev/null +++ b/packaging/arch/PKGBUILD @@ -0,0 +1,55 @@ +# Maintainer: SirBlobby +pkgname=typst-desktop +pkgver=1.0.0 +pkgrel=1 +pkgdesc="A desktop editor for Typst documents with a built-in compiler, live preview, and optional TypstDrive sync" +arch=('x86_64') +url="https://github.com/sirblobby/typst-desktop" +license=('Apache-2.0') +depends=('webkit2gtk-4.1' 'gtk3' 'openssl') +makedepends=('rust' 'git' 'bun' 'webkit2gtk-4.1' 'gtk3' 'openssl') +options=('!lto') +source=("$pkgname.desktop") +sha256sums=('SKIP') + +_typst_commit=${TYPST_COMMIT:-9dfd3a08500b7896045f907433cf7b4b02434fad} + +prepare() { + rm -rf "$srcdir/$pkgname-src" + git -C "$startdir/../.." archive --format=tar HEAD | \ + (mkdir -p "$srcdir/$pkgname-src" && tar -x -C "$srcdir/$pkgname-src") + + git clone https://github.com/typst/typst.git "$srcdir/$pkgname-src/typst" + git -C "$srcdir/$pkgname-src/typst" checkout "$_typst_commit" +} + +build() { + cd "$srcdir/$pkgname-src" + export CARGO_TARGET_DIR="$srcdir/target" + bun install --frozen-lockfile + bun run tauri build -- --no-bundle +} + +package() { + cd "$srcdir/$pkgname-src" + + install -Dm755 "$srcdir/target/release/typst-desktop" \ + "$pkgdir/usr/bin/typst-desktop" + + install -Dm644 "$srcdir/$pkgname.desktop" \ + "$pkgdir/usr/share/applications/$pkgname.desktop" + + install -Dm644 src-tauri/icons/32x32.png \ + "$pkgdir/usr/share/icons/hicolor/32x32/apps/$pkgname.png" + install -Dm644 src-tauri/icons/64x64.png \ + "$pkgdir/usr/share/icons/hicolor/64x64/apps/$pkgname.png" + install -Dm644 src-tauri/icons/128x128.png \ + "$pkgdir/usr/share/icons/hicolor/128x128/apps/$pkgname.png" + install -Dm644 "src-tauri/icons/128x128@2x.png" \ + "$pkgdir/usr/share/icons/hicolor/256x256/apps/$pkgname.png" + install -Dm644 src-tauri/icons/icon.png \ + "$pkgdir/usr/share/icons/hicolor/512x512/apps/$pkgname.png" + + install -Dm644 LICENSE \ + "$pkgdir/usr/share/licenses/$pkgname/LICENSE" +} diff --git a/packaging/arch/typst-desktop.desktop b/packaging/arch/typst-desktop.desktop new file mode 100644 index 0000000..ab72ada --- /dev/null +++ b/packaging/arch/typst-desktop.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Application +Name=Typst Desktop +Comment=A desktop editor for Typst documents with a built-in compiler, live preview, and optional TypstDrive sync +Exec=typst-desktop %U +Icon=typst-desktop +Terminal=false +Categories=Office;Utility;TextEditor; +StartupWMClass=typst-desktop