diff --git a/.github/workflows/flathub.yml b/.github/workflows/flathub.yml index a0f6c21b..c8c33f66 100644 --- a/.github/workflows/flathub.yml +++ b/.github/workflows/flathub.yml @@ -16,6 +16,13 @@ jobs: - name: Checkout app repo uses: actions/checkout@v4 + - name: Checkout Flathub repo + uses: actions/checkout@v4 + with: + repository: flathub/app.yaak.Yaak + token: ${{ secrets.FLATHUB_TOKEN }} + path: flathub-repo + - name: Set up Python uses: actions/setup-python@v5 with: @@ -32,22 +39,7 @@ jobs: git clone --depth 1 https://github.com/flatpak/flatpak-builder-tools flatpak/flatpak-builder-tools - name: Run update-manifest.sh - run: bash flatpak/update-manifest.sh "${{ github.event.release.tag_name }}" - - - name: Checkout Flathub repo - uses: actions/checkout@v4 - with: - repository: flathub/app.yaak.Yaak - token: ${{ secrets.FLATHUB_TOKEN }} - path: flathub-repo - - - name: Copy updated files to Flathub repo - run: | - cp flatpak/app.yaak.Yaak.yml flathub-repo/ - cp flatpak/cargo-sources.json flathub-repo/ - cp flatpak/node-sources.json flathub-repo/ - cp LICENSE flathub-repo/ - sed -i 's|path: \.\./LICENSE|path: LICENSE|' flathub-repo/app.yaak.Yaak.yml + run: bash flatpak/update-manifest.sh "${{ github.event.release.tag_name }}" flathub-repo - name: Commit and push to Flathub working-directory: flathub-repo diff --git a/flatpak/generate-sources.sh b/flatpak/generate-sources.sh index f656d0aa..216d0a4d 100755 --- a/flatpak/generate-sources.sh +++ b/flatpak/generate-sources.sh @@ -7,20 +7,25 @@ # Clone https://github.com/flatpak/flatpak-builder-tools (for cargo generator) # # Usage: -# ./flatpak/generate-sources.sh +# ./flatpak/generate-sources.sh +# ./flatpak/generate-sources.sh ../flathub-repo set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" -# Generate cargo-sources.json -python3 "$SCRIPT_DIR/flatpak-builder-tools/cargo/flatpak-cargo-generator.py" \ - -o "$SCRIPT_DIR/cargo-sources.json" "$REPO_ROOT/Cargo.lock" +if [ $# -lt 1 ]; then + echo "Usage: $0 " + echo "Example: $0 ../flathub-repo" + exit 1 +fi + +FLATHUB_REPO="$(cd "$1" && pwd)" + +python3 "$SCRIPT_DIR/flatpak-builder-tools/cargo/flatpak-cargo-generator.py" \ + -o "$FLATHUB_REPO/cargo-sources.json" "$REPO_ROOT/Cargo.lock" -# Generate node-sources.json from a patched copy of the lockfile. -# npm omits resolved/integrity for some workspace deps, and -# flatpak-node-generator can't handle workspace link entries. TMPDIR=$(mktemp -d) trap 'rm -rf "$TMPDIR"' EXIT @@ -40,4 +45,4 @@ node -e " " "$TMPDIR/package-lock.json" flatpak-node-generator --no-requests-cache \ - -o "$SCRIPT_DIR/node-sources.json" npm "$TMPDIR/package-lock.json" + -o "$FLATHUB_REPO/node-sources.json" npm "$TMPDIR/package-lock.json" diff --git a/flatpak/patch-lockfile.cjs b/flatpak/patch-lockfile.cjs deleted file mode 100644 index 222f1b64..00000000 --- a/flatpak/patch-lockfile.cjs +++ /dev/null @@ -1,20 +0,0 @@ -// Adds missing `resolved` URLs to package-lock.json for nested workspace deps. -// npm omits these fields for some packages (see https://github.com/npm/cli/issues/4460), -// which breaks offline installs. This script constructs the URL from the package -// name and version without requiring network access. - -const fs = require("fs"); - -const p = process.argv[2] || "package-lock.json"; -const d = JSON.parse(fs.readFileSync(p, "utf-8")); - -for (const [name, info] of Object.entries(d.packages || {})) { - if (!name || info.link || info.resolved) continue; - if (!name.includes("node_modules/") || !info.version) continue; - const pkg = name.split("node_modules/").pop(); - const base = pkg.split("/").pop(); - info.resolved = - "https://registry.npmjs.org/" + pkg + "/-/" + base + "-" + info.version + ".tgz"; -} - -fs.writeFileSync(p, JSON.stringify(d, null, 2)); diff --git a/flatpak/update-manifest.sh b/flatpak/update-manifest.sh index 1676365c..8ad59f70 100755 --- a/flatpak/update-manifest.sh +++ b/flatpak/update-manifest.sh @@ -1,30 +1,27 @@ #!/usr/bin/env bash # -# Update the Flatpak manifest for a new release. +# Update the Flathub repo for a new release. # # Usage: -# ./flatpak/update-manifest.sh v2026.2.0 -# -# This script: -# 1. Updates the git tag and commit in the manifest -# 2. Regenerates cargo-sources.json and node-sources.json from the tagged lockfiles -# 3. Adds a new entry to the metainfo +# ./flatpak/update-manifest.sh +# ./flatpak/update-manifest.sh v2026.2.0 ../flathub-repo set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" -MANIFEST="$SCRIPT_DIR/app.yaak.Yaak.yml" -METAINFO="$SCRIPT_DIR/app.yaak.Yaak.metainfo.xml" -if [ $# -lt 1 ]; then - echo "Usage: $0 " - echo "Example: $0 v2026.2.0" +if [ $# -lt 2 ]; then + echo "Usage: $0 " + echo "Example: $0 v2026.2.0 ../flathub-repo" exit 1 fi VERSION_TAG="$1" VERSION="${VERSION_TAG#v}" +FLATHUB_REPO="$(cd "$2" && pwd)" +MANIFEST="$FLATHUB_REPO/app.yaak.Yaak.yml" +METAINFO="$SCRIPT_DIR/app.yaak.Yaak.metainfo.xml" if [[ "$VERSION" == *-* ]]; then echo "Skipping pre-release version '$VERSION_TAG' (only stable releases are published to Flathub)" @@ -58,7 +55,7 @@ curl -fsSL "https://raw.githubusercontent.com/$REPO/$VERSION_TAG/package.json" - echo "Generating cargo-sources.json..." python3 "$SCRIPT_DIR/flatpak-builder-tools/cargo/flatpak-cargo-generator.py" \ - -o "$SCRIPT_DIR/cargo-sources.json" "$TMPDIR/Cargo.lock" + -o "$FLATHUB_REPO/cargo-sources.json" "$TMPDIR/Cargo.lock" echo "Generating node-sources.json..." node "$SCRIPT_DIR/fix-lockfile.mjs" "$TMPDIR/package-lock.json" @@ -74,7 +71,7 @@ node -e " " "$TMPDIR/package-lock.json" flatpak-node-generator --no-requests-cache \ - -o "$SCRIPT_DIR/node-sources.json" npm "$TMPDIR/package-lock.json" + -o "$FLATHUB_REPO/node-sources.json" npm "$TMPDIR/package-lock.json" # Update metainfo with new release TODAY=$(date +%Y-%m-%d) @@ -85,5 +82,5 @@ echo "" echo "Done! Review the changes:" echo " $MANIFEST" echo " $METAINFO" -echo " $SCRIPT_DIR/cargo-sources.json" -echo " $SCRIPT_DIR/node-sources.json" +echo " $FLATHUB_REPO/cargo-sources.json" +echo " $FLATHUB_REPO/node-sources.json" diff --git a/flatpak/yaak.desktop b/flatpak/yaak.desktop deleted file mode 100644 index 0b7f0736..00000000 --- a/flatpak/yaak.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Categories=Development; -Comment=The API client for modern developers -Exec=yaak-app -Icon=yaak-app -Name=Yaak -StartupWMClass=yaak -Terminal=false -Type=Application