Add CI/CD and release workflow with changesets #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: Release | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| env: | ||
| CARGO_TERM_COLOR: always | ||
| jobs: | ||
| # ───────────────────────────────────────────────────────────── | ||
| # Changesets: Version management and release PR | ||
| # ───────────────────────────────────────────────────────────── | ||
| changesets: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| published: ${{ steps.changesets.outputs.published }} | ||
| publishedPackages: ${{ steps.changesets.outputs.publishedPackages }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 9 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: 'pnpm' | ||
| - run: pnpm install --frozen-lockfile | ||
| - name: Create Release PR or Publish | ||
| id: changesets | ||
| uses: changesets/action@v1 | ||
| with: | ||
| title: 'chore: version packages' | ||
| commit: 'chore: version packages' | ||
| version: pnpm changeset version | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| # ───────────────────────────────────────────────────────────── | ||
| # Build and Release: Triggered when changesets publishes | ||
| # ───────────────────────────────────────────────────────────── | ||
| build-release: | ||
| needs: changesets | ||
| if: needs.changesets.outputs.published == 'true' | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - os: ubuntu-latest | ||
| target: x86_64-unknown-linux-gnu | ||
| artifact: linux | ||
| - os: windows-latest | ||
| target: x86_64-pc-windows-msvc | ||
| artifact: windows | ||
| - os: macos-latest | ||
| target: aarch64-apple-darwin | ||
| artifact: macos-arm | ||
| - os: macos-13 | ||
| target: x86_64-apple-darwin | ||
| artifact: macos-intel | ||
| runs-on: ${{ matrix.os }} | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| targets: ${{ matrix.target }} | ||
| - uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| key: ${{ matrix.target }}-release | ||
| - uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 9 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: 'pnpm' | ||
| - name: Install Linux deps | ||
| if: matrix.os == 'ubuntu-latest' | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libsecret-1-dev | ||
| - run: pnpm install --frozen-lockfile | ||
| - name: Build Tauri app | ||
| uses: tauri-apps/tauri-action@v0 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} | ||
| TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} | ||
| with: | ||
| tagName: v__VERSION__ | ||
| releaseName: 'McpMux v__VERSION__' | ||
| releaseBody: 'See the changelog for details.' | ||
| releaseDraft: false | ||
| prerelease: false | ||
| # ───────────────────────────────────────────────────────────── | ||
| # Nightly: Build on every push (no release) | ||
| # ───────────────────────────────────────────────────────────── | ||
| nightly: | ||
| if: github.event_name == 'push' && !contains(github.event.head_commit.message, 'chore: version packages') | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - os: ubuntu-latest | ||
| target: x86_64-unknown-linux-gnu | ||
| - os: windows-latest | ||
| target: x86_64-pc-windows-msvc | ||
| - os: macos-latest | ||
| target: aarch64-apple-darwin | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| targets: ${{ matrix.target }} | ||
| - uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| key: ${{ matrix.target }}-nightly | ||
| - uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 9 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: 'pnpm' | ||
| - name: Install Linux deps | ||
| if: matrix.os == 'ubuntu-latest' | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libsecret-1-dev | ||
| - run: pnpm install --frozen-lockfile | ||
| - run: pnpm build | ||
| env: | ||
| TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} | ||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: build-${{ matrix.target }} | ||
| path: | | ||
| target/release/bundle/**/* | ||
| retention-days: 7 | ||