Build and Release #5
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*' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to release (e.g., 1.0.0)' | |
| required: false | |
| type: string | |
| jobs: | |
| build-macos: | |
| runs-on: macos-latest | |
| permissions: | |
| contents: write | |
| strategy: | |
| matrix: | |
| arch: [x64, arm64] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| target: ${{ matrix.arch == 'arm64' && 'aarch64-apple-darwin' || 'x86_64-apple-darwin' }} | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build native module | |
| run: | | |
| if [ "${{ matrix.arch }}" = "arm64" ]; then | |
| export CARGO_BUILD_TARGET=aarch64-apple-darwin | |
| else | |
| export CARGO_BUILD_TARGET=x86_64-apple-darwin | |
| fi | |
| npm run build:native | |
| env: | |
| CARGO_BUILD_TARGET: ${{ matrix.arch == 'arm64' && 'aarch64-apple-darwin' || 'x86_64-apple-darwin' }} | |
| - name: Build application | |
| run: | | |
| npm run build:ts | |
| npm run build:renderer | |
| - name: Package and publish | |
| run: | | |
| # Build and publish both zip and dmg with retries for dmg | |
| npx electron-builder --mac zip --${{ matrix.arch }} --publish always | |
| # DMG can be flaky on CI, retry up to 3 times | |
| for i in 1 2 3; do | |
| echo "DMG build attempt $i..." | |
| if npx electron-builder --mac dmg --${{ matrix.arch }} --publish always; then | |
| echo "DMG build succeeded on attempt $i" | |
| break | |
| fi | |
| if [ $i -eq 3 ]; then | |
| echo "DMG build failed after 3 attempts" | |
| exit 1 | |
| fi | |
| echo "Retrying in 10 seconds..." | |
| sleep 10 | |
| done | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |