fix: make dev script cross-platform compatible #99
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: Desktop Build | |
| on: | |
| push: | |
| branches: [ main, master, feat/desktop-branch ] | |
| tags: | |
| - 'v*.*.*-*' # prerelease: v0.1.0-beta.1 | |
| - 'v[0-9]*.[0-9]*.[0-9]*' # release: v0.1.0 (纯版本号) | |
| paths: | |
| - 'desktop/**' | |
| - '.github/workflows/desktop-build.yml' | |
| pull_request: | |
| branches: [ main, master, feat/desktop-branch ] | |
| paths: | |
| - 'desktop/**' | |
| - '.github/workflows/desktop-build.yml' | |
| workflow_dispatch: | |
| concurrency: | |
| group: desktop-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| name: Desktop ${{ matrix.platform }} (${{ matrix.arch }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: macos-14 | |
| platform: mac | |
| arch: arm64 | |
| python: python3.10 | |
| asr: funasr-onnx | |
| artifact_path: | | |
| desktop/release/*.dmg | |
| - os: windows-latest | |
| platform: win | |
| arch: x64 | |
| python: python | |
| asr: funasr-onnx | |
| artifact_path: | | |
| desktop/release/*.exe | |
| defaults: | |
| run: | |
| shell: bash | |
| working-directory: desktop | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| run_install: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: pnpm | |
| cache-dependency-path: desktop/pnpm-lock.yaml | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Prepare Python env for ASR backend | |
| working-directory: desktop | |
| run: pnpm run prepare:python | |
| - name: Print app version | |
| id: meta | |
| run: | | |
| node -e "const v=require('./package.json').version; console.log('app_version='+v)" >> "$GITHUB_OUTPUT" | |
| - name: Build desktop package | |
| env: | |
| PYTHON: ${{ matrix.python }} | |
| ASR_IMPL: ${{ matrix.asr }} | |
| ASR_PYTHON_PATH: ${{ matrix.platform == 'win' && format('{0}/desktop/python-env/Scripts/python.exe', github.workspace) || format('{0}/desktop/python-env/bin/python3', github.workspace) }} | |
| run: | | |
| if [ "${{ matrix.platform }}" = "mac" ]; then | |
| pnpm run build:mac -- --${{ matrix.arch }} | |
| else | |
| pnpm run build:win -- --${{ matrix.arch }} | |
| fi | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: livegalgame-desktop-${{ matrix.platform }}-${{ matrix.arch }}-v${{ steps.meta.outputs.app_version }} | |
| path: ${{ matrix.artifact_path }} | |
| if-no-files-found: error | |
| retention-days: 14 | |
| prerelease: | |
| name: Publish prerelease | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: | | |
| startsWith(github.ref, 'refs/tags/v') && | |
| contains(github.ref_name, '-') | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| - name: Create prerelease | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release create "${GITHUB_REF_NAME}" \ | |
| --prerelease \ | |
| --title "${GITHUB_REF_NAME}" \ | |
| --notes "Prerelease ${GITHUB_REF_NAME}" | |
| # 处理带空格的文件名 | |
| find dist -type f -print0 | xargs -0 -I {} gh release upload "${GITHUB_REF_NAME}" "{}" --clobber | |
| release: | |
| name: Publish release | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: | | |
| startsWith(github.ref, 'refs/tags/v') && | |
| !contains(github.ref_name, '-') | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| - name: Create release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release create "${GITHUB_REF_NAME}" \ | |
| --title "${GITHUB_REF_NAME}" \ | |
| --notes "Release ${GITHUB_REF_NAME}" | |
| # 处理带空格的文件名 | |
| find dist -type f -print0 | xargs -0 -I {} gh release upload "${GITHUB_REF_NAME}" "{}" --clobber |