update runtime detection #1
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 | ||
|
Check failure on line 1 in .github/workflows/build.yml
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| tags: | ||
| - "v*" | ||
| workflow_dispatch: | ||
| inputs: | ||
| platform: | ||
| description: "Platform to build" | ||
| required: true | ||
| default: "all" | ||
| type: choice | ||
| options: | ||
| - all | ||
| - linux | ||
| - windows | ||
| - macos-intel | ||
| - macos-arm64 | ||
| release: | ||
| description: "Create a release after build" | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
| env: | ||
| CARGO_INCREMENTAL: 0 | ||
| RUST_BACKTRACE: short | ||
| jobs: | ||
| build: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| # Linux x86_64 | ||
| - platform: linux | ||
| os: ubuntu-22.04 | ||
| rust_target: x86_64-unknown-linux-gnu | ||
| tauri_target: x86_64-unknown-linux-gnu | ||
| bun_target: bun-linux-x64 | ||
| name: linux-x86_64 | ||
| # Windows x86_64 | ||
| - platform: windows | ||
| os: windows-latest | ||
| rust_target: x86_64-pc-windows-msvc | ||
| tauri_target: x86_64-pc-windows-msvc | ||
| bun_target: bun-windows-x64 | ||
| name: windows-x86_64 | ||
| # macOS Intel | ||
| - platform: macos-intel | ||
| os: macos-latest | ||
| rust_target: x86_64-apple-darwin | ||
| tauri_target: x86_64-apple-darwin | ||
| bun_target: bun-darwin-x64 | ||
| name: macos-intel | ||
| # macOS Apple Silicon | ||
| - platform: macos-arm64 | ||
| os: macos-latest | ||
| rust_target: aarch64-apple-darwin | ||
| tauri_target: aarch64-apple-darwin | ||
| bun_target: bun-darwin-arm64 | ||
| name: macos-arm64 | ||
| runs-on: ${{ matrix.os }} | ||
| # Skip this job if platform doesn't match the input (for workflow_dispatch) | ||
| if: | | ||
| github.event_name != 'workflow_dispatch' || | ||
| github.event.inputs.platform == 'all' || | ||
| github.event.inputs.platform == matrix.platform | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Install dependencies (Linux) | ||
| if: matrix.platform == 'linux' | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 9 | ||
| - name: Setup Bun | ||
| uses: oven-sh/setup-bun@v2 | ||
| with: | ||
| bun-version: latest | ||
| - name: Get pnpm store directory | ||
| shell: bash | ||
| run: | | ||
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
| - name: Setup pnpm cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ${{ env.STORE_PATH }} | ||
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pnpm-store- | ||
| - name: Setup Rust | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| targets: ${{ matrix.rust_target }} | ||
| - name: Setup Rust cache | ||
| uses: swatinem/rust-cache@v2 | ||
| with: | ||
| workspaces: "./src-tauri -> target" | ||
| shared-key: ${{ matrix.name }} | ||
| - name: Install frontend dependencies | ||
| run: pnpm install | ||
| - name: Build API sidecar (Unix) | ||
| if: matrix.platform != 'windows' | ||
| shell: bash | ||
| run: | | ||
| cd src-api | ||
| mkdir -p dist | ||
| bun build src/index.ts --compile --target=${{ matrix.bun_target }} --outfile dist/workany-api-${{ matrix.rust_target }} | ||
| - name: Build API sidecar (Windows) | ||
| if: matrix.platform == 'windows' | ||
| shell: bash | ||
| run: | | ||
| cd src-api | ||
| mkdir -p dist | ||
| bun build src/index.ts --compile --target=${{ matrix.bun_target }} --outfile dist/workany-api-${{ matrix.rust_target }}.exe | ||
| - name: Build Tauri app | ||
| uses: tauri-apps/tauri-action@v0 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| # macOS signing and notarization (only when secrets are configured) | ||
| APPLE_CERTIFICATE: ${{ startsWith(matrix.platform, 'macos') && secrets.APPLE_CERTIFICATE || '' }} | ||
| APPLE_CERTIFICATE_PASSWORD: ${{ startsWith(matrix.platform, 'macos') && secrets.APPLE_CERTIFICATE_PASSWORD || '' }} | ||
| APPLE_SIGNING_IDENTITY: ${{ startsWith(matrix.platform, 'macos') && secrets.APPLE_SIGNING_IDENTITY || '' }} | ||
| APPLE_ID: ${{ startsWith(matrix.platform, 'macos') && secrets.APPLE_ID || '' }} | ||
| APPLE_PASSWORD: ${{ startsWith(matrix.platform, 'macos') && secrets.APPLE_PASSWORD || '' }} | ||
| APPLE_TEAM_ID: ${{ startsWith(matrix.platform, 'macos') && secrets.APPLE_TEAM_ID || '' }} | ||
| with: | ||
| args: --target ${{ matrix.tauri_target }} | ||
| - name: Upload artifacts (Linux) | ||
| if: matrix.platform == 'linux' | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: WorkAny-${{ matrix.name }} | ||
| path: | | ||
| src-tauri/target/${{ matrix.tauri_target }}/release/bundle/deb/*.deb | ||
| src-tauri/target/${{ matrix.tauri_target }}/release/bundle/rpm/*.rpm | ||
| src-tauri/target/${{ matrix.tauri_target }}/release/bundle/appimage/*.AppImage | ||
| if-no-files-found: ignore | ||
| - name: Upload artifacts (Windows) | ||
| if: matrix.platform == 'windows' | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: WorkAny-${{ matrix.name }} | ||
| path: | | ||
| src-tauri/target/${{ matrix.tauri_target }}/release/bundle/msi/*.msi | ||
| src-tauri/target/${{ matrix.tauri_target }}/release/bundle/nsis/*.exe | ||
| if-no-files-found: ignore | ||
| - name: Upload artifacts (macOS) | ||
| if: startsWith(matrix.platform, 'macos') | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: WorkAny-${{ matrix.name }} | ||
| path: | | ||
| src-tauri/target/${{ matrix.tauri_target }}/release/bundle/dmg/*.dmg | ||
| src-tauri/target/${{ matrix.tauri_target }}/release/bundle/macos/*.app | ||
| if-no-files-found: ignore | ||
| release: | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.release == 'true' | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Download all artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| path: artifacts | ||
| - name: Display structure of downloaded files | ||
| run: ls -R artifacts | ||
| - name: Create Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| draft: true | ||
| generate_release_notes: true | ||
| files: | | ||
| artifacts/**/*.deb | ||
| artifacts/**/*.rpm | ||
| artifacts/**/*.AppImage | ||
| artifacts/**/*.msi | ||
| artifacts/**/*.exe | ||
| artifacts/**/*.dmg | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||