This commit is contained in:
fanbook-wangdage
2025-11-20 20:28:27 +08:00
commit 1f268acc29
2530 changed files with 221582 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
name: PublishDistribution
on:
release:
types: [released]
workflow_dispatch:
jobs:
Publish:
runs-on: ubuntu-latest
steps:
# Purge Patch System Cache
- name: Purge Patch
env:
PURGE_URL: ${{ secrets.PURGE_URL }}
run: |
curl -X PATCH $PURGE_URL
- name: Overwrite CN patch mirrors
shell: pwsh
run: |
$latestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/DGP-Studio/Snap.Hutao/releases/latest"
$asset = $latestRelease.assets[0]
$assetUrl = "https://ghproxy.qhy04.cc/" + $asset.browser_download_url
$tagName = $latestRelease.tag_name
Write-Output "Waiting Patch API to update"
while ($true) {
$patchData = Invoke-RestMethod -Uri "https://api.snapgenshin.com/patch/hutao"
$cachedVersion = $patchData.data.version.Substring(0, $patchData.data.version.Length - 2)
if ($cachedVersion -eq $tagName) {
break
}
Start-Sleep -Seconds 3
}
Write-Output "Add GitHub Proxy to Patch API"
$mirrorData = @{
key = "snap-hutao"
url = $assetUrl
mirror_name = "GitHub Proxy"
mirror_type = "direct"
} | ConvertTo-Json
$response1 = Invoke-WebRequest -Uri "https://api.snapgenshin.com/patch/mirror" `
-Method POST `
-Headers @{"API-Token" = "${{ secrets.OVERWRITE_TOKEN }}"} `
-Body $mirrorData `
-ContentType "application/json"
Write-Output $response1.Content
Write-Output "Add R2 to Patch API"
$r2Url = "https://hutao-dist.qhy04.cc/$($asset.name)"
$r2Data = @{
key = "snap-hutao"
url = $r2Url
mirror_name = "Cloudflare R2"
mirror_type = "direct"
} | ConvertTo-Json
$response2 = Invoke-WebRequest -Uri "https://api.snapgenshin.com/patch/mirror" `
-Method POST `
-Headers @{"API-Token" = "${{ secrets.OVERWRITE_TOKEN }}"} `
-Body $r2Data `
-ContentType "application/json"
Write-Output $response2.Content
- uses: benc-uk/workflow-dispatch@v1.2.4
with:
workflow: Build
repo: DGP-Studio/hutao-installer
ref: main
token: "${{ secrets.RUNNER_CHECK_TOKEN }}"
inputs: '{ "only-offline": true }'

139
.github/workflows/alpha.yml vendored Normal file
View File

@@ -0,0 +1,139 @@
name: Snap Hutao Alpha
on:
workflow_dispatch:
push:
branches: [ develop ]
paths-ignore:
- '.gitattributes'
- '.github/**'
- '.gitignore'
- '.gitmodules'
- '**.md'
- 'LICENSE'
- '**.yml'
pull_request:
branches: [ develop ]
paths-ignore:
- '.gitattributes'
- '.github/**'
- '.gitignore'
- '.gitmodules'
- '**.md'
- 'LICENSE'
- '**.yml'
- '**.resx'
jobs:
select-runner:
runs-on: ubuntu-latest
outputs:
runner: ${{ steps.select_runner.outputs.runner }}
steps:
- name: Select runner
id: select_runner
shell: bash
env:
ORG: ${{ github.repository_owner }}
REPO: ${{ github.repository }}
TOKEN: ${{ secrets.RUNNER_CHECK_TOKEN }}
LABEL: ${{ vars.RUNNER_LABEL || 'sjc1' }}
run: |
set -o pipefail
FALLBACK="windows-latest"
get_status_by_label () {
local url="$1"
local json
json=$(curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $TOKEN" \
"$url" 2>/dev/null || true)
jq -r --arg label "$LABEL" '
(.runners // [])
| map(select(any(.labels[]?; .name==$label)))
| .[0].status // ""' <<<"$json" 2>/dev/null || echo ""
}
# Check org's runner first and then repo's
STATUS="$(get_status_by_label "https://api.github.com/orgs/${ORG}/actions/runners?per_page=100")"
if [ -z "$STATUS" ]; then
STATUS="$(get_status_by_label "https://api.github.com/repos/${REPO}/actions/runners?per_page=100")"
fi
if [ "$STATUS" = "online" ]; then
PICK="$LABEL"
else
PICK="$FALLBACK"
fi
echo "Selected runner: $PICK (label=$LABEL, status=${STATUS:-unknown})"
echo "runner=$PICK" >> "$GITHUB_OUTPUT"
build:
needs: select-runner
runs-on: ${{ needs.select-runner.outputs.runner }}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup .NET (self-hosted)
if: ${{ needs.select-runner.outputs.runner == 'sjc1' }}
shell: pwsh
run: |
Write-Host "Running environment setup script…"
Invoke-WebRequest `
-Uri 'https://raw.githubusercontent.com/DGP-Studio/Snap.Hutao.DevelopEnvironment.Setup/refs/heads/main/setup.ps1' `
-OutFile 'setup.ps1' `
-UseBasicParsing
Write-Host "Executing setup.ps1"
.\setup.ps1
- name: Setup .NET
if: ${{ needs.select-runner.outputs.runner == 'windows-latest' }}
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0
- name: Cache NuGet packages
if: ${{ needs.select-runner.outputs.runner == 'windows-latest' }}
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:
VERSION_API_TOKEN: ${{ secrets.VERSION_API_TOKEN }}
CERTIFICATE: ${{ secrets.CERTIFICATE }}
PW: ${{ secrets.PW }}
- name: Upload signed msix
if: success() && github.event_name != 'pull_request'
uses: actions/upload-artifact@v5
with:
name: Snap.Hutao.Alpha-${{ steps.cake.outputs.version }}
path: ${{ github.workspace }}/src/output/Snap.Hutao.Alpha-${{ steps.cake.outputs.version }}.msix
- name: Add summary
if: success() && github.event_name != 'pull_request'
shell: pwsh
run: |
$summary = "
> [!WARNING]
> 该版本是由 CI 程序自动打包生成的 `Alpha` 测试版本,包含已经基本完工的新功能及问题修复
> [!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
- name: Clean up
shell: pwsh
run: |
Write-Host "Cleaning up NuGet cache..."
Remove-Item -Recurse -Force "$env:USERPROFILE\.nuget\packages"
Write-Host "NuGet cache cleaned."

97
.github/workflows/canary.yml vendored Normal file
View File

@@ -0,0 +1,97 @@
name: Snap Hutao Canary
on:
workflow_dispatch:
push:
branches-ignore:
- l10n_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@v5
with:
ref: develop
fetch-depth: 0
- name: Merge all branches into develop locally
id: merge
run: |
$continue = $true
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 }
if ($refs.Count -eq 0 -or ($refs.Count -eq 1 -and $refs -eq "l10n_develop")) {
echo "No PRs to merge"
$continue = $false
echo "continue=$continue" >> $Env:GITHUB_OUTPUT
exit
}
foreach ($ref in $refs) {
echo "Merging $ref into develop"
git merge "origin/$ref" --strategy=ort --allow-unrelated-histories -m "Merge $ref into develop"
}
echo "continue=$continue" >> $Env:GITHUB_OUTPUT
- name: Setup .NET
if: ${{ steps.merge.outputs.continue == 'true' }}
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0
- name: Cache NuGet packages
if: ${{ steps.merge.outputs.continue == 'true' }}
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Snap.Hutao.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Cake
if: ${{ steps.merge.outputs.continue == 'true' }}
id: cake
shell: pwsh
run: dotnet tool restore && dotnet cake
env:
CERTIFICATE: ${{ secrets.CERTIFICATE }}
PW: ${{ secrets.PW }}
- name: Upload signed msix
if: ${{ success() && steps.merge.outputs.continue == 'true' }}
uses: actions/upload-artifact@v5
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() && steps.merge.outputs.continue == 'true' }}
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

16
.github/workflows/close_stale.yml vendored Normal file
View File

@@ -0,0 +1,16 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *'
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v10
with:
any-of-labels: 'needs-more-info,需要更多信息'
stale-issue-message: 'This issue is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 3 days.'
days-before-stale: 7
days-before-close: 3
close-issue-reason: not_planned

20
.github/workflows/issue_similarity.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: Issues Similarity Analysis
on:
issues:
types: [opened, edited]
jobs:
similarity-analysis:
runs-on: ubuntu-latest
steps:
- name: analysis
uses: actions-cool/issues-similarity-analysis@v1
with:
filter-threshold: 0.5
comment-title: '### Probable Similar Topics'
title-excludes: '[Publish]:,[Bug]:,[Feat]:,[Network]:,[ENG]'
comment-body: '${index}. ${similarity} #${number}'
show-footer: false
show-mentioned: true
since-days: 365

View File

@@ -0,0 +1,26 @@
name: 'Lock Threads'
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
permissions:
issues: write
pull-requests: write
discussions: write
concurrency:
group: lock-threads
jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v5
with:
issue-inactive-days: '30'
issue-comment: 'This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topic.'
issue-lock-reason: 'resolved'
process-only: 'issues'
log-output: false