fix(updater): correct channel names to match actual yml filenames in … #39
Workflow file for this run
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 and Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| include: | |
| - os: macos-latest | |
| platform: mac | |
| - os: windows-latest | |
| platform: win | |
| arch: x64 | |
| - os: windows-latest | |
| platform: win | |
| arch: arm64 | |
| - os: ubuntu-latest | |
| platform: linux | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| # 显式使用与 package.json 中一致的 pnpm 版本 | |
| version: 9.15.0 | |
| run_install: false | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Clean previous build artifacts | |
| shell: bash | |
| run: | | |
| rm -rf dist || true | |
| - name: Build for ${{ matrix.platform }} ${{ matrix.arch }} | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.platform }}" = "win" ] && [ -n "${{ matrix.arch }}" ]; then | |
| # Windows: build specific architecture | |
| pnpm vite build && pnpm electron-builder --win --${{ matrix.arch }} --publish never | |
| else | |
| pnpm electron:build:${{ matrix.platform }} | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Normalize Windows update metadata | |
| if: matrix.platform == 'win' && matrix.arch != '' | |
| shell: bash | |
| run: | | |
| # Rename latest.yml to latest-{arch}.yml | |
| if [ -f "dist/latest.yml" ]; then | |
| mv dist/latest.yml dist/latest-${{ matrix.arch }}.yml | |
| echo "Renamed latest.yml to latest-${{ matrix.arch }}.yml" | |
| fi | |
| # Ensure latest-{arch}.yml points to the arch-specific installer | |
| node -e "const fs=require('fs');const path=require('path');const arch='${{ matrix.arch }}';const yml=path.join('dist','latest-'+arch+'.yml');if(!fs.existsSync(yml)) process.exit(0);const exe=fs.readdirSync('dist').find(f=>f.startsWith('PromptHub-Setup-')&&f.endsWith('-'+arch+'.exe'));if(!exe) process.exit(0);let data=fs.readFileSync(yml,'utf8');data=data.replace(/PromptHub-Setup-[0-9.]+\\.exe\\.blockmap/g, exe+'.blockmap').replace(/PromptHub-Setup-[0-9.]+\\.exe/g, exe);fs.writeFileSync(yml,data);console.log('Patched '+yml+' -> '+exe);" | |
| # Keep latest.yml as x64 alias for compatibility | |
| if [ "${{ matrix.arch }}" = "x64" ] && [ -f "dist/latest-x64.yml" ]; then | |
| cp dist/latest-x64.yml dist/latest.yml | |
| echo "Copied latest-x64.yml to latest.yml" | |
| fi | |
| # Remove duplicate NSIS blockmap without arch (prevents release upload errors) | |
| shopt -s nullglob | |
| for file in dist/*.exe.blockmap; do | |
| case "$file" in | |
| *-x64.exe.blockmap|*-arm64.exe.blockmap) ;; | |
| *) rm -f "$file" ;; | |
| esac | |
| done | |
| - name: Remove debug files | |
| shell: bash | |
| run: | | |
| # 删除 builder-debug.yml | |
| find dist -name "builder-debug.yml" -delete || true | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.platform }}-${{ matrix.arch || 'default' }}-build | |
| path: | | |
| dist/*.dmg | |
| dist/*.zip | |
| dist/*-x64.exe | |
| dist/*-arm64.exe | |
| dist/*.AppImage | |
| dist/*.deb | |
| dist/*.blockmap | |
| dist/latest*.yml | |
| if-no-files-found: ignore | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Deduplicate release assets | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| declare -A seen | |
| while IFS= read -r -d '' file; do | |
| base=$(basename "$file") | |
| if [[ -n "${seen[$base]:-}" ]]; then | |
| keep="${seen[$base]}" | |
| if [[ "$base" == *-x64.exe* ]] && [[ "$file" == *"win-x64-build"* ]] && [[ "$keep" != *"win-x64-build"* ]]; then | |
| rm -f "$keep" | |
| seen[$base]="$file" | |
| continue | |
| fi | |
| if [[ "$base" == *-arm64.exe* ]] && [[ "$file" == *"win-arm64-build"* ]] && [[ "$keep" != *"win-arm64-build"* ]]; then | |
| rm -f "$keep" | |
| seen[$base]="$file" | |
| continue | |
| fi | |
| rm -f "$file" | |
| else | |
| seen[$base]="$file" | |
| fi | |
| done < <(find artifacts -type f -print0) | |
| - name: Set release version | |
| shell: bash | |
| run: | | |
| echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV" | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| artifacts/**/PromptHub-*-x64.dmg | |
| artifacts/**/PromptHub-*-arm64.dmg | |
| artifacts/**/PromptHub-Setup-*-x64.exe | |
| artifacts/**/PromptHub-Setup-*-arm64.exe | |
| artifacts/**/PromptHub-*-x64.AppImage | |
| artifacts/**/prompthub_*_amd64.deb | |
| artifacts/**/PromptHub-*.zip | |
| artifacts/**/latest*.yml | |
| artifacts/**/*.blockmap | |
| draft: false | |
| prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alpha') }} | |
| generate_release_notes: true | |
| body: | | |
| ## 📦 下载安装 | |
| | 平台 | 下载 | | |
| |------|------| | |
| | Windows | [](https://github.com/legeling/PromptHub/releases/latest/download/PromptHub-Setup-${{ env.VERSION }}-x64.exe) [](https://github.com/legeling/PromptHub/releases/latest/download/PromptHub-Setup-${{ env.VERSION }}-arm64.exe) | | |
| | macOS | [](https://github.com/legeling/PromptHub/releases/latest/download/PromptHub-${{ env.VERSION }}-arm64.dmg) [](https://github.com/legeling/PromptHub/releases/latest/download/PromptHub-${{ env.VERSION }}-x64.dmg) | | |
| | Linux | [](https://github.com/legeling/PromptHub/releases/latest/download/PromptHub-${{ env.VERSION }}-x64.AppImage) [](https://github.com/legeling/PromptHub/releases/latest/download/prompthub_${{ env.VERSION }}_amd64.deb) | | |
| ### ⚠️ macOS 首次启动 | |
| 如果提示"无法打开"或"已损坏",请在终端执行: | |
| ```bash | |
| sudo xattr -rd com.apple.quarantine /Applications/PromptHub.app | |
| ``` | |
| --- | |
| ## 🔄 本次更新 | |
| 详细更新日志请查看 [更新日志](https://github.com/legeling/PromptHub#-更新日志) | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |