name: Build & Package on: workflow_dispatch: inputs: platform: description: "Target platform" required: true default: "all" type: choice options: - all - windows - macos - linux push: tags: - "v*" permissions: contents: write jobs: build-windows: if: ${{ github.event_name == 'push' || inputs.platform == 'all' || inputs.platform == 'windows' }} runs-on: windows-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 cache: npm - name: Install dependencies run: npm ci - name: Build Electron app run: npm run electron:build - name: Package for Windows run: npx electron-builder --win --config electron-builder.yml --publish never - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: build-windows path: | release/*.exe release/*.exe.blockmap release/latest.yml retention-days: 3 build-macos: if: ${{ github.event_name == 'push' || inputs.platform == 'all' || inputs.platform == 'macos' }} runs-on: macos-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 cache: npm - name: Install dependencies run: npm ci - name: Build Electron app run: npm run electron:build - name: Package for macOS (x64 + arm64) env: CSC_IDENTITY_AUTO_DISCOVERY: "false" run: npx electron-builder --mac --config electron-builder.yml --publish never - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: build-macos path: | release/*.dmg release/*.dmg.blockmap release/*.zip release/*.zip.blockmap release/latest-mac.yml retention-days: 3 build-linux: if: ${{ github.event_name == 'push' || inputs.platform == 'all' || inputs.platform == 'linux' }} runs-on: ubuntu-latest strategy: matrix: arch: [x64, arm64] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 cache: npm - name: Install dependencies run: npm ci - name: Build Electron app run: npm run electron:build - name: Package for Linux (${{ matrix.arch }}) run: npx electron-builder --linux --${{ matrix.arch }} --config electron-builder.yml --publish never - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: build-linux-${{ matrix.arch }} path: | release/*.AppImage release/*.deb release/*.rpm release/latest-linux*.yml retention-days: 3 release: if: ${{ always() && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && !contains(needs.*.result, 'cancelled') }} needs: [build-windows, build-macos, build-linux] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Download all artifacts uses: actions/download-artifact@v4 with: path: artifacts merge-multiple: true - name: List artifacts run: find artifacts -type f | sort - name: Get version and previous tag id: meta run: | VERSION=${GITHUB_REF_NAME#v} echo "version=$VERSION" >> "$GITHUB_OUTPUT" PREV_TAG=$(git tag --sort=-creatordate | grep '^v' | sed -n '2p' || echo "") echo "prev_tag=$PREV_TAG" >> "$GITHUB_OUTPUT" - name: Generate changelog id: changelog run: | PREV_TAG="${{ steps.meta.outputs.prev_tag }}" if [ -n "$PREV_TAG" ]; then RANGE="${PREV_TAG}..HEAD" else RANGE="HEAD" fi { echo "changelog<> "$GITHUB_OUTPUT" - name: Create release and upload assets env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | VERSION="${{ steps.meta.outputs.version }}" PREV_TAG="${{ steps.meta.outputs.prev_tag }}" cat > release-notes.md << 'NOTES_EOF' ## Downloads **Windows** - **CodePilot Setup ${{ steps.meta.outputs.version }}.exe** — Windows installer (x64 + arm64) **macOS** - **CodePilot-${{ steps.meta.outputs.version }}-arm64.dmg** — macOS Apple Silicon (M1/M2/M3/M4) - **CodePilot-${{ steps.meta.outputs.version }}-x64.dmg** — macOS Intel **Linux** - **AppImage / deb / rpm** — x64 and arm64 ## Installation **Windows**: Download the exe installer, double-click to install. **macOS**: 1. Download the DMG for your chip architecture 2. Open the DMG, drag CodePilot into Applications 3. If you see a security prompt on first launch, go to **System Settings > Privacy & Security** and click "Open Anyway" 4. Configure your Anthropic API Key in Settings **Linux**: Run the AppImage directly, or install via deb/rpm package. ## Requirements - Windows 10+ / macOS 12.0+ / Linux (glibc 2.31+) - Anthropic API Key or `ANTHROPIC_API_KEY` environment variable - Claude Code CLI recommended for code features ## Changelog NOTES_EOF if [ -n "$PREV_TAG" ]; then echo "" >> release-notes.md echo "| Commit | Description |" >> release-notes.md echo "|--------|-------------|" >> release-notes.md cat >> release-notes.md << 'CHANGELOG_INLINE_EOF' ${{ steps.changelog.outputs.changelog }} CHANGELOG_INLINE_EOF fi # Collect all release files (handle filenames with spaces) FILES=() while IFS= read -r f; do FILES+=("$f") done < <(find artifacts -type f \( -name "*.dmg" -o -name "*.zip" -o -name "*.exe" -o -name "*.AppImage" -o -name "*.deb" -o -name "*.rpm" -o -name "*.blockmap" -o -name "*.yml" \) | sort) # Create release and upload all assets in one shot gh release create "${GITHUB_REF_NAME}" \ --title "CodePilot v${VERSION}" \ --notes-file release-notes.md \ --latest \ "${FILES[@]}"