更新 maa-framework 依赖版本,支持 Win32InputMethod.Interception (#318) #1268
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 | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| branches: | |
| - "**" | |
| paths: | |
| - ".github/workflows/build.yml" | |
| - "src/**" | |
| - "src-tauri/**" | |
| - "package.json" | |
| - "pnpm-lock.yaml" | |
| - "vite.config.ts" | |
| pull_request: | |
| branches: | |
| - "**" | |
| paths: | |
| - ".github/workflows/build.yml" | |
| - "src/**" | |
| - "src-tauri/**" | |
| - "package.json" | |
| - "pnpm-lock.yaml" | |
| - "vite.config.ts" | |
| workflow_dispatch: | |
| jobs: | |
| meta: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| tag: ${{ steps.version.outputs.tag }} | |
| is-release: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Get version | |
| id: version | |
| run: | | |
| if [[ "${{ github.ref }}" == refs/tags/v* ]]; then | |
| VERSION="${GITHUB_REF#refs/tags/v}" | |
| TAG="${GITHUB_REF#refs/tags/}" | |
| else | |
| VERSION="0.0.0-dev" | |
| TAG="dev" | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| windows: | |
| needs: meta | |
| runs-on: windows-latest | |
| strategy: | |
| matrix: | |
| arch: [x86_64, aarch64] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 20 | |
| cache: "pnpm" | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.arch == 'x86_64' && 'x86_64-pc-windows-msvc' || 'aarch64-pc-windows-msvc' }} | |
| - name: Rust cache | |
| uses: swatinem/rust-cache@v2 | |
| with: | |
| workspaces: "src-tauri -> target" | |
| shared-key: "windows-${{ matrix.arch }}" | |
| cache-on-failure: true | |
| - name: Install frontend dependencies | |
| run: pnpm install | |
| - name: Update version | |
| shell: bash | |
| run: | | |
| VERSION="${{ needs.meta.outputs.version }}" | |
| # Update package.json | |
| sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$VERSION\"/" package.json | |
| # Update tauri.conf.json | |
| sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$VERSION\"/" src-tauri/tauri.conf.json | |
| # Update Cargo.toml (only the package version at line start, not dependency versions) | |
| sed -i "s/^version = \"[^\"]*\"/version = \"$VERSION\"/" src-tauri/Cargo.toml | |
| echo "Updated version to $VERSION" | |
| - name: Build Tauri app | |
| run: pnpm tauri build --no-bundle --target ${{ matrix.arch == 'x86_64' && 'x86_64-pc-windows-msvc' || 'aarch64-pc-windows-msvc' }} | |
| - name: Prepare artifacts | |
| shell: bash | |
| run: | | |
| mkdir -p install | |
| TARGET_DIR="src-tauri/target/${{ matrix.arch == 'x86_64' && 'x86_64-pc-windows-msvc' || 'aarch64-pc-windows-msvc' }}/release" | |
| cp -r "$TARGET_DIR/mxu.exe" install/ || true | |
| cp -r "$TARGET_DIR/mxu.pdb" install/ || true | |
| cp LICENSE README.md install/ || true | |
| ls -la install/ | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v6 | |
| if: always() | |
| with: | |
| name: MXU-win-${{ matrix.arch }}-${{ needs.meta.outputs.tag }} | |
| path: "install" | |
| linux: | |
| needs: meta | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| arch: [x86_64] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Install Linux dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 20 | |
| cache: "pnpm" | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Rust cache | |
| uses: swatinem/rust-cache@v2 | |
| with: | |
| workspaces: "src-tauri -> target" | |
| shared-key: "linux-${{ matrix.arch }}" | |
| cache-on-failure: true | |
| - name: Install frontend dependencies | |
| run: pnpm install | |
| - name: Update version | |
| run: | | |
| VERSION="${{ needs.meta.outputs.version }}" | |
| # Update package.json | |
| sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$VERSION\"/" package.json | |
| # Update tauri.conf.json | |
| sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$VERSION\"/" src-tauri/tauri.conf.json | |
| # Update Cargo.toml (only the package version at line start, not dependency versions) | |
| sed -i "s/^version = \"[^\"]*\"/version = \"$VERSION\"/" src-tauri/Cargo.toml | |
| echo "Updated version to $VERSION" | |
| - name: Build Tauri app | |
| run: pnpm tauri build --no-bundle | |
| - name: Prepare artifacts | |
| run: | | |
| mkdir -p install | |
| cp -r src-tauri/target/release/mxu install/ || true | |
| cp LICENSE README.md install/ || true | |
| ls -la install/ | |
| tar -czvf MXU-linux-${{ matrix.arch }}-${{ needs.meta.outputs.tag }}.tar.gz -C install . | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v6 | |
| if: always() | |
| with: | |
| name: MXU-linux-${{ matrix.arch }}-${{ needs.meta.outputs.tag }} | |
| path: "MXU-linux-${{ matrix.arch }}-${{ needs.meta.outputs.tag }}.tar.gz" | |
| macos: | |
| needs: meta | |
| runs-on: macos-latest | |
| strategy: | |
| matrix: | |
| arch: [x86_64, aarch64] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 20 | |
| cache: "pnpm" | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.arch == 'x86_64' && 'x86_64-apple-darwin' || 'aarch64-apple-darwin' }} | |
| - name: Rust cache | |
| uses: swatinem/rust-cache@v2 | |
| with: | |
| workspaces: "src-tauri -> target" | |
| shared-key: "macos-${{ matrix.arch }}" | |
| cache-on-failure: true | |
| - name: Install frontend dependencies | |
| run: pnpm install | |
| - name: Update version | |
| run: | | |
| VERSION="${{ needs.meta.outputs.version }}" | |
| # Update package.json | |
| sed -i '' "s/\"version\": \"[^\"]*\"/\"version\": \"$VERSION\"/" package.json | |
| # Update tauri.conf.json | |
| sed -i '' "s/\"version\": \"[^\"]*\"/\"version\": \"$VERSION\"/" src-tauri/tauri.conf.json | |
| # Update Cargo.toml (only the package version at line start, not dependency versions) | |
| sed -i '' "s/^version = \"[^\"]*\"/version = \"$VERSION\"/" src-tauri/Cargo.toml | |
| echo "Updated version to $VERSION" | |
| - name: Build Tauri app | |
| run: pnpm tauri build --no-bundle --target ${{ matrix.arch == 'x86_64' && 'x86_64-apple-darwin' || 'aarch64-apple-darwin' }} | |
| - name: Prepare artifacts | |
| run: | | |
| mkdir -p install | |
| cp -r src-tauri/target/${{ matrix.arch == 'x86_64' && 'x86_64-apple-darwin' || 'aarch64-apple-darwin' }}/release/mxu install/ || true | |
| cp LICENSE README.md install/ || true | |
| ls -la install/ | |
| tar -czvf MXU-macos-${{ matrix.arch }}-${{ needs.meta.outputs.tag }}.tar.gz -C install . | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v6 | |
| if: always() | |
| with: | |
| name: MXU-macos-${{ matrix.arch }}-${{ needs.meta.outputs.tag }} | |
| path: "MXU-macos-${{ matrix.arch }}-${{ needs.meta.outputs.tag }}.tar.gz" | |
| changelog: | |
| name: Generate changelog | |
| needs: meta | |
| runs-on: ubuntu-latest | |
| outputs: | |
| release_body: ${{ steps.git-cliff.outputs.content }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Generate a changelog | |
| uses: orhun/git-cliff-action@v4 | |
| id: git-cliff | |
| with: | |
| config: .github/cliff.toml | |
| args: -vv --latest --strip header | |
| env: | |
| OUTPUT: CHANGES.md | |
| GITHUB_REPO: ${{ github.repository }} | |
| release: | |
| if: ${{ needs.meta.outputs.is-release == 'true' }} | |
| needs: [meta, windows, linux, macos, changelog] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v6 | |
| with: | |
| path: artifacts | |
| - name: Package artifacts | |
| run: | | |
| cd artifacts | |
| for dir in */; do | |
| name="${dir%/}" | |
| cd "$name" | |
| # Linux and macOS artifacts are already tgz files, just move them | |
| if ls *.tar.gz 1> /dev/null 2>&1; then | |
| mv *.tar.gz ../ | |
| else | |
| # Windows artifacts need to be zipped | |
| zip -r "../${name}.zip" . | |
| fi | |
| cd .. | |
| done | |
| ls -la | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.meta.outputs.tag }} | |
| name: Release ${{ needs.meta.outputs.tag }} | |
| draft: false | |
| prerelease: false | |
| body: ${{ needs.changelog.outputs.release_body }} | |
| files: | | |
| artifacts/*.zip | |
| artifacts/*.tar.gz | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |