name: 'publish' # on: # push: # tags: # - 'v*' jobs: publish-tauri: permissions: contents: write strategy: fail-fast: false matrix: include: - platform: 'macos-latest' # for Arm based macs (M1 and above). args: '--target aarch64-apple-darwin' - platform: 'macos-latest' # for Intel based macs. args: '--target x86_64-apple-darwin' - platform: 'ubuntu-22.04' args: '' - platform: 'windows-latest' args: '' runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v4 - name: install dependencies (ubuntu only) if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above. run: | sudo apt-get update sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf # 添加 macOS 依赖安装,包括 sharp 需要的构建工具 - name: install dependencies (macos only) if: matrix.platform == 'macos-latest' run: | # 安装 sharp 需要的构建工具和库 brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman # 设置 pkg-config 路径 echo "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/homebrew/lib/pkgconfig" >> $GITHUB_ENV # 新增 pnpm/action-setup 来安装 pnpm - name: setup pnpm uses: pnpm/action-setup@v3 with: version: 8 # 你可以在此指定 pnpm 的版本 # 修改 setup-node 的缓存为 pnpm - name: setup node uses: actions/setup-node@v4 with: node-version: lts/* cache: 'pnpm' # 设置 Python 环境以解决 sharp 依赖问题 - name: setup python uses: actions/setup-python@v4 with: python-version: '3.11' # 使用 3.11 版本以确保 distutils 可用 # 安装 setuptools 以提供 distutils - name: install setuptools run: pip install setuptools # 设置 sharp 构建环境变量 - name: setup sharp build environment if: matrix.platform == 'macos-latest' run: | echo "SHARP_IGNORE_GLOBAL_LIBVIPS=1" >> $GITHUB_ENV echo "npm_config_arch=${{ matrix.args == '--target aarch64-apple-darwin' && 'arm64' || 'x64' }}" >> $GITHUB_ENV - name: install Rust stable uses: dtolnay/rust-toolchain@stable with: # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds. targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} - name: Rust cache uses: swatinem/rust-cache@v2 with: workspaces: './src-tauri -> target' # 缓存 node_modules 以加速构建 - name: cache node_modules uses: actions/cache@v3 with: path: node_modules key: ${{ matrix.platform }}-node-modules-${{ hashFiles('pnpm-lock.yaml') }} restore-keys: | ${{ matrix.platform }}-node-modules- # 修改依赖安装命令为 pnpm install - name: install frontend dependencies # If you don't have `beforeBuildCommand` configured you may want to build your frontend here too. run: pnpm install - uses: tauri-apps/tauri-action@v0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tagName: app-${{ github.ref_name }} releaseName: 'App ${{ github.ref_name }}' releaseBody: 'See the assets to download this version and install.' releaseDraft: true prerelease: false args: ${{ matrix.args }}