WeChatFerry/.github/workflows/release.yml
2025-04-30 02:41:43 +08:00

68 lines
2.3 KiB
YAML

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
# 压缩根目录下 Out 中的产物
Compress-Archive `
-Path "WeChatFerry/Out/sdk.dll","WeChatFerry/Out/spy.dll","WeChatFerry/Out/spy_debug.dll","WeChatFerry/Out/DISCLAIMER.md" `
-DestinationPath "tmp/v${{ env.version }}.zip"
# 下载对应 WeChat 安装包
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/)