mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
265 lines
11 KiB
YAML
265 lines
11 KiB
YAML
name: Build desktop apps
|
|
|
|
# Compiles the Konduktor desktop app (Tauri + frozen Python sidecar) for macOS
|
|
# and Windows on every push to main, then publishes both installers as a new
|
|
# GitHub Release under an auto-incrementing tag. Also runnable on demand.
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
# A newer push to main supersedes an in-flight build.
|
|
concurrency:
|
|
group: build-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
# macOS runner is Apple Silicon (arm64). For an Intel build too, add a
|
|
# macos-13 entry with triple x86_64-apple-darwin.
|
|
- os: macos-latest
|
|
triple: aarch64-apple-darwin
|
|
- os: windows-latest
|
|
triple: x86_64-pc-windows-msvc
|
|
runs-on: ${{ matrix.os }}
|
|
name: ${{ matrix.os }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Rust (stable + ${{ matrix.triple }})
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.triple }}
|
|
|
|
# Cache the Rust build of the Tauri app between runs.
|
|
- name: Cache Rust
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
workspaces: frontend/src-tauri
|
|
|
|
- name: Set up Node 20
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: frontend/package-lock.json
|
|
|
|
- name: Set up Python 3.12
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
# --- Step 1: freeze the FastAPI backend into a onedir sidecar folder ---
|
|
# build_sidecar.* stages it as
|
|
# frontend/src-tauri/binaries/konduktor-sidecar/
|
|
# which tauri.macos.conf.json (bundle.macOS.files, keeps its symlinks) /
|
|
# tauri.windows.conf.json (bundle.resources) put in the app as `sidecar/`.
|
|
- name: Install backend deps
|
|
working-directory: backend
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt -r requirements-build.txt
|
|
|
|
- name: Build backend sidecar (macOS)
|
|
if: runner.os == 'macOS'
|
|
working-directory: backend
|
|
env:
|
|
PY: python # build_sidecar.sh defaults to .venv/bin/python
|
|
run: |
|
|
chmod +x build_sidecar.sh
|
|
./build_sidecar.sh
|
|
|
|
- name: Build backend sidecar (Windows)
|
|
if: runner.os == 'Windows'
|
|
working-directory: backend
|
|
shell: pwsh
|
|
run: .\build_sidecar.ps1 # falls back to `python` when no .venv
|
|
|
|
# --- Step 2: build the Tauri app (its beforeBuildCommand runs the Vite build) ---
|
|
- name: Install frontend deps
|
|
working-directory: frontend
|
|
run: npm ci
|
|
|
|
# createUpdaterArtifacts also signs the in-app update packages
|
|
# (Konduktor.app.tar.gz / the NSIS setup.exe) with the updater key, whose
|
|
# public half is plugins.updater.pubkey in tauri.conf.json. Losing the
|
|
# private key means installed copies can never update themselves again.
|
|
- name: Build Tauri app
|
|
working-directory: frontend
|
|
env:
|
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
|
run: npx tauri build
|
|
|
|
# Stage the single installer per OS into a flat folder. Uploading one
|
|
# directory (not multiple bundle subpaths) keeps the artifact root at
|
|
# ./installer, so the zip holds the bare file — no nested dmg/ or nsis/
|
|
# folder. We ship the DMG on macOS and the NSIS -setup.exe on Windows
|
|
# (the .msi is intentionally left out), plus what the in-app updater
|
|
# installs: the .app.tar.gz on macOS (the setup.exe on Windows) and the
|
|
# .sig files the release job folds into latest.json.
|
|
- name: Stage installer (macOS)
|
|
if: runner.os == 'macOS'
|
|
run: |
|
|
mkdir -p installer
|
|
cp frontend/src-tauri/target/release/bundle/dmg/*.dmg installer/
|
|
cp frontend/src-tauri/target/release/bundle/macos/*.app.tar.gz installer/
|
|
cp frontend/src-tauri/target/release/bundle/macos/*.app.tar.gz.sig installer/
|
|
|
|
- name: Stage installer (Windows)
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: |
|
|
New-Item -ItemType Directory -Force installer | Out-Null
|
|
Copy-Item frontend/src-tauri/target/release/bundle/nsis/*-setup.exe installer/
|
|
Copy-Item frontend/src-tauri/target/release/bundle/nsis/*-setup.exe.sig installer/
|
|
|
|
- name: Upload installer
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: konduktor-${{ runner.os }}
|
|
if-no-files-found: error
|
|
path: installer/*
|
|
|
|
# The Konduktor SERVER image (server/Dockerfile): a remote library's half,
|
|
# pushed to GHCR with the same version as the desktop app, so a TrueNAS app
|
|
# can name the tag that matches the app it is opened from.
|
|
server-image:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write # push to ghcr.io
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Resolve version and image name
|
|
id: meta
|
|
run: |
|
|
echo "version=$(jq -r .version frontend/package.json)" >> "$GITHUB_OUTPUT"
|
|
# GHCR names must be lower-case; the owner may not be.
|
|
echo "image=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/konduktor-server" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
env:
|
|
DOCKER_BUILD_RECORD_UPLOAD: false # no .dockerbuild artifact in the run
|
|
with:
|
|
context: .
|
|
file: server/Dockerfile
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: |
|
|
${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.version }}-b${{ github.run_number }}
|
|
${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.version }}
|
|
${{ steps.meta.outputs.image }}:latest
|
|
labels: |
|
|
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
|
org.opencontainers.image.version=${{ steps.meta.outputs.version }}
|
|
|
|
# Gather both platforms' installers and publish them as a single new Release.
|
|
# Runs once, after both builds succeed, so the two matrix jobs never race to
|
|
# create the same tag/release.
|
|
release:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write # required to create the tag + release
|
|
pull-requests: read # to read the merged PR's patch notes
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
# App version from the single source of truth, frontend/package.json (the
|
|
# same value Tauri names the installers from). The run number is appended
|
|
# as a -b<N> suffix to keep each push's tag/release unique → e.g. v0.1.1-b42.
|
|
- name: Resolve version
|
|
id: version
|
|
run: echo "version=$(jq -r .version frontend/package.json)" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Download installers from both builds
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
# Only the installers: the run also holds server-image's Docker build
|
|
# record, which is not a release asset (and once failed to download).
|
|
pattern: konduktor-*
|
|
path: artifacts # → artifacts/konduktor-macOS/…, artifacts/konduktor-Windows/…
|
|
|
|
# Release notes from the "Patch notes" section of the PR that merged this
|
|
# commit into main (dev → main merges carry many features in one PR, so
|
|
# its title alone says little). Written under "What's Changed", the
|
|
# heading the app's update dialog reads. No PR (a manual run, a direct
|
|
# push) or no such section → GitHub's generated notes, as before.
|
|
- name: Patch notes from the merged PR
|
|
id: notes
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
gh api "repos/${{ github.repository }}/commits/${{ github.sha }}/pulls" \
|
|
--jq '[.[] | select(.base.ref == "main" and .merged_at != null)][0].body // ""' \
|
|
> pr-body.md || : > pr-body.md
|
|
python3 - <<'EOF'
|
|
import os, re
|
|
body = open("pr-body.md", encoding="utf-8").read().replace("\r\n", "\n")
|
|
body = re.sub(r"<!--.*?-->", "", body, flags=re.S)
|
|
section, level = [], None
|
|
for line in body.split("\n"):
|
|
m = re.match(r"^(#{1,6})\s+(.*?)\s*#*\s*$", line)
|
|
if level is None:
|
|
if m and re.fullmatch(r"patch[\s-]?notes:?", m.group(2), re.I):
|
|
level = len(m.group(1))
|
|
elif m and len(m.group(1)) <= level:
|
|
break
|
|
else:
|
|
section.append(line)
|
|
notes = "\n".join(section).strip()
|
|
found = bool(notes)
|
|
if found:
|
|
with open("release-notes.md", "w", encoding="utf-8") as f:
|
|
f.write("## What's Changed\n\n" + notes + "\n")
|
|
with open(os.environ["GITHUB_OUTPUT"], "a") as out:
|
|
out.write(f"found={'true' if found else 'false'}\n")
|
|
print("Using the PR's patch notes." if found else "No patch notes section; using generated notes.")
|
|
EOF
|
|
|
|
# The in-app updater's manifest for THIS release (the app's update
|
|
# dialog finds the release, then reads releases/download/<tag>/latest.json).
|
|
# The .sig files are folded into it and not uploaded themselves.
|
|
- name: Updater manifest
|
|
run: |
|
|
python3 .github/scripts/updater_manifest.py artifacts \
|
|
--version "${{ steps.version.outputs.version }}" \
|
|
--tag "v${{ steps.version.outputs.version }}-b${{ github.run_number }}" \
|
|
--repo "${{ github.repository }}"
|
|
|
|
- name: Publish release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: v${{ steps.version.outputs.version }}-b${{ github.run_number }}
|
|
name: Konduktor v${{ steps.version.outputs.version }}-b${{ github.run_number }}
|
|
target_commitish: ${{ github.sha }}
|
|
body_path: ${{ steps.notes.outputs.found == 'true' && 'release-notes.md' || '' }}
|
|
generate_release_notes: ${{ steps.notes.outputs.found != 'true' }}
|
|
fail_on_unmatched_files: true
|
|
files: |
|
|
artifacts/**/*.dmg
|
|
artifacts/**/*-setup.exe
|
|
artifacts/**/*.app.tar.gz
|
|
artifacts/latest.json
|