Skip to content

Commit e1b9aa1

Browse files
authored
Merge branch 'lich0821:master' into master
2 parents f724230 + a91f4f7 commit e1b9aa1

5 files changed

Lines changed: 142 additions & 115 deletions

File tree

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ charset = utf-8-bom
44
trim_trailing_whitespace = true
55
insert_final_newline = true
66
indent_style = space
7-
indent_size = 4
7+
indent_size = 4
8+
9+
[*.{yml,yaml}]
10+
indent_size = 2

.github/workflows/Build-WeChatFerry.yml

Lines changed: 0 additions & 114 deletions
This file was deleted.

.github/workflows/build-ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build CI
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
build:
8+
name: 编译校验
9+
runs-on: windows-latest
10+
steps:
11+
- name: 检出代码
12+
uses: actions/checkout@v4
13+
14+
- name: 获取版本号和微信版本号
15+
if: ${{ github.event_name == 'push' }}
16+
run: |
17+
$version_full = (Select-String -Path "WeChatFerry/spy/spy.rc" -Pattern 'VALUE "FileVersion", "(.*)"').Matches.Groups[1].Value.Trim()
18+
$wechat_version = (Select-String -Path "WeChatFerry/spy/spy.rc" -Pattern 'VALUE "ProductVersion", "(.*)"').Matches.Groups[1].Value.Trim()
19+
$version = $version_full -replace '(\d+\.\d+\.\d+)\.\d+', '$1'
20+
echo "version=$version" >> $env:GITHUB_ENV
21+
echo "wechat_version=$wechat_version" >> $env:GITHUB_ENV
22+
shell: pwsh
23+
24+
- name: 设置 Visual Studio 2019
25+
uses: microsoft/setup-msbuild@v2
26+
with:
27+
vs-version: "16.0"
28+
29+
- name: 设置 Python 3
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: "3.9"
33+
34+
- name: 安装 Python 依赖项
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install grpcio-tools==1.48.2
38+
shell: pwsh
39+
40+
- name: 设置 vcpkg 缓存
41+
id: cache-vcpkg
42+
uses: actions/cache@v4
43+
with:
44+
path: |
45+
C:/Tools/vcpkg
46+
${{ github.workspace }}/WeChatFerry/vcpkg_installed
47+
key: vcpkg-${{ hashFiles('WeChatFerry/vcpkg.json') }}
48+
restore-keys: |
49+
vcpkg-
50+
51+
- name: 安装 vcpkg 并初始化
52+
run: |
53+
if (!(Test-Path 'C:/Tools')) { New-Item -ItemType Directory -Force -Path 'C:/Tools' }
54+
cd C:/Tools
55+
if (!(Test-Path 'C:/Tools/vcpkg')) { git clone https://github.com/microsoft/vcpkg }
56+
.\vcpkg\bootstrap-vcpkg.bat
57+
echo "VCPKG_ROOT=C:/Tools/vcpkg" >> $GITHUB_ENV
58+
cd ${{ github.workspace }}/WeChatFerry
59+
C:/Tools/vcpkg/vcpkg install --triplet x64-windows-static
60+
C:/Tools/vcpkg/vcpkg integrate install
61+
shell: pwsh
62+
63+
- name: 解析并构建 Release/Debug
64+
run: |
65+
$configs = "Release","Debug"
66+
foreach ($cfg in $configs) {
67+
Write-Host "Building $cfg"
68+
msbuild WeChatFerry/WeChatFerry.sln `
69+
/p:Configuration=$cfg `
70+
/p:Platform="x64" `
71+
/p:VcpkgTriplet="x64-windows-static" `
72+
/p:VcpkgEnableManifest=true `
73+
/verbosity:minimal
74+
}
75+
shell: pwsh

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: read
10+
actions: write
11+
12+
jobs:
13+
build:
14+
uses: ./.github/workflows/build-ci.yml

.github/workflows/release.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
8+
permissions:
9+
contents: read
10+
actions: write
11+
12+
jobs:
13+
build:
14+
uses: ./.github/workflows/build-ci.yml
15+
16+
release:
17+
name: 打包 & 发布
18+
needs: build
19+
runs-on: windows-latest
20+
# 仅当触发源是 push 且是 Tag 时才执行
21+
if: ${{ github.event_name == 'push' }}
22+
steps:
23+
- name: 检出代码
24+
uses: actions/checkout@v4
25+
26+
- name: 打包输出文件及下载 WeChat 安装包
27+
run: |
28+
New-Item -ItemType Directory -Force -Path "WeChatFerry/tmp"
29+
Compress-Archive -Path "WeChatFerry/Out/sdk.dll", "WeChatFerry/Out/spy.dll", "WeChatFerry/Out/spy_debug.dll", "WeChatFerry/Out/DISCLAIMER.md" -DestinationPath "WeChatFerry/tmp/v${{ env.version }}.zip"
30+
Invoke-WebRequest -Uri "https://github.com/tom-snow/wechat-windows-versions/releases/download/v${{ env.wechat_version }}/WeChatSetup-${{ env.wechat_version }}.exe" -OutFile "WeChatFerry/tmp/WeChatSetup-${{ env.wechat_version }}.exe"
31+
shell: pwsh
32+
33+
- name: 列出待发布文件
34+
run: |
35+
Get-ChildItem -Path "WeChatFerry/tmp" -Recurse
36+
shell: pwsh
37+
38+
- name: 发布到 GitHub Releases
39+
uses: ncipollo/release-action@main
40+
with:
41+
name: v${{ env.version }}
42+
tag: v${{ env.version }}
43+
token: ${{ secrets.REPO_TOKEN }}
44+
allowUpdates: true
45+
artifacts: "WeChatFerry/tmp/*"
46+
body: |
47+
程序版本:`v${{ env.version }}`
48+
配套微信版本:`${{ env.wechat_version }}`
49+
[📖 Python 文档](https://wechatferry.readthedocs.io/)

0 commit comments

Comments
 (0)