|
| 1 | +name: Desktop Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, master, feat/desktop-branch ] |
| 6 | + tags: |
| 7 | + - 'v*.*.*-*' # prerelease: v0.1.0-beta.1 |
| 8 | + - 'v[0-9]*.[0-9]*.[0-9]*' # release: v0.1.0 (纯版本号) |
| 9 | + paths: |
| 10 | + - 'desktop/**' |
| 11 | + - '.github/workflows/desktop-build.yml' |
| 12 | + pull_request: |
| 13 | + branches: [ main, master, feat/desktop-branch ] |
| 14 | + paths: |
| 15 | + - 'desktop/**' |
| 16 | + - '.github/workflows/desktop-build.yml' |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: desktop-${{ github.ref }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +jobs: |
| 24 | + build: |
| 25 | + name: Desktop ${{ matrix.platform }} (${{ matrix.arch }}) |
| 26 | + runs-on: ${{ matrix.os }} |
| 27 | + strategy: |
| 28 | + fail-fast: false |
| 29 | + matrix: |
| 30 | + include: |
| 31 | + - os: macos-14 |
| 32 | + platform: mac |
| 33 | + arch: arm64 |
| 34 | + python: python3.10 |
| 35 | + asr: funasr-onnx |
| 36 | + artifact_path: | |
| 37 | + desktop/release/*.dmg |
| 38 | + - os: windows-latest |
| 39 | + platform: win |
| 40 | + arch: x64 |
| 41 | + python: python |
| 42 | + asr: funasr-onnx |
| 43 | + artifact_path: | |
| 44 | + desktop/release/*.exe |
| 45 | +
|
| 46 | + defaults: |
| 47 | + run: |
| 48 | + shell: bash |
| 49 | + working-directory: desktop |
| 50 | + |
| 51 | + steps: |
| 52 | + - name: Checkout repository |
| 53 | + uses: actions/checkout@v4 |
| 54 | + with: |
| 55 | + fetch-depth: 0 |
| 56 | + |
| 57 | + - name: Setup pnpm |
| 58 | + uses: pnpm/action-setup@v4 |
| 59 | + with: |
| 60 | + version: 9 |
| 61 | + run_install: false |
| 62 | + |
| 63 | + - name: Setup Node.js |
| 64 | + uses: actions/setup-node@v4 |
| 65 | + with: |
| 66 | + node-version: 20 |
| 67 | + cache: pnpm |
| 68 | + cache-dependency-path: desktop/pnpm-lock.yaml |
| 69 | + |
| 70 | + - name: Setup Python |
| 71 | + uses: actions/setup-python@v5 |
| 72 | + with: |
| 73 | + python-version: '3.10' |
| 74 | + |
| 75 | + - name: Install dependencies |
| 76 | + run: pnpm install --frozen-lockfile |
| 77 | + |
| 78 | + - name: Prepare Python env for ASR backend |
| 79 | + working-directory: desktop |
| 80 | + run: pnpm run prepare:python |
| 81 | + |
| 82 | + - name: Print app version |
| 83 | + id: meta |
| 84 | + run: | |
| 85 | + node -e "const v=require('./package.json').version; console.log('app_version='+v)" >> "$GITHUB_OUTPUT" |
| 86 | +
|
| 87 | +
|
| 88 | + - name: Build desktop package |
| 89 | + env: |
| 90 | + PYTHON: ${{ matrix.python }} |
| 91 | + ASR_IMPL: ${{ matrix.asr }} |
| 92 | + 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) }} |
| 93 | + run: | |
| 94 | + if [ "${{ matrix.platform }}" = "mac" ]; then |
| 95 | + pnpm run build:mac -- --${{ matrix.arch }} |
| 96 | + else |
| 97 | + pnpm run build:win -- --${{ matrix.arch }} |
| 98 | + fi |
| 99 | +
|
| 100 | + - name: Upload artifacts |
| 101 | + uses: actions/upload-artifact@v4 |
| 102 | + with: |
| 103 | + name: livegalgame-desktop-${{ matrix.platform }}-${{ matrix.arch }}-v${{ steps.meta.outputs.app_version }} |
| 104 | + path: ${{ matrix.artifact_path }} |
| 105 | + if-no-files-found: error |
| 106 | + retention-days: 14 |
| 107 | + |
| 108 | + prerelease: |
| 109 | + name: Publish prerelease |
| 110 | + runs-on: ubuntu-latest |
| 111 | + needs: build |
| 112 | + if: | |
| 113 | + startsWith(github.ref, 'refs/tags/v') && |
| 114 | + contains(github.ref_name, '-') |
| 115 | + permissions: |
| 116 | + contents: write |
| 117 | + steps: |
| 118 | + - name: Checkout repository |
| 119 | + uses: actions/checkout@v4 |
| 120 | + |
| 121 | + - name: Download artifacts |
| 122 | + uses: actions/download-artifact@v4 |
| 123 | + with: |
| 124 | + path: dist |
| 125 | + |
| 126 | + - name: Create prerelease |
| 127 | + env: |
| 128 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 129 | + run: | |
| 130 | + gh release create "${GITHUB_REF_NAME}" \ |
| 131 | + --prerelease \ |
| 132 | + --title "${GITHUB_REF_NAME}" \ |
| 133 | + --notes "Prerelease ${GITHUB_REF_NAME}" |
| 134 | + # 处理带空格的文件名 |
| 135 | + find dist -type f -print0 | xargs -0 -I {} gh release upload "${GITHUB_REF_NAME}" "{}" --clobber |
| 136 | +
|
| 137 | + release: |
| 138 | + name: Publish release |
| 139 | + runs-on: ubuntu-latest |
| 140 | + needs: build |
| 141 | + if: | |
| 142 | + startsWith(github.ref, 'refs/tags/v') && |
| 143 | + !contains(github.ref_name, '-') |
| 144 | + permissions: |
| 145 | + contents: write |
| 146 | + steps: |
| 147 | + - name: Checkout repository |
| 148 | + uses: actions/checkout@v4 |
| 149 | + with: |
| 150 | + fetch-depth: 0 |
| 151 | + |
| 152 | + - name: Download artifacts |
| 153 | + uses: actions/download-artifact@v4 |
| 154 | + with: |
| 155 | + path: dist |
| 156 | + |
| 157 | + - name: Create release |
| 158 | + env: |
| 159 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 160 | + run: | |
| 161 | + gh release create "${GITHUB_REF_NAME}" \ |
| 162 | + --title "${GITHUB_REF_NAME}" \ |
| 163 | + --notes "Release ${GITHUB_REF_NAME}" |
| 164 | + # 处理带空格的文件名 |
| 165 | + find dist -type f -print0 | xargs -0 -I {} gh release upload "${GITHUB_REF_NAME}" "{}" --clobber |
0 commit comments