name: Release on: push: tags: - "v[0-9]+.[0-9]+.[0-9]+" permissions: contents: write actions: write jobs: build: uses: ./.github/workflows/build-ci.yml release: name: 打包 & 发布 needs: build runs-on: windows-latest if: ${{ github.event_name == 'push' }} steps: - name: 检出代码 uses: actions/checkout@v4 - name: 获取版本号和微信版本号 shell: pwsh run: | $version_full = (Select-String -Path "WeChatFerry/spy/spy.rc" -Pattern 'VALUE "FileVersion", "(.*)"').Matches.Groups[1].Value.Trim() $wechat_version = (Select-String -Path "WeChatFerry/spy/spy.rc" -Pattern 'VALUE "ProductVersion", "(.*)"').Matches.Groups[1].Value.Trim() $version = $version_full -replace '(\d+\.\d+\.\d+)\.\d+', '$1' echo "version=$version" >> $env:GITHUB_ENV echo "wechat_version=$wechat_version" >> $env:GITHUB_ENV echo "Program Version: $version" echo "WeChat Version: $wechat_version" - name: 打包输出文件及下载 WeChat 安装包 shell: pwsh run: | # 在根目录创建 tmp New-Item -ItemType Directory -Force -Path tmp # Release 版的 spy.dll 和 sdk.dll $rel = "WeChatFerry/WeChatFerry/x64/Release" # Debug 版的 spy_debug.dll $dbg = "WeChatFerry/WeChatFerry/x64/Debug" # 项目根的 DISCLAIMER.md $md = "WeChatFerry/WeChatFerry/DISCLAIMER.md" Compress-Archive ` -Path "$rel/spy.dll","$rel/sdk.dll","$dbg/spy_debug.dll",$md ` -DestinationPath "tmp/v${{ env.version }}.zip" # 下载对应版本微信安装包 Invoke-WebRequest ` -Uri "https://github.com/tom-snow/wechat-windows-versions/releases/download/v${{ env.wechat_version }}/WeChatSetup-${{ env.wechat_version }}.exe" ` -OutFile "tmp/WeChatSetup-${{ env.wechat_version }}.exe" - name: 列出待发布文件 shell: pwsh run: Get-ChildItem -Path tmp -Recurse - name: 发布到 GitHub Releases uses: ncipollo/release-action@main with: name: v${{ env.version }} tag: v${{ env.version }} token: ${{ secrets.GITHUB_TOKEN }} allowUpdates: true artifacts: "tmp/*" body: | 程序版本:`v${{ env.version }}` 配套微信版本:`${{ env.wechat_version }}` [📖 Python 文档](https://wechatferry.readthedocs.io/)