diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..76dce43 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,90 @@ +name: CI + +on: + push: + branches: [main, feat/tauri-port] + pull_request: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-22.04] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v7 + + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy, rustfmt + + - uses: Swatinem/rust-cache@v2 + + - uses: actions/setup-node@v7 + with: + node-version: lts/* + cache: npm + + - name: Install Linux build prerequisites + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential curl wget file \ + libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev + + - run: npm ci + + - run: cargo fmt --check + + - run: cargo clippy --all-targets --locked -- -D warnings + + - run: cargo test --locked + + - run: npm run lint + + - run: npm test + + - run: npm run tauri build -- --no-bundle + + - name: Check the exe version resource + if: runner.os == 'Windows' + shell: pwsh + run: | + $match = Select-String -Path Cargo.toml -Pattern '^version\s*=\s*"([^"]+)"' | Select-Object -First 1 + $cargoVersion = $match.Matches.Groups[1].Value + $info = (Get-Item target/release/claude-code-usage-bubble.exe).VersionInfo + $info | Format-List ProductName, CompanyName, FileDescription, FileVersion, ProductVersion, LegalCopyright + if ($info.ProductVersion -ne $cargoVersion) { + Write-Error "ProductVersion '$($info.ProductVersion)' does not match Cargo.toml version '$cargoVersion'" + exit 1 + } + + - name: Upload the Windows exe + if: runner.os == 'Windows' + uses: actions/upload-artifact@v7 + with: + name: bubble-exe-${{ github.sha }} + path: target/release/claude-code-usage-bubble.exe + retention-days: 7 + if-no-files-found: error + + macos-check: + name: macos-latest (cargo check) + runs-on: macos-latest + steps: + - uses: actions/checkout@v7 + + - uses: dtolnay/rust-toolchain@stable + + - uses: Swatinem/rust-cache@v2 + + - run: cargo check --all-targets --locked