name: desktop-release # Phase 1 M5.4 — Linux desktop packaging (jpackage app-image + deb). # jpackage cannot cross-compile (§7 of the phase plan), and macOS/Windows # GA is explicitly Phase 2 (§8) — this job therefore runs ONLY on the # Linux self-hosted runner; the deferred jobs at the bottom document the # shape the matrix takes when matching runners exist. on: push: tags: - 'v*.*.*' # Same retry rationale as release.yml: a tag push pins this file to the # tag's commit, so re-dispatching against main replays main's current # workflow against an already-published tag. workflow_dispatch: inputs: tag: description: 'Existing tag to rebuild desktop assets for, e.g. v0.4.2.0' required: true type: string jobs: desktop-linux: name: Build Linux desktop image (+deb when dpkg present) runs-on: ubuntu-latest timeout-minutes: 40 env: RELEASE_TAG: ${{ github.event.inputs.tag || github.ref_name }} steps: - name: Checkout run: | git clone https://git.trevena.info/nick/incido.git repo cd repo git fetch --depth=1 origin tag "$RELEASE_TAG" || true git fetch --tags origin git checkout "$RELEASE_TAG" - name: Set up JDK 17 run: | WORKDIR=/var/lib/gitea-runner/work if [ ! -d "$WORKDIR/jdk" ]; then wget -q 'https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.13%2B11/OpenJDK17U-jdk_x64_linux_hotspot_17.0.13_11.tar.gz' -O /tmp/jdk.tar.gz mkdir -p "$WORKDIR/jdk" tar -xzf /tmp/jdk.tar.gz -C "$WORKDIR/jdk" --strip-components=1 rm /tmp/jdk.tar.gz fi echo "JAVA_HOME=$WORKDIR/jdk" >> $GITHUB_ENV echo "PATH=$WORKDIR/jdk/bin:$PATH" >> $GITHUB_ENV - name: Set up Android SDK run: | # Desktop modules don't use it, but AGP evaluation of :app / # :composeApp needs ANDROID_HOME during the configuration # phase of every build in this repo. Same cache as dev.yml. WORKDIR=/var/lib/gitea-runner/work SDK=$WORKDIR/android-sdk if [ ! -d "$SDK/cmdline-tools/latest" ]; then mkdir -p "$SDK" wget -q 'https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip' -O /tmp/cmdline-tools.zip unzip -q /tmp/cmdline-tools.zip -d /tmp/cmdline-tools-extract mkdir -p "$SDK/cmdline-tools" mv /tmp/cmdline-tools-extract/cmdline-tools "$SDK/cmdline-tools/latest" rm -rf /tmp/cmdline-tools.zip /tmp/cmdline-tools-extract yes | "$SDK/cmdline-tools/latest/bin/sdkmanager" --licenses > /dev/null 2>&1 || true "$SDK/cmdline-tools/latest/bin/sdkmanager" --install \ "platform-tools" \ "platforms;android-34" \ "build-tools;34.0.0" > /dev/null 2>&1 fi echo "ANDROID_HOME=$SDK" >> $GITHUB_ENV echo "ANDROID_SDK_ROOT=$SDK" >> $GITHUB_ENV - name: Build desktop distribution timeout-minutes: 30 run: | cd repo chmod +x gradlew ./gradlew --stop 2>/dev/null || true # App-image first — it needs no host tooling (Phase 0 Q6). ./gradlew :desktopApp:createDistributable :desktopApp:printPackageVersion --no-daemon VERSION=$(./gradlew -q :desktopApp:printPackageVersion | grep PACKAGE-VERSION | awk '{print $2}') echo "PKG_VERSION=$VERSION" >> $GITHUB_ENV IMAGE_DIR=desktopApp/build/compose/binaries/main/app/incido test -x "$IMAGE_DIR/bin/incido" # M5.3 contract: smoke the IMAGE, not just the run task (the # jlink runtime hides missing modules until inside the image). if command -v xvfb-run >/dev/null 2>&1; then rm -rf /tmp/ci-desktop-smoke xvfb-run -a "$IMAGE_DIR/bin/incido" --data-dir /tmp/ci-desktop-smoke --self-test --exit-after 6 \ | tee /tmp/desktop-smoke.log grep -q 'SELFTEST wrote note' /tmp/desktop-smoke.log echo 'Image smoke PASS' else echo 'NO xvfb on this runner — image smoke SKIPPED (recorded, not faked).' fi # deb only when dpkg exists; rpm needs rpmbuild (absent here). if command -v dpkg >/dev/null 2>&1; then ./gradlew :desktopApp:packageDeb --no-daemon || \ echo 'deb packaging failed (recorded; app-image still shipped)' else echo 'NO dpkg on this runner — deb build skipped (recorded).' fi - name: Stage assets run: | cd repo VERSION="${PKG_VERSION:-$RELEASE_TAG}" IMAGE_DIR=desktopApp/build/compose/binaries/main/app/incido # Bundle the M5.3 .desktop template + icon INSIDE the tarball. cp desktopApp/packaging/incido.desktop desktopApp/packaging/icon.png "$IMAGE_DIR/" tar -czf "Incido-${VERSION}-linux-x64.tar.gz" -C "$(dirname "$IMAGE_DIR")" incido ls -la Incido-*.tar.gz cp desktopApp/build/compose/binaries/main/deb/*.deb "Incido-${VERSION}-linux-x64.deb" 2>/dev/null \ || echo 'no deb produced (dpkg absent or failed) — asset list will omit it' - name: Attach desktop assets to the release env: GH_TOKEN: ${{ secrets.TOKEN }} run: | set -e cd repo TAG="$RELEASE_TAG" API="http://192.168.8.17:3000/api/v1/repos/nick/incido" RELEASE_ID=$(curl -s "$API/releases/tags/$TAG" \ -H "Authorization: token $GH_TOKEN" \ | python3 -c "import sys,json; print(json.load(sys.stdin).get('id','') or '')") if [ -z "$RELEASE_ID" ]; then echo "No release for $TAG yet (APK release job may not have run) — creating it." RELEASE_ID=$(curl -s -X POST "$API/releases" \ -H "Authorization: token $GH_TOKEN" \ -H "Content-Type: application/json" \ -d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"Desktop assets for $TAG\",\"draft\":false,\"prerelease\":false}" \ | python3 -c "import sys,json; print(json.load(sys.stdin).get('id','') or '')") fi test -n "$RELEASE_ID" for ASSET in Incido-*.tar.gz Incido-*.deb; do [ -f "$ASSET" ] || continue for attempt in 1 2 3 4 5; do echo "--- Uploading $ASSET (attempt $attempt/5) ---" curl -s -f -X POST "$API/releases/$RELEASE_ID/assets?name=$ASSET" \ -H "Authorization: token $GH_TOKEN" \ -F "attachment=@$ASSET" \ --max-time 900 --retry 2 --retry-all-errors --retry-delay 15 >/dev/null || true if curl -s "$API/releases/$RELEASE_ID" -H "Authorization: token $GH_TOKEN" \ | python3 -c "import sys,json; d=json.load(sys.stdin); sys.exit(0 if any(a['name']=='$ASSET' for a in d['assets']) else 1)"; then echo "Verified: $ASSET attached." break fi [ "$attempt" = 5 ] && { echo "ERROR: $ASSET not attached after 5 attempts"; exit 1; } sleep 15 done done # Deferred per phase plan §8 (macOS/Windows GA = Phase 2): enable when # this Gitea instance has runner labels for those OSes. jpackage will # not cross-compile; each OS needs its own host. # # desktop-macos: # runs-on: macos-latest # (a self-hosted macOS runner label) # steps: [ ...createDistributable with Dmg; codesigning TBD... ] # desktop-windows: # runs-on: windows-latest # (a self-hosted Windows runner label) # steps: [ ...createDistributable with Msi/Exe... ]