diff --git a/PKGBUILD b/PKGBUILD index e1826b8..834a38c 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,5 +1,5 @@ pkgname=moku -pkgver=0.2.0 +pkgver=0.3.0 pkgrel=1 pkgdesc="Native Linux manga reader frontend for Suwayomi-Server" arch=('x86_64') @@ -22,7 +22,7 @@ source=( "suwayomi-server.jar::https://github.com/Suwayomi/Suwayomi-Server/releases/download/v2.1.1867/suwayomi-server-v2.1.1867.jar" "jdk.tar.gz::https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.3%2B9/OpenJDK21U-jre_x64_linux_hotspot_21.0.3_9.tar.gz" ) -sha256sums=('dfd110ae4f11711ce979020ae65b08ab2d0bd51ecc1ba877ba1780ba037357a4' +sha256sums=('2475d4bb4c7e8527384f7fcf9b0ace1c8a6354416f3af31398b844e35953fb73' '51e307c2581e4e1a002991ab3e3a77503c8b074c42695987a984a7382d0ac5af' 'f1af100c4afca2035f446967323230150cfe5872b5a664d98c86963e5c066e0d') diff --git a/build-scripts/bump.sh b/build-scripts/bump.sh new file mode 100755 index 0000000..cc0dd37 --- /dev/null +++ b/build-scripts/bump.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# build-scripts/pkgbuild-bump.sh +# ───────────────────────────────────────────────────────────────────────────── +# Run this AFTER the git tag has been pushed to GitHub. +# +# Usage: +# ./build-scripts/pkgbuild-bump.sh 0.3.0 +set -euo pipefail + +RED='\033[0;31m'; GREEN='\033[0;32m'; CYAN='\033[0;36m'; BOLD='\033[1m'; RESET='\033[0m' +info() { echo -e "${CYAN} →${RESET} $*"; } +success() { echo -e "${GREEN} ✓${RESET} $*"; } +die() { echo -e "${RED} ✗${RESET} $*" >&2; exit 1; } +section() { echo -e "\n${BOLD}── $* ──${RESET}"; } + +[[ $# -lt 1 ]] && die "Usage: $0 " +VERSION="$1" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" +PKGBUILD="${REPO_ROOT}/PKGBUILD" + +command -v curl &>/dev/null || die "curl not found" +[[ -f "$PKGBUILD" ]] || die "PKGBUILD not found: $PKGBUILD" + +section "Patching PKGBUILD → ${VERSION}" + +TARBALL_URL="https://github.com/Youwes09/Moku/archive/refs/tags/v${VERSION}.tar.gz" +info "Fetching source tarball to compute sha256…" +TARBALL_SHA=$(curl -fsSL "$TARBALL_URL" | sha256sum | awk '{print $1}') + +sed -i "s/^pkgver=.*/pkgver=${VERSION}/" "$PKGBUILD" +sed -i "s/^pkgrel=.*/pkgrel=1/" "$PKGBUILD" + +# Replace only the first sha256 entry (source tarball) inside sha256sums=('...') +# The suwayomi jar and jdk hashes are pinned and stay untouched. +# Strategy: match the opening sha256sums=('' then swap just that first hash. +sed -i "s/\(sha256sums=('\)[0-9a-f]\{64\}/\1${TARBALL_SHA}/" "$PKGBUILD" + +# Verify the replacement landed +if ! grep -q "$TARBALL_SHA" "$PKGBUILD"; then + die "sha256 replacement failed — check PKGBUILD sha256sums format" +fi + +success "PKGBUILD patched (pkgver=${VERSION}, sha256=${TARBALL_SHA})" +info "PKGBUILD → ${PKGBUILD}" \ No newline at end of file diff --git a/build-scripts/release.sh b/build-scripts/release.sh index 4669223..5e73cd5 100755 --- a/build-scripts/release.sh +++ b/build-scripts/release.sh @@ -2,18 +2,14 @@ # build-scripts/release.sh # ───────────────────────────────────────────────────────────────────────────── # Usage: -# ./build-scripts/release.sh 0.2.0 — full release (AUR + Flatpak) -# ./build-scripts/release.sh 0.2.0 --aur — AUR bin package only -# ./build-scripts/release.sh 0.2.0 --flatpak — Flatpak sources + bundle only +# ./build-scripts/release.sh 0.2.0 # -# Requires: nix, podman (for AUR .SRCINFO generation in Arch container) - +# Requires: nix, flatpak-builder, appstream set -euo pipefail # ── Colour helpers ───────────────────────────────────────────────────────────── RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m' CYAN='\033[0;36m'; BOLD='\033[1m'; RESET='\033[0m' - info() { echo -e "${CYAN} →${RESET} $*"; } success() { echo -e "${GREEN} ✓${RESET} $*"; } warn() { echo -e "${YELLOW} ⚠${RESET} $*"; } @@ -21,31 +17,23 @@ die() { echo -e "${RED} ✗${RESET} $*" >&2; exit 1; } section() { echo -e "\n${BOLD}── $* ──${RESET}"; } # ── Args ─────────────────────────────────────────────────────────────────────── -[[ $# -lt 1 ]] && die "Usage: $0 [--aur|--flatpak]" - +[[ $# -lt 1 ]] && die "Usage: $0 " VERSION="$1" -MODE="${2:-all}" - SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" -AUR_DIR="${REPO_ROOT}/../moku-bin" -TARBALL="moku-${VERSION}-x86_64.tar.gz" FLATPAK_MANIFEST="${REPO_ROOT}/dev.moku.app.yml" +PKGBUILD="${REPO_ROOT}/PKGBUILD" # ── Sanity checks ────────────────────────────────────────────────────────────── section "Pre-flight" -command -v nix &>/dev/null || die "nix not found" - -if [[ "$MODE" == "all" || "$MODE" == "--aur" ]]; then - command -v podman &>/dev/null || die "podman not found — needed for Arch container (makepkg)" - [[ -d "$AUR_DIR" ]] || die "AUR dir not found at $AUR_DIR\nClone it first:\n git clone ssh://aur@aur.archlinux.org/moku-bin.git ../moku-bin" - [[ -f "${AUR_DIR}/PKGBUILD" ]] || die "PKGBUILD not found in $AUR_DIR" -fi +command -v nix &>/dev/null || die "nix not found" +command -v curl &>/dev/null || die "curl not found" +[[ -f "$FLATPAK_MANIFEST" ]] || die "Flatpak manifest not found: $FLATPAK_MANIFEST" +[[ -f "$PKGBUILD" ]] || die "PKGBUILD not found: $PKGBUILD" success "OK" # ── Bump versions ────────────────────────────────────────────────────────────── section "Bumping version → ${VERSION}" - sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"${VERSION}\"/" \ "${REPO_ROOT}/src-tauri/tauri.conf.json" success "tauri.conf.json → ${VERSION}" @@ -54,6 +42,12 @@ sed -i "0,/^version = \"[^\"]*\"/s//version = \"${VERSION}\"/" \ "${REPO_ROOT}/src-tauri/Cargo.toml" success "Cargo.toml → ${VERSION}" +# flake.nix has two `version = "x.y.z";` strings inside the frontend +# derivation and fetchPnpmDeps — both need to match. +sed -i "s/version = \"[^\"]*\";/version = \"${VERSION}\";/g" \ + "${REPO_ROOT}/flake.nix" +success "flake.nix → ${VERSION}" + # ── Build frontend ───────────────────────────────────────────────────────────── section "Building frontend" cd "$REPO_ROOT" @@ -61,37 +55,26 @@ nix develop --command pnpm install --frozen-lockfile nix develop --command pnpm build success "Frontend built → dist/" -# ── Build Rust binary ────────────────────────────────────────────────────────── -section "Building Rust binary" -nix develop --command cargo build --release --manifest-path src-tauri/Cargo.toml - -BINARY="${REPO_ROOT}/src-tauri/target/release/moku" -[[ -f "$BINARY" ]] || die "Binary not found: $BINARY" -success "Binary → $BINARY" - # ── Flatpak ──────────────────────────────────────────────────────────────────── -if [[ "$MODE" == "all" || "$MODE" == "--flatpak" ]]; then - section "Regenerating cargo-sources.json" - cd "$REPO_ROOT" - nix-shell \ - -p "python311.withPackages(ps: [ ps.aiohttp ps.tomlkit ])" \ - --run "python3 packaging/flatpak-cargo-generator.py src-tauri/Cargo.lock -o packaging/cargo-sources.json" - success "cargo-sources.json updated" +section "Regenerating cargo-sources.json" +cd "$REPO_ROOT" +nix-shell \ + -p "python311.withPackages(ps: [ ps.aiohttp ps.tomlkit ])" \ + --run "python3 packaging/flatpak-cargo-generator.py src-tauri/Cargo.lock -o packaging/cargo-sources.json" +success "cargo-sources.json updated" - section "Rebuilding frontend-dist.tar.gz" - tar -czf packaging/frontend-dist.tar.gz -C dist . - FRONTEND_SHA=$(sha256sum packaging/frontend-dist.tar.gz | awk '{print $1}') - success "frontend-dist.tar.gz rebuilt sha256: ${FRONTEND_SHA}" +section "Rebuilding frontend-dist.tar.gz" +tar -czf packaging/frontend-dist.tar.gz -C dist . +FRONTEND_SHA=$(sha256sum packaging/frontend-dist.tar.gz | awk '{print $1}') +success "frontend-dist.tar.gz rebuilt sha256: ${FRONTEND_SHA}" - # Patch the sha256 in dev.moku.app.yml automatically via a temp script - PATCH_SCRIPT=$(mktemp /tmp/patch-sha256-XXXXXX.py) - cat > "$PATCH_SCRIPT" << PYEOF +section "Patching frontend-dist sha256 in dev.moku.app.yml" +PATCH_SCRIPT=$(mktemp /tmp/patch-sha256-XXXXXX.py) +cat > "$PATCH_SCRIPT" << PYEOF import re, sys - path = "${FLATPAK_MANIFEST}" new_sha = "${FRONTEND_SHA}" text = open(path).read() - pattern = r'(path:\s*packaging/frontend-dist\.tar\.gz\s*\n\s*sha256:\s*)[0-9a-f]+' replacement = r'\g<1>' + new_sha updated, n = re.subn(pattern, replacement, text) @@ -99,86 +82,32 @@ if n == 0: sys.exit("Could not find frontend-dist sha256 in dev.moku.app.yml") open(path, 'w').write(updated) PYEOF - nix-shell -p python3 --run "python3 '$PATCH_SCRIPT'" - rm -f "$PATCH_SCRIPT" - success "dev.moku.app.yml sha256 updated" +nix-shell -p python3 --run "python3 '$PATCH_SCRIPT'" +rm -f "$PATCH_SCRIPT" +success "dev.moku.app.yml sha256 updated" - section "Building Flatpak bundle" - rm -rf "${REPO_ROOT}/build-dir" "${REPO_ROOT}/repo" +section "Building Flatpak bundle" +rm -rf "${REPO_ROOT}/build-dir" "${REPO_ROOT}/repo" +nix shell nixpkgs#appstream nixpkgs#flatpak-builder --command \ + flatpak-builder \ + --repo="${REPO_ROOT}/repo" \ + --force-clean \ + "${REPO_ROOT}/build-dir" \ + "$FLATPAK_MANIFEST" - nix shell nixpkgs#appstream nixpkgs#flatpak-builder --command \ - flatpak-builder \ - --repo="${REPO_ROOT}/repo" \ - --force-clean \ - "${REPO_ROOT}/build-dir" \ - "$FLATPAK_MANIFEST" +flatpak build-bundle \ + "${REPO_ROOT}/repo" \ + "${REPO_ROOT}/moku.flatpak" \ + dev.moku.app - flatpak build-bundle \ - "${REPO_ROOT}/repo" \ - "${REPO_ROOT}/moku.flatpak" \ - dev.moku.app - - # Clean up intermediate build artefacts — keep only moku.flatpak - rm -rf "${REPO_ROOT}/build-dir" "${REPO_ROOT}/repo" - success "moku.flatpak created" -fi - -# ── AUR tarball + PKGBUILD ───────────────────────────────────────────────────── -if [[ "$MODE" == "all" || "$MODE" == "--aur" ]]; then - section "Assembling release tarball" - cd "$REPO_ROOT" - STAGE="release-${VERSION}" - rm -rf "$STAGE" - - install -Dm755 "$BINARY" "${STAGE}/usr/bin/moku" - install -Dm644 packaging/dev.moku.app.desktop "${STAGE}/usr/share/applications/dev.moku.app.desktop" - install -Dm644 src-tauri/icons/32x32.png "${STAGE}/usr/share/icons/hicolor/32x32/apps/dev.moku.app.png" - install -Dm644 src-tauri/icons/128x128.png "${STAGE}/usr/share/icons/hicolor/128x128/apps/dev.moku.app.png" - install -Dm644 "src-tauri/icons/128x128@2x.png" "${STAGE}/usr/share/icons/hicolor/256x256/apps/dev.moku.app.png" - install -Dm644 packaging/dev.moku.app.metainfo.xml "${STAGE}/usr/share/metainfo/dev.moku.app.metainfo.xml" - - tar -czf "$TARBALL" "$STAGE/" - AUR_SHA=$(sha256sum "$TARBALL" | awk '{print $1}') - rm -rf "$STAGE" - success "Tarball: ${TARBALL} sha256: ${AUR_SHA}" - - section "Patching PKGBUILD" - PKGBUILD="${AUR_DIR}/PKGBUILD" - sed -i "s/^pkgver=.*/pkgver=${VERSION}/" "$PKGBUILD" - sed -i "s/^pkgrel=.*/pkgrel=1/" "$PKGBUILD" - sed -i "s/sha256sums=('[^']*')/sha256sums=('${AUR_SHA}')/" "$PKGBUILD" - success "PKGBUILD patched" - - # Tarball is only needed for the GitHub upload — remind user then it can go - info "Tarball kept at ${REPO_ROOT}/${TARBALL} — upload it to GitHub, then it can be deleted" - - section "Generating .SRCINFO (Arch container)" - # Mount only the AUR dir into a throwaway Arch container and run makepkg - podman run --rm \ - --volume "${AUR_DIR}:/aur:z" \ - --workdir /aur \ - archlinux:latest \ - bash -c " - pacman -Sy --noconfirm pacman >/dev/null 2>&1 - source PKGBUILD - makepkg --printsrcinfo > .SRCINFO - " - success ".SRCINFO generated" - - section "Next steps" - echo "" - echo -e " ${BOLD}1. Upload tarball to GitHub:${RESET}" - echo -e " ${CYAN}gh release create v${VERSION} '${REPO_ROOT}/${TARBALL}' --title 'v${VERSION}' --generate-notes${RESET}" - echo "" - echo -e " ${BOLD}2. Push AUR:${RESET}" - echo -e " ${CYAN}cd ${AUR_DIR}${RESET}" - echo -e " ${CYAN}git add PKGBUILD .SRCINFO${RESET}" - echo -e " ${CYAN}git commit -m 'Update to ${VERSION}'${RESET}" - echo -e " ${CYAN}git push origin master${RESET}" - echo "" - echo -e " ${BOLD}3. Clean up:${RESET}" - echo -e " ${CYAN}rm -f ${REPO_ROOT}/${TARBALL}${RESET}" -fi +rm -rf "${REPO_ROOT}/build-dir" "${REPO_ROOT}/repo" +success "moku.flatpak created" +# ── Done ─────────────────────────────────────────────────────────────────────── echo "" -success "v${VERSION} ready" \ No newline at end of file +success "v${VERSION} ready" +info "Flatpak bundle → ${REPO_ROOT}/moku.flatpak" +echo "" +warn "PKGBUILD not patched yet — tag must exist on GitHub first." +info "After pushing the tag, run:" +echo -e " ${CYAN}./build-scripts/pkgbuild-bump.sh ${VERSION}${RESET}" \ No newline at end of file diff --git a/dev.moku.app.yml b/dev.moku.app.yml index ff0deb6..429618d 100644 --- a/dev.moku.app.yml +++ b/dev.moku.app.yml @@ -181,7 +181,7 @@ modules: path: . - type: file path: packaging/frontend-dist.tar.gz - sha256: ac23bf503533711b19b7fd4b3ec04e081928f2f41b66d8391af1a9e36681548a + sha256: c9bb5ee6613b2bc61e69a92cc1ef0029da3b61138d51b01d363f8ea524e51996 - packaging/cargo-sources.json - type: inline dest: src-tauri/.cargo diff --git a/flake.nix b/flake.nix index 225ed9d..273d044 100644 --- a/flake.nix +++ b/flake.nix @@ -75,7 +75,7 @@ frontend = pkgs.stdenv.mkDerivation { pname = "moku-frontend"; - version = "0.1.0"; + version = "0.3.0"; src = frontendSrc; nativeBuildInputs = with pkgs; [ @@ -86,7 +86,7 @@ pnpmDeps = pkgs.fetchPnpmDeps { pname = "moku-frontend"; - version = "0.1.0"; + version = "0.3.0"; src = frontendSrc; fetcherVersion = 1; hash = "sha256-bpGYsB534RPNNAcYR9BA61vvFpSG6Xu2hY923PakCyY="; @@ -135,11 +135,67 @@ --prefix PATH : "${lib.makeBinPath [ pkgs.suwayomi-server ]}" \ --set GDK_BACKEND wayland \ --set WEBKIT_FORCE_SANDBOX 0 + + # ── Icon ───────────────────────────────────────────────────────── + # Tauri bakes several sizes into src-tauri/icons/. We prefer the + # largest PNG (512x512) for the hicolor theme, and also install the + # rounded 32x32 used as the in-app logo so small sizes look right. + # Adjust the source filenames if yours differ. + for size in 32x32 128x128 256x256 512x512; do + src="icons/$size.png" + if [ -f "$src" ]; then + install -Dm644 "$src" \ + "$out/share/icons/hicolor/$size/apps/moku.png" + fi + done + + # @2x variants that Tauri also generates + for size in 128x128 256x256; do + src="icons/''${size}@2x.png" + if [ -f "$src" ]; then + install -Dm644 "$src" \ + "$out/share/icons/hicolor/''${size}@2/apps/moku.png" + fi + done + + # Scalable SVG — src/assets/moku-icon.svg is the rounded version + # referenced in SplashScreen.tsx. Pull it straight from the source + # tree so the launcher always uses the same rounded artwork. + install -Dm644 "${./src/assets/moku-icon.svg}" \ + "$out/share/icons/hicolor/scalable/apps/moku.svg" + + # ── .desktop entry ─────────────────────────────────────────────── + install -Dm644 /dev/stdin \ + "$out/share/applications/moku.desktop" <