Files
typst-desktop/.gitea/workflows/build.yml
T

127 lines
3.6 KiB
YAML

name: Build Linux Packages
on:
push:
tags:
- "v*"
workflow_dispatch:
env:
TYPST_COMMIT: 9dfd3a08500b7896045f907433cf7b4b02434fad
APPIMAGE_EXTRACT_AND_RUN: 1
NO_STRIP: 1
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: typst-desktop
- name: Clone Typst compiler
run: |
git clone https://github.com/typst/typst.git typstdrive/typst
git -C typstdrive/typst checkout "$TYPST_COMMIT"
- name: Install build dependencies
run: |
apt-get update
apt-get install -y \
libwebkit2gtk-4.1-dev \
libgtk-3-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf \
libssl-dev \
pkg-config \
build-essential \
file \
curl \
wget \
jq
- name: Set up Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
typst-desktop/src-tauri/target
key: cargo-release-${{ hashFiles('typst-desktop/src-tauri/Cargo.lock') }}
restore-keys: cargo-release-
- name: Install frontend dependencies
working-directory: typst-desktop
run: bun install
- name: Build application
working-directory: typst-desktop
run: bun run tauri build
- name: Collect packages
run: |
mkdir -p packages
find typst-desktop/src-tauri/target/release/bundle \
-type f \( -name "*.deb" -o -name "*.rpm" -o -name "*.AppImage" \) \
-exec cp {} packages/ \;
ls -la packages
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: typst-desktop-linux-x86_64
path: packages/*
if-no-files-found: error
- name: Publish to GitHub release
if: startsWith(github.ref, 'refs/tags/v')
env:
TOKEN: ${{ secrets.RELEASE_TOKEN }}
REPOSITORY: sirblobby/typst-desktop
TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
api="https://api.github.com/repos/$REPOSITORY"
auth="Authorization: Bearer $TOKEN"
json="Content-Type: application/json"
existing=$(curl -sS -H "$auth" "$api/releases/tags/$TAG" | jq -r '.id // empty')
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
if [ -z "$release_id" ] || [ "$release_id" = "null" ]; then
echo "Could not create or find the release"
exit 1
fi
for package in packages/*; do
name=$(basename "$package")
echo "Uploading $name"
curl -sS --fail -X POST -H "$auth" \
-H "Content-Type: application/octet-stream" \
--data-binary "@$package" \
"https://uploads.github.com/repos/$REPOSITORY/releases/$release_id/assets?name=$name" \
> /dev/null
done
echo "Uploaded to the draft release for $TAG"