build(release): 同步 0.1.3 版本入口 #9
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: windows-release-on-tag | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: windows-latest | |
| env: | |
| DEEPLX_URL: http://127.0.0.1:1188/translate | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.11" | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: desktop-shell/package-lock.json | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install pyinstaller | |
| python -m pip install -r requirements.txt | |
| - name: Install desktop-shell dependencies | |
| working-directory: desktop-shell | |
| run: npm ci | |
| - name: Build desktop-shell sidecars | |
| run: python scripts/build_desktop_shell_sidecars.py --python python | |
| - name: Run desktop-shell frontend tests | |
| working-directory: desktop-shell | |
| run: npm test | |
| - name: Build desktop-shell frontend dist | |
| working-directory: desktop-shell | |
| run: npm run build | |
| - name: Run desktop-shell Rust tests | |
| working-directory: desktop-shell | |
| run: npm run test:rust | |
| - name: Build desktop-shell Windows release | |
| working-directory: desktop-shell | |
| run: npm run tauri -- build | |
| - name: Run desktop-shell release smoke | |
| run: python scripts/smoke_desktop_shell_release.py --skip-build | |
| - name: Prepare release metadata | |
| id: release_meta | |
| shell: pwsh | |
| run: | | |
| $ErrorActionPreference = 'Stop' | |
| $desktopVersion = python -c "import json; package_version=json.load(open('desktop-shell/package.json', encoding='utf-8'))['version']; tauri_version=json.load(open('desktop-shell/src-tauri/tauri.conf.json', encoding='utf-8'))['version']; assert package_version == tauri_version, f'version mismatch package={package_version} tauri={tauri_version}'; print(tauri_version)" | |
| if (-not $desktopVersion) { | |
| throw 'failed to resolve desktop release version' | |
| } | |
| $releaseName = "WeChat Auto Shell Windows $desktopVersion" | |
| "desktop_version=$desktopVersion" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
| "release_name=$releaseName" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
| - name: Generate release checksums | |
| shell: pwsh | |
| env: | |
| DESKTOP_VERSION: ${{ steps.release_meta.outputs.desktop_version }} | |
| run: | | |
| $ErrorActionPreference = 'Stop' | |
| New-Item -ItemType Directory -Force -Path 'release-assets' | Out-Null | |
| $desktopVersion = $env:DESKTOP_VERSION | |
| if (-not $desktopVersion) { | |
| throw 'missing desktop release version' | |
| } | |
| $msiPath = Get-ChildItem 'desktop-shell/src-tauri/target/release/bundle/msi/*.msi' | Select-Object -First 1 -ExpandProperty FullName | |
| $setupPath = Get-ChildItem 'desktop-shell/src-tauri/target/release/bundle/nsis/*-setup.exe' | Select-Object -First 1 -ExpandProperty FullName | |
| if (-not $msiPath) { | |
| throw 'no public msi release asset found' | |
| } | |
| if (-not $setupPath) { | |
| throw 'no public setup.exe release asset found' | |
| } | |
| $releaseAssetsRoot = Resolve-Path 'release-assets' | |
| $publicReleaseAssetPaths = @( | |
| (Join-Path $releaseAssetsRoot "wechat-auto-shell-$desktopVersion-windows-x64.msi"), | |
| (Join-Path $releaseAssetsRoot "wechat-auto-shell-$desktopVersion-windows-x64-setup.exe") | |
| ) | |
| Copy-Item -Force -Path $msiPath -Destination $publicReleaseAssetPaths[0] | |
| Copy-Item -Force -Path $setupPath -Destination $publicReleaseAssetPaths[1] | |
| $checksumLines = foreach ($path in ($publicReleaseAssetPaths | Sort-Object)) { | |
| $hash = (Get-FileHash -Algorithm SHA256 -Path $path).Hash.ToLower() | |
| "$hash $(Split-Path $path -Leaf)" | |
| } | |
| Set-Content -Path 'release-assets/SHA256SUMS.txt' -Value $checksumLines -Encoding utf8 | |
| - name: Upload workflow artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-build-assets-${{ github.ref_name }} | |
| if-no-files-found: error | |
| path: | | |
| desktop-shell/src-tauri/target/release/wechat-auto-shell.exe | |
| desktop-shell/src-tauri/target/release/wechat-auto-backend.exe | |
| desktop-shell/src-tauri/target/release/group_listener_worker.exe | |
| release-assets/*.msi | |
| release-assets/*-setup.exe | |
| release-assets/SHA256SUMS.txt | |
| - name: Publish GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: ${{ steps.release_meta.outputs.release_name }} | |
| generate_release_notes: true | |
| fail_on_unmatched_files: true | |
| prerelease: ${{ contains(github.ref_name, '-') }} | |
| files: | | |
| release-assets/*.msi | |
| release-assets/*-setup.exe | |
| release-assets/SHA256SUMS.txt |