Publish releases to GitHub from Gitea
This commit is contained in:
@@ -40,7 +40,8 @@ jobs:
|
|||||||
build-essential \
|
build-essential \
|
||||||
file \
|
file \
|
||||||
curl \
|
curl \
|
||||||
wget
|
wget \
|
||||||
|
jq
|
||||||
|
|
||||||
- name: Set up Bun
|
- name: Set up Bun
|
||||||
uses: oven-sh/setup-bun@v2
|
uses: oven-sh/setup-bun@v2
|
||||||
@@ -82,3 +83,44 @@ jobs:
|
|||||||
name: typst-desktop-linux-x86_64
|
name: typst-desktop-linux-x86_64
|
||||||
path: packages/*
|
path: packages/*
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
|
- name: Publish to GitHub release
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.GITHUB_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"
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
name: CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
env:
|
|
||||||
TYPST_COMMIT: 44b3f78ed37fedea75e911dde2269ef86c45316f
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
frontend:
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Bun
|
|
||||||
uses: oven-sh/setup-bun@v2
|
|
||||||
with:
|
|
||||||
bun-version: latest
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: bun install
|
|
||||||
|
|
||||||
- name: Type check
|
|
||||||
run: bun run check
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: bun run build
|
|
||||||
|
|
||||||
backend:
|
|
||||||
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 Linux dependencies
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev libssl-dev
|
|
||||||
|
|
||||||
- name: Set up Rust
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
|
|
||||||
- name: Cache cargo
|
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
workspaces: typst-desktop/src-tauri
|
|
||||||
|
|
||||||
- name: Check
|
|
||||||
working-directory: typst-desktop/src-tauri
|
|
||||||
run: cargo check
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
name: Build and Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- "v*"
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
version:
|
|
||||||
description: "Release tag to publish, for example v1.0.0"
|
|
||||||
required: false
|
|
||||||
|
|
||||||
env:
|
|
||||||
TYPST_COMMIT: 44b3f78ed37fedea75e911dde2269ef86c45316f
|
|
||||||
APPIMAGE_EXTRACT_AND_RUN: 1
|
|
||||||
NO_STRIP: 1
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- platform: ubuntu-22.04
|
|
||||||
target: ""
|
|
||||||
label: linux-x86_64
|
|
||||||
- platform: windows-latest
|
|
||||||
target: ""
|
|
||||||
label: windows-x86_64
|
|
||||||
- platform: macos-latest
|
|
||||||
target: aarch64-apple-darwin
|
|
||||||
label: macos-aarch64
|
|
||||||
- platform: macos-latest
|
|
||||||
target: x86_64-apple-darwin
|
|
||||||
label: macos-x86_64
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.platform }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
path: typst-desktop
|
|
||||||
|
|
||||||
- name: Clone Typst compiler
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
git clone https://github.com/typst/typst.git typstdrive/typst
|
|
||||||
git -C typstdrive/typst checkout "$TYPST_COMMIT"
|
|
||||||
|
|
||||||
- name: Set up Bun
|
|
||||||
uses: oven-sh/setup-bun@v2
|
|
||||||
with:
|
|
||||||
bun-version: latest
|
|
||||||
|
|
||||||
- name: Set up Rust
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
with:
|
|
||||||
targets: ${{ matrix.target }}
|
|
||||||
|
|
||||||
- name: Cache cargo
|
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
workspaces: typst-desktop/src-tauri
|
|
||||||
key: ${{ matrix.label }}
|
|
||||||
|
|
||||||
- name: Install Linux dependencies
|
|
||||||
if: matrix.platform == 'ubuntu-22.04'
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y \
|
|
||||||
libwebkit2gtk-4.1-dev \
|
|
||||||
libappindicator3-dev \
|
|
||||||
librsvg2-dev \
|
|
||||||
patchelf \
|
|
||||||
libgtk-3-dev \
|
|
||||||
build-essential \
|
|
||||||
curl \
|
|
||||||
wget \
|
|
||||||
file \
|
|
||||||
libssl-dev
|
|
||||||
|
|
||||||
- name: Install frontend dependencies
|
|
||||||
working-directory: typst-desktop
|
|
||||||
run: bun install
|
|
||||||
|
|
||||||
- name: Build application
|
|
||||||
uses: tauri-apps/tauri-action@v0
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
projectPath: typst-desktop
|
|
||||||
tagName: ${{ github.ref_type == 'tag' && github.ref_name || inputs.version }}
|
|
||||||
releaseName: Typst Desktop ${{ github.ref_type == 'tag' && github.ref_name || inputs.version }}
|
|
||||||
releaseBody: "Download the installer for your platform below."
|
|
||||||
releaseDraft: true
|
|
||||||
prerelease: false
|
|
||||||
args: ${{ matrix.target && format('--target {0}', matrix.target) || '' }}
|
|
||||||
|
|
||||||
- name: Upload build artifacts
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: typst-desktop-${{ matrix.label }}
|
|
||||||
path: |
|
|
||||||
typst-desktop/src-tauri/target/release/bundle/**/*.deb
|
|
||||||
typst-desktop/src-tauri/target/release/bundle/**/*.rpm
|
|
||||||
typst-desktop/src-tauri/target/release/bundle/**/*.AppImage
|
|
||||||
typst-desktop/src-tauri/target/release/bundle/**/*.dmg
|
|
||||||
typst-desktop/src-tauri/target/release/bundle/**/*.msi
|
|
||||||
typst-desktop/src-tauri/target/release/bundle/**/*.exe
|
|
||||||
typst-desktop/src-tauri/target/*/release/bundle/**/*.dmg
|
|
||||||
if-no-files-found: ignore
|
|
||||||
@@ -140,21 +140,24 @@ bun run tauri build
|
|||||||
|
|
||||||
## Distribution
|
## Distribution
|
||||||
|
|
||||||
Workflows live in `.github/workflows` for GitHub Actions and `.gitea/workflows` for Gitea Actions.
|
Workflows live in `.gitea/workflows` and run on Gitea Actions.
|
||||||
|
|
||||||
| Workflow | Where | Trigger | Output |
|
| Workflow | Trigger | Output |
|
||||||
|---|---|---|---|
|
|---|---|---|
|
||||||
| `ci.yml` | both | push, pull requests | Type check, frontend build, backend check. |
|
| `ci.yml` | push, pull requests | Type check, frontend build, backend check. |
|
||||||
| `release.yml` | GitHub | `v*` tags, manual | A draft release with installers for every platform. |
|
| `build.yml` | `v*` tags, manual | Linux packages as workflow artifacts, and on a tag, a draft GitHub release. |
|
||||||
| `build.yml` | Gitea | `v*` tags, manual | Linux packages as workflow artifacts. |
|
|
||||||
|
|
||||||
| Platform | Artifacts |
|
| Platform | Artifacts |
|
||||||
|---|---|
|
|---|---|
|
||||||
| Linux | `.deb`, `.rpm`, `.AppImage` |
|
| Linux | `.deb`, `.rpm`, `.AppImage` |
|
||||||
| Windows | `.msi`, `-setup.exe` (NSIS) |
|
|
||||||
| macOS | `.dmg` for Apple Silicon and Intel, built separately |
|
|
||||||
|
|
||||||
Windows and macOS installers come from GitHub Actions because those runners are not available on a self-hosted Gitea instance. The Gitea workflows cover checks and Linux packages.
|
Builds run on a Linux runner, so Linux packages are the only artifacts produced. Windows and macOS installers have to be built on their own platforms and attached to the release by hand.
|
||||||
|
|
||||||
|
Publishing to GitHub needs one repository secret:
|
||||||
|
|
||||||
|
| Secret | Value |
|
||||||
|
|---|---|
|
||||||
|
| `GITHUB_RELEASE_TOKEN` | A classic GitHub personal access token with the `repo` scope. |
|
||||||
|
|
||||||
To cut a release:
|
To cut a release:
|
||||||
|
|
||||||
@@ -163,11 +166,11 @@ git tag v1.0.0
|
|||||||
git push origin v1.0.0
|
git push origin v1.0.0
|
||||||
```
|
```
|
||||||
|
|
||||||
The workflow drafts the release so you can review the artifacts before publishing.
|
The release is drafted rather than published, so you can add other platforms and review the artifacts before making it public.
|
||||||
|
|
||||||
### Platform notes
|
### Platform notes
|
||||||
|
|
||||||
Each runner builds natively, so no cross-compilation is involved. `.msi` packages can only be built on Windows because the WiX Toolset is Windows-only, which is why the Windows job runs on a Windows runner rather than cross-compiling with `cargo-xwin`.
|
`.msi` packages can only be built on Windows, because the WiX Toolset is Windows-only. Building on the target platform is the supported path for both Windows and macOS.
|
||||||
|
|
||||||
The Windows installers download the WebView2 bootstrapper when the runtime is missing. Windows 10 (April 2018 or later) and Windows 11 already ship it, so this only affects older systems. The NSIS installer asks whether to install for the current user or the whole machine.
|
The Windows installers download the WebView2 bootstrapper when the runtime is missing. Windows 10 (April 2018 or later) and Windows 11 already ship it, so this only affects older systems. The NSIS installer asks whether to install for the current user or the whole machine.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user