Merge pull request #2 from variableway/feature/executable-tutorial #2
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: Executable Tutorial CI/CD | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'apps/desktop/**' | |
| - 'packages/**' | |
| - '.github/workflows/executable-tutorial.yml' | |
| pull_request: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'apps/desktop/**' | |
| - 'packages/**' | |
| workflow_dispatch: | |
| inputs: | |
| task: | |
| description: 'Task to execute' | |
| required: true | |
| default: 'build' | |
| type: choice | |
| options: | |
| - build | |
| - test | |
| - lint | |
| - release | |
| env: | |
| CARGO_TERM_COLOR: always | |
| NODE_VERSION: '20' | |
| jobs: | |
| # 代码检查和测试 | |
| check: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| - name: Setup Rust | |
| uses: dtolnay/rust-action@stable | |
| - name: Install dependencies | |
| run: | | |
| npm ci | |
| cd apps/desktop && npm ci | |
| - name: Run linter | |
| run: | | |
| cd apps/desktop | |
| npm run lint | |
| continue-on-error: true | |
| - name: Run tests | |
| run: | | |
| cd apps/desktop | |
| npm run test | |
| continue-on-error: true | |
| # 构建桌面应用 | |
| build: | |
| needs: check | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| args: '--target aarch64-apple-darwin' | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| args: '--target x86_64-apple-darwin' | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| args: '' | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| args: '' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| - name: Setup Rust | |
| uses: dtolnay/rust-action@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install Linux dependencies | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf | |
| - name: Install dependencies | |
| run: | | |
| npm ci | |
| cd apps/desktop && npm ci | |
| - name: Build Tauri app | |
| run: | | |
| cd apps/desktop/src-tauri | |
| cargo build --release ${{ matrix.args }} | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: executable-tutorial-${{ matrix.target }} | |
| path: | | |
| apps/desktop/src-tauri/target/release/bundle/**/*.dmg | |
| apps/desktop/src-tauri/target/release/bundle/**/*.app | |
| apps/desktop/src-tauri/target/release/bundle/**/*.exe | |
| apps/desktop/src-tauri/target/release/bundle/**/*.msi | |
| apps/desktop/src-tauri/target/release/bundle/**/*.deb | |
| apps/desktop/src-tauri/target/release/bundle/**/*.AppImage | |
| # 发布版本 | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| files: artifacts/**/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |