name: Release on: workflow_dispatch: inputs: version: description: "Release version (e.g. 0.1.0)" required: true type: string notes: description: "Extra release notes (appended after default text)" required: false type: string default: "" permissions: contents: write pull-requests: write jobs: publish: name: Release (${{ matrix.name }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: - name: macOS (Apple Silicon) os: macos-14 args: --target aarch64-apple-darwin rust_targets: aarch64-apple-darwin,x86_64-apple-darwin - name: macOS (Intel) os: macos-14 args: --target x86_64-apple-darwin rust_targets: aarch64-apple-darwin,x86_64-apple-darwin ort_dylib: true - name: Windows os: windows-latest args: "" rust_targets: "" - name: Linux os: ubuntu-24.04 args: "" rust_targets: "" steps: - name: Checkout uses: actions/checkout@v5 - name: Setup pnpm uses: pnpm/action-setup@v4 with: version: 10.12.1 - name: Setup Node.js uses: actions/setup-node@v5 with: node-version: 20 cache: pnpm - name: Setup Rust uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.rust_targets }} - name: Restore Rust cache uses: swatinem/rust-cache@v2 with: workspaces: ./src-tauri -> target - name: Install Linux build dependencies if: runner.os == 'Linux' run: | sudo apt-get update sudo apt-get install -y \ build-essential \ curl \ file \ patchelf \ libasound2-dev \ libayatana-appindicator3-dev \ librsvg2-dev \ libssl-dev \ libwebkit2gtk-4.1-dev \ libxdo-dev \ wget - name: Download ONNX Runtime for Intel Mac cross-compile if: matrix.ort_dylib run: | ORT_VERSION="1.20.1" curl -L -o ort.tgz "https://github.com/microsoft/onnxruntime/releases/download/v${ORT_VERSION}/onnxruntime-osx-x86_64-${ORT_VERSION}.tgz" mkdir -p ${{ github.workspace }}/ort-x64 tar -xzf ort.tgz --strip-components=1 -C ${{ github.workspace }}/ort-x64 echo "ORT_LIB_LOCATION=${{ github.workspace }}/ort-x64/lib" >> $GITHUB_ENV echo "ORT_PREFER_DYNAMIC_LINK=1" >> $GITHUB_ENV # Inject macOS.frameworks into tauri.conf.json so the dylib is bundled inside .app ORT_DYLIB=$(ls ${{ github.workspace }}/ort-x64/lib/libonnxruntime.*.dylib | head -1) jq --arg dylib "$ORT_DYLIB" '.bundle.macOS.frameworks = [$dylib]' \ src-tauri/tauri.conf.json > src-tauri/tauri.conf.tmp \ && mv src-tauri/tauri.conf.tmp src-tauri/tauri.conf.json - name: Install JavaScript dependencies run: pnpm install --frozen-lockfile - name: Build and publish release uses: tauri-apps/tauri-action@action-v0.6.2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tagName: v${{ github.event.inputs.version }} releaseName: OpenKara v${{ github.event.inputs.version }} releaseBody: | See the assets below to download and install this version of OpenKara. ${{ github.event.inputs.notes }} releaseDraft: false prerelease: false args: ${{ matrix.args }} tauriScript: pnpm tauri prepare-distribution-manifests: name: Prepare distribution manifests runs-on: ubuntu-latest needs: publish steps: - name: Checkout uses: actions/checkout@v5 - name: Setup pnpm uses: pnpm/action-setup@v4 with: version: 10.12.1 - name: Setup Node.js uses: actions/setup-node@v5 with: node-version: 20 - name: Render WinGet manifests run: | node scripts/render-winget-manifests.mjs \ --version "${{ github.event.inputs.version }}" \ --output "${{ github.workspace }}/dist/winget" - name: Render Flatpak manifests run: | node scripts/render-flatpak-manifest.mjs \ --version "${{ github.event.inputs.version }}" \ --output "${{ github.workspace }}/dist/flatpak" \ --screenshot-base-url "https://raw.githubusercontent.com/thedavidweng/OpenKara/v${{ github.event.inputs.version }}/packaging/flatpak/screenshots" - name: Upload WinGet manifest artifact uses: actions/upload-artifact@v4 with: name: winget-manifests path: dist/winget - name: Upload Flatpak manifest artifact uses: actions/upload-artifact@v4 with: name: flatpak-manifests path: dist/flatpak submit-winget-pr: name: Submit WinGet PR runs-on: ubuntu-latest needs: prepare-distribution-manifests if: ${{ vars.WINGET_FORK_REPO != '' }} steps: - name: Check WinGet automation bootstrap id: bootstrap env: GH_TOKEN: ${{ secrets.WINGET_PR_TOKEN }} run: | if [ -z "${GH_TOKEN}" ]; then echo "ready=false" >> "$GITHUB_OUTPUT" echo "WINGET_PR_TOKEN is not configured; skipping WinGet PR automation." exit 0 fi echo "ready=true" >> "$GITHUB_OUTPUT" - name: Download WinGet manifest artifact if: ${{ steps.bootstrap.outputs.ready == 'true' }} uses: actions/download-artifact@v4 with: name: winget-manifests path: dist/winget - name: Create or update WinGet PR if: ${{ steps.bootstrap.outputs.ready == 'true' }} env: GH_TOKEN: ${{ secrets.WINGET_PR_TOKEN }} WINGET_FORK_REPO: ${{ vars.WINGET_FORK_REPO }} WINGET_TARGET_REPO: ${{ vars.WINGET_TARGET_REPO || 'microsoft/winget-pkgs' }} WINGET_BASE_BRANCH: ${{ vars.WINGET_BASE_BRANCH || 'master' }} WINGET_PACKAGE_IDENTIFIER: ${{ vars.WINGET_PACKAGE_IDENTIFIER || 'thedavidweng.OpenKara' }} VERSION: ${{ github.event.inputs.version }} run: | set -euo pipefail branch="openkara/${VERSION}" fork_owner="${WINGET_FORK_REPO%%/*}" target_repo="${WINGET_TARGET_REPO}" base_branch="${WINGET_BASE_BRANCH}" git clone "https://x-access-token:${GH_TOKEN}@github.com/${WINGET_FORK_REPO}.git" winget-fork cd winget-fork git remote add upstream "https://github.com/${target_repo}.git" git fetch upstream "${base_branch}" git checkout -B "${branch}" "upstream/${base_branch}" mkdir -p manifests/t/thedavidweng/OpenKara cp -R ../dist/winget/t/thedavidweng/OpenKara/"${VERSION}" manifests/t/thedavidweng/OpenKara/ git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add manifests/t/thedavidweng/OpenKara/"${VERSION}" if git diff --cached --quiet; then echo "No WinGet manifest changes to submit" exit 0 fi git commit -m "Add OpenKara ${VERSION}" git push origin "${branch}" --force pr_url="$(gh pr list --repo "${target_repo}" --head "${fork_owner}:${branch}" --json url --jq '.[0].url')" if [ -n "${pr_url}" ]; then echo "Existing WinGet PR: ${pr_url}" exit 0 fi if gh pr create \ --repo "${target_repo}" \ --base "${base_branch}" \ --head "${fork_owner}:${branch}" \ --title "New version: ${WINGET_PACKAGE_IDENTIFIER} version ${VERSION}" \ --body "Automated WinGet manifest update for OpenKara ${VERSION}."; then exit 0 fi compare_url="https://github.com/${WINGET_FORK_REPO}/compare/${base_branch}...${fork_owner}:${branch}?expand=1" { echo "WinGet PR could not be created automatically." echo "Open this URL to create it manually:" echo "${compare_url}" } | tee -a "$GITHUB_STEP_SUMMARY" exit 0 submit-flathub-pr: name: Submit Flathub PR runs-on: ubuntu-latest needs: prepare-distribution-manifests if: ${{ vars.FLATHUB_FORK_REPO != '' }} steps: - name: Check Flathub automation bootstrap id: bootstrap env: GH_TOKEN: ${{ secrets.FLATHUB_PR_TOKEN }} run: | if [ -z "${GH_TOKEN}" ]; then echo "ready=false" >> "$GITHUB_OUTPUT" echo "FLATHUB_PR_TOKEN is not configured; skipping Flathub PR automation." exit 0 fi echo "ready=true" >> "$GITHUB_OUTPUT" - name: Download Flatpak manifest artifact if: ${{ steps.bootstrap.outputs.ready == 'true' }} uses: actions/download-artifact@v4 with: name: flatpak-manifests path: dist/flatpak - name: Create or update Flathub PR if: ${{ steps.bootstrap.outputs.ready == 'true' }} env: GH_TOKEN: ${{ secrets.FLATHUB_PR_TOKEN }} FLATHUB_FORK_REPO: ${{ vars.FLATHUB_FORK_REPO }} FLATHUB_TARGET_REPO: ${{ vars.FLATHUB_TARGET_REPO }} FLATHUB_BASE_BRANCH: ${{ vars.FLATHUB_BASE_BRANCH }} VERSION: ${{ github.event.inputs.version }} run: | set -euo pipefail target_repo="${FLATHUB_TARGET_REPO:-flathub/io.github.thedavidweng.OpenKara}" base_branch="${FLATHUB_BASE_BRANCH:-master}" branch="openkara/${VERSION}" fork_owner="${FLATHUB_FORK_REPO%%/*}" git clone "https://x-access-token:${GH_TOKEN}@github.com/${FLATHUB_FORK_REPO}.git" flathub-fork cd flathub-fork git remote add upstream "https://github.com/${target_repo}.git" git fetch upstream "${base_branch}" git checkout -B "${branch}" "upstream/${base_branch}" cp -R ../dist/flatpak/io.github.thedavidweng.OpenKara/. . git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add . if git diff --cached --quiet; then echo "No Flathub manifest changes to submit" exit 0 fi git commit -m "Update OpenKara ${VERSION}" git push origin "${branch}" --force pr_url="$(gh pr list --repo "${target_repo}" --head "${fork_owner}:${branch}" --json url --jq '.[0].url')" if [ -n "${pr_url}" ]; then echo "Existing Flathub PR: ${pr_url}" exit 0 fi gh pr create \ --repo "${target_repo}" \ --base "${base_branch}" \ --head "${fork_owner}:${branch}" \ --title "Update OpenKara ${VERSION}" \ --body "Automated Flatpak manifest update for OpenKara ${VERSION}."