Build and Release #50
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Build and Release" | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| jobs: | |
| create-release: | |
| permissions: | |
| contents: write | |
| runs-on: ubuntu-latest | |
| outputs: | |
| release_id: ${{ steps.create-release.outputs.result }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: setup node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| - name: get version | |
| run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV | |
| - name: create release | |
| id: create-release | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { data } = await github.rest.repos.createRelease({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag_name: `app-v${process.env.PACKAGE_VERSION}`, | |
| name: `KiraPilot v${process.env.PACKAGE_VERSION}`, | |
| body: 'KiraPilot is a cross-platform productivity application that combines task management, time tracking, and intelligent AI assistance. The app helps users navigate their day with precision through beautiful design and smart automation. Take a look at the assets to download and install this app.', | |
| draft: true, | |
| prerelease: false | |
| }) | |
| return data.id | |
| build-tauri: | |
| needs: create-release | |
| permissions: | |
| contents: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: "macos-latest" # for Arm based macs (M1 and above). | |
| args: "--target aarch64-apple-darwin" | |
| os_name: "macos-arm64" | |
| - platform: "macos-latest" # for Intel based macs. | |
| args: "--target x86_64-apple-darwin" | |
| os_name: "macos-x64" | |
| - platform: "ubuntu-22.04" # for Tauri v1 you could replace this with ubuntu-20.04. | |
| args: "" | |
| os_name: "linux-x64" | |
| - platform: "windows-latest" | |
| args: "" | |
| os_name: "windows-x64" | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch full git history for build info generation | |
| - name: setup node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| - name: install Rust stable | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds. | |
| targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} | |
| components: rustfmt, clippy | |
| - name: Rust cache | |
| uses: swatinem/rust-cache@v2 | |
| with: | |
| workspaces: './src-tauri -> target' | |
| - name: install dependencies (ubuntu only) | |
| if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above. | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libwebkit2gtk-4.1-dev librsvg2-dev patchelf build-essential curl wget file libssl-dev pkg-config libgtk-3-dev libayatana-appindicator3-dev libomp-dev | |
| # webkitgtk 4.1 is for Tauri v2 - removed 4.0 to avoid conflicts | |
| # Added build-essential and other essential dev tools for proc-macro compilation | |
| - name: install dependencies (macOS only) | |
| if: matrix.platform == 'macos-latest' | |
| run: | | |
| brew install libomp | |
| # Ensure git is available in build context | |
| git config --global --add safe.directory '*' | |
| # Install OpenMP for better performance on macOS builds | |
| - name: install frontend dependencies | |
| run: npm ci # Using npm ci for more reliable builds | |
| - uses: tauri-apps/tauri-action@v0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Fix ARM64 macOS build issues with llama-cpp | |
| GGML_NO_I8MM: "1" | |
| GGML_NO_SVE: "1" | |
| GGML_NO_SME: "1" | |
| GGML_METAL: "1" | |
| # Additional environment variables for better builds | |
| MACOSX_DEPLOYMENT_TARGET: "10.13" | |
| CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER: "clang" | |
| CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER: "clang" | |
| # Ensure git context is available for build info | |
| GIT_DISCOVERY_ACROSS_FILESYSTEMS: "1" | |
| GIT_CEILING_DIRECTORIES: "/" | |
| with: | |
| releaseId: ${{ needs.create-release.outputs.release_id }} | |
| args: ${{ matrix.args }} | |
| rename-assets: | |
| permissions: | |
| contents: write | |
| runs-on: ubuntu-latest | |
| needs: [create-release, build-tauri] | |
| steps: | |
| - name: rename release assets | |
| id: rename-assets | |
| uses: actions/github-script@v7 | |
| env: | |
| release_id: ${{ needs.create-release.outputs.release_id }} | |
| with: | |
| script: | | |
| // Get all assets from the release | |
| const { data: release } = await github.rest.repos.getRelease({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| release_id: process.env.release_id | |
| }); | |
| console.log(`Found ${release.assets.length} assets to process`); | |
| function detectPlatform(filename) { | |
| // macOS files | |
| if (filename.includes('.app.tar.gz')) { | |
| if (filename.includes('aarch64')) return 'macos-arm64'; | |
| if (filename.includes('x64') || filename.includes('x86_64')) return 'macos-x64'; | |
| return 'macos-universal'; | |
| } | |
| if (filename.includes('.dmg')) return 'macos-universal'; | |
| // Windows files | |
| if (filename.includes('.exe') || filename.includes('.msi')) return 'windows-x64'; | |
| // Linux files | |
| if (filename.includes('.AppImage') || filename.includes('.deb')) { | |
| if (filename.includes('aarch64') || filename.includes('arm64')) return 'linux-arm64'; | |
| return 'linux-x64'; | |
| } | |
| return null; | |
| } | |
| function generateCleanName(originalName, platform) { | |
| // Extract version if present (format like _0.0.13_) | |
| const versionMatch = originalName.match(/_(\d+\.\d+\.\d+)_/); | |
| const version = versionMatch ? versionMatch[1] : null; | |
| // Remove existing architecture indicators to avoid duplication | |
| let cleanName = originalName | |
| .replace(/_amd64/g, '') | |
| .replace(/_x64/g, '') | |
| .replace(/_aarch64/g, '') | |
| .replace(/_arm64/g, '') | |
| .replace(/-setup/g, '') | |
| .replace(/_en-US/g, ''); | |
| // Handle different file types | |
| if (cleanName.includes('.app.tar.gz')) { | |
| // For macOS app bundles: KiraPilot.app.tar.gz -> KiraPilot_0.0.13-macos-arm64.app.tar.gz | |
| const baseName = cleanName.replace('.app.tar.gz', ''); | |
| const versionPart = version ? `_${version}` : ''; | |
| return `${baseName}${versionPart}-${platform}.app.tar.gz`; | |
| } else if (cleanName.includes('.dmg')) { | |
| // For DMG files: KiraPilot.dmg -> KiraPilot_0.0.13-macos-universal.dmg | |
| const baseName = cleanName.replace('.dmg', ''); | |
| const versionPart = version ? `_${version}` : ''; | |
| return `${baseName}${versionPart}-${platform}.dmg`; | |
| } else if (cleanName.includes('.tar.gz')) { | |
| // For other tar.gz files: file.tar.gz -> file-platform.tar.gz | |
| return cleanName.replace('.tar.gz', `-${platform}.tar.gz`); | |
| } else { | |
| // For single extension files: file.ext -> file-platform.ext | |
| const lastDotIndex = cleanName.lastIndexOf('.'); | |
| if (lastDotIndex !== -1) { | |
| const baseName = cleanName.substring(0, lastDotIndex); | |
| const extension = cleanName.substring(lastDotIndex); | |
| return `${baseName}-${platform}${extension}`; | |
| } else { | |
| return `${cleanName}-${platform}`; | |
| } | |
| } | |
| } | |
| // Process each asset | |
| for (const asset of release.assets) { | |
| console.log(`Processing asset: ${asset.name}`); | |
| const platform = detectPlatform(asset.name); | |
| if (platform) { | |
| // Check if the file already has the correct platform identifier | |
| if (asset.name.includes(`-${platform}`)) { | |
| console.log(`Asset ${asset.name} already has correct platform identifier`); | |
| continue; | |
| } | |
| const newName = generateCleanName(asset.name, platform); | |
| console.log(`Renaming: ${asset.name} -> ${newName}`); | |
| try { | |
| await github.rest.repos.updateReleaseAsset({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| asset_id: asset.id, | |
| name: newName | |
| }); | |
| console.log(`Successfully renamed asset to: ${newName}`); | |
| } catch (error) { | |
| console.error(`Failed to rename asset ${asset.name}:`, error); | |
| } | |
| } else { | |
| console.log(`Skipping ${asset.name} - could not detect platform`); | |
| } | |
| } | |
| publish-release: | |
| permissions: | |
| contents: write | |
| runs-on: ubuntu-latest | |
| needs: [create-release, build-tauri, rename-assets] | |
| steps: | |
| - name: publish release | |
| id: publish-release | |
| uses: actions/github-script@v7 | |
| env: | |
| release_id: ${{ needs.create-release.outputs.release_id }} | |
| with: | |
| script: | | |
| github.rest.repos.updateRelease({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| release_id: process.env.release_id, | |
| draft: false, | |
| prerelease: false | |
| }) |