Skip to content

Commit

Permalink
[skip ci] update ci
Browse files Browse the repository at this point in the history
  • Loading branch information
qhy040404 committed Nov 29, 2024
1 parent ec3f7b0 commit 58d9cec
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"cake.tool": {
"version": "4.0.0",
"version": "5.0.0",
"commands": [
"dotnet-cake"
]
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ on:
workflow_dispatch:
push:
branches:
- main
- develop
- 'feat/*'
paths-ignore:
- '.gitattributes'
- '.github/**'
Expand Down Expand Up @@ -90,10 +88,7 @@ jobs:
run: |
$summary = "
> [!WARNING]
> 该版本是由 CI 程序自动打包生成的 `Alpha` 测试版本,**仅供开发者测试使用**
> [!TIP]
> 普通用户请 [点击这里](https://github.com/DGP-Studio/Snap.Hutao/releases/latest/) 下载最新的稳定版本
> 该版本是由 CI 程序自动打包生成的 `Alpha` 测试版本,包含已经基本完工的新功能及问题修复
> [!IMPORTANT]
> 请先安装 **[DGP_Studio_CA.crt](https://github.com/DGP-Automation/Hutao-Auto-Release/releases/download/certificate-ca/DGP_Studio_CA.crt)** 到 **受信任的根证书颁发机构** 以安装测试版安装包
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Snap Hutao Canary
on:
workflow_dispatch:
push:
branches-ignore:
- develop
- main
- release
- dependabot/**
paths-ignore:
- '.gitattributes'
- '.github/**'
- '.gitignore'
- '.gitmodules'
- '**.md'
- 'LICENSE'
- '**.yml'

jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: develop
fetch-depth: 0

- name: Merge all branches into develop locally
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git fetch origin '+refs/heads/*:refs/remotes/origin/*'
git checkout origin/develop
$response = curl -s https://api.github.com/repos/DGP-Studio/Snap.Hutao/pulls?state=open
$refs = $response | ConvertFrom-Json | Where-Object { $_.draft -eq $false } | ForEach-Object { $_.head.ref }
foreach ($ref in $refs) {
echo "Merging $ref into develop"
git merge "origin/$ref" --strategy=ort --allow-unrelated-histories -m "Merge $ref into develop"
}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0

- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Snap.Hutao.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Cake
id: cake
shell: pwsh
run: dotnet tool restore && dotnet cake
env:
CERTIFICATE: ${{ secrets.CERTIFICATE }}
PW: ${{ secrets.PW }}

- name: Upload signed msix
if: success()
uses: actions/upload-artifact@v4
with:
name: Snap.Hutao.Canary-${{ steps.cake.outputs.version }}
path: ${{ github.workspace }}/src/output/Snap.Hutao.Canary-${{ steps.cake.outputs.version }}.msix

- name: Add summary
if: success()
shell: pwsh
run: |
$summary = "
> [!WARNING]
> 该版本是由 CI 程序自动打包生成的 `Canary` 测试版本,包含新功能原型及问题修复
> [!IMPORTANT]
> 请先安装 **[DGP_Studio_CA.crt](https://github.com/DGP-Automation/Hutao-Auto-Release/releases/download/certificate-ca/DGP_Studio_CA.crt)** 到 **受信任的根证书颁发机构** 以安装测试版安装包
"
echo $summary >> $Env:GITHUB_STEP_SUMMARY
87 changes: 70 additions & 17 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,28 @@ if (GitHubActions.IsRunningOnGitHubActions)
}
else
{
var versionAuth = HasEnvironmentVariable("VERSION_API_TOKEN") ? EnvironmentVariable("VERSION_API_TOKEN") : throw new Exception("Cannot find VERSION_API_TOKEN");
version = HttpGet(
"https://internal.snapgenshin.cn/BuildIntergration/RequestNewVersion",
new HttpSettings
{
Headers = new Dictionary<string, string>
{
if (GitHubActions.Environment.Workflow.Workflow == "Snap Hutao Alpha")
{
var versionAuth = HasEnvironmentVariable("VERSION_API_TOKEN") ? EnvironmentVariable("VERSION_API_TOKEN") : throw new Exception("Cannot find VERSION_API_TOKEN");
version = HttpGet(
"https://internal.snapgenshin.cn/BuildIntergration/RequestNewVersion",
new HttpSettings
{
Headers = new Dictionary<string, string>
{
{ "Authorization", versionAuth }
}
}
);
}
}
);
}
else if (GitHubActions.Environment.Workflow.Workflow == "Snap Hutao Canary")
{
version = System.DateTime.Now.ToString("yyyy.M.d.") + ((int)((System.DateTime.Now - System.DateTime.Today).TotalSeconds / 86400 * 65535)).ToString();
}
else
{
throw new Exception("Unsupported workflow.");
}

var certificateBase64 = HasEnvironmentVariable("CERTIFICATE") ? EnvironmentVariable("CERTIFICATE") : throw new Exception("Cannot find CERTIFICATE");
pw = HasEnvironmentVariable("PW") ? EnvironmentVariable("PW") : throw new Exception("Cannot find PW");
Expand Down Expand Up @@ -134,11 +145,29 @@ Task("Generate AppxManifest")
if (GitHubActions.IsRunningOnGitHubActions)
{
Information("Using CI configuraion");
content = content
.Replace("Snap Hutao", "Snap Hutao Alpha")
.Replace("胡桃", "胡桃 Alpha")
.Replace("DGP Studio", "DGP Studio CI");
content = System.Text.RegularExpressions.Regex.Replace(content, " Name=\"([^\"]*)\"", " Name=\"7f0db578-026f-4e0b-a75b-d5d06bb0a74c\"");
if (GitHubActions.Environment.Workflow.Workflow == "Snap Hutao Alpha")
{
Information("Using Alpha configuration");
content = content
.Replace("Snap Hutao", "Snap Hutao Alpha")
.Replace("胡桃", "胡桃 Alpha")
.Replace("DGP Studio", "DGP Studio CI");
content = System.Text.RegularExpressions.Regex.Replace(content, " Name=\"([^\"]*)\"", " Name=\"7f0db578-026f-4e0b-a75b-d5d06bb0a74c\"");
}
else if (GitHubActions.Environment.Workflow.Workflow == "Snap Hutao Canary")
{
Information("Using Canary configuration");
content = content
.Replace("Snap Hutao", "Snap Hutao Canary")
.Replace("胡桃", "胡桃 Canary")
.Replace("DGP Studio", "DGP Studio CI");
content = System.Text.RegularExpressions.Regex.Replace(content, " Name=\"([^\"]*)\"", " Name=\"52127695-c6a7-406e-916a-693b905e8ba7\"");
}
else
{
throw new Exception("Unsupported workflow.");
}

content = System.Text.RegularExpressions.Regex.Replace(content, " Publisher=\"([^\"]*)\"", " Publisher=\"E=admin@dgp-studio.cn, CN=DGP Studio CI, OU=CI, O=DGP-Studio, L=San Jose, S=CA, C=US\"");
content = System.Text.RegularExpressions.Regex.Replace(content, " Version=\"([0-9\\.]+)\"", $" Version=\"{version}\"");
}
Expand Down Expand Up @@ -214,7 +243,18 @@ Task("Build MSIX")
var arguments = "arguments";
if (GitHubActions.IsRunningOnGitHubActions)
{
arguments = "pack /d " + binPath + " /p " + System.IO.Path.Combine(outputPath, $"Snap.Hutao.Alpha-{version}.msix");
if (GitHubActions.Environment.Workflow.Workflow == "Snap Hutao Alpha")
{
arguments = "pack /d " + binPath + " /p " + System.IO.Path.Combine(outputPath, $"Snap.Hutao.Alpha-{version}.msix");
}
else if (GitHubActions.Environment.Workflow.Workflow == "Snap Hutao Canary")
{
arguments = "pack /d " + binPath + " /p " + System.IO.Path.Combine(outputPath, $"Snap.Hutao.Canary-{version}.msix");
}
else
{
throw new Exception("Unsupported workflow.");
}
}
else if (AppVeyor.IsRunningOnAppVeyor)
{
Expand Down Expand Up @@ -258,7 +298,20 @@ Task("Sign")
}

var signPath = System.IO.Path.Combine(winsdkBinPath, "signtool.exe");
var arguments = $"sign /debug /v /a /fd SHA256 /f {pfxPath} /p {pw} {System.IO.Path.Combine(outputPath, $"Snap.Hutao.Alpha-{version}.msix")}";
var arguments = "arguments";

if (GitHubActions.Environment.Workflow.Workflow == "Snap Hutao Alpha")
{
arguments = $"sign /debug /v /a /fd SHA256 /f {pfxPath} /p {pw} {System.IO.Path.Combine(outputPath, $"Snap.Hutao.Alpha-{version}.msix")}";
}
else if (GitHubActions.Environment.Workflow.Workflow == "Snap Hutao Canary")
{
arguments = $"sign /debug /v /a /fd SHA256 /f {pfxPath} /p {pw} {System.IO.Path.Combine(outputPath, $"Snap.Hutao.Canary-{version}.msix")}";
}
else
{
throw new Exception("Unsupported workflow.");
}

var p = StartProcess(
signPath,
Expand Down

0 comments on commit 58d9cec

Please sign in to comment.