Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 93 additions & 94 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,99 +1,98 @@
name: Build Canary

on:
push:
branches: [ "main" ]
paths-ignore:
- '**.md'
workflow_dispatch:
push:
branches: ["main"]
paths-ignore:
- "**.md"
workflow_dispatch:

jobs:
build:
name: Build
runs-on: self-hosted

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive

- name: Checkout Assets
uses: clansty/checkout@main
with:
repository: MuNET-OSS/AquaMai-Build-Assets
token: ${{ secrets.BUILD_ASSETS_PAT }}
path: build-assets
max-attempts: 50
min-retry-interval: 1
max-retry-interval: 5

- name: Copy Assets
shell: powershell
run: |
Write-Host "Copying assets..."
Copy-Item -Path "build-assets/SDEZ/*" -Destination "AquaMai/Libs/" -Recurse -Force

- name: Setup Nuget
run: |
dotnet nuget list source
if (-not (dotnet nuget list source | Select-String "nuget.org")) {
dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org
}

- name: Install Frontend Dependencies
shell: powershell
run: |
corepack enable
Push-Location MaiChartManager\Front
pnpm install
Pop-Location


- name: Build
shell: powershell
run: |
.\Packaging\Build.ps1 -Mode Canary

- name: Upload to Alist
shell: powershell
env:
ALIST_TOKEN: ${{ secrets.ALIST_TOKEN }}
run: |
$alistUrl = "https://alist.c5y.moe"

# 找到构建产物
$appxFile = Get-ChildItem -Path "Packaging" -Filter "MaiChartManager_Canary_*.appx" | Select-Object -First 1
if (-not $appxFile) {
throw "No appx file found!"
}

Write-Host "Uploading $($appxFile.Name)..."

# 上传文件
$remotePath = "/SBGA/MaiChartManager Canary/$($appxFile.Name)"
$encodedPath = [System.Uri]::EscapeDataString($remotePath)

$headers = @{
"Authorization" = $env:ALIST_TOKEN
"File-Path" = $encodedPath
}

Invoke-RestMethod -Uri "$alistUrl/api/fs/put" -Method Put -InFile $appxFile.FullName -Headers $headers

Write-Host "Upload complete: $remotePath"

- name: Update AppInstaller Config
shell: powershell
run: |
# 1. 获取构建好的 Appx 文件名来提取版本号
$appxFile = Get-ChildItem -Path "Packaging" -Filter "MaiChartManager_Canary_*.appx" | Select-Object -First 1
if (-not $appxFile) { throw "Appx file not found for version extraction!" }

# 2. 提取版本号 (假设文件名格式为 MaiChartManager_Canary_1.2.3.4.appx)
$version = $appxFile.Name -replace 'MaiChartManager_Canary_', '' -replace '.appx', ''
Write-Host "Detected Version: $version"

# 3. 执行更新脚本
& "D:\sign\mcm-canary-update.ps1" -Version $version
build:
name: Build
runs-on: self-hosted

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive

- name: Checkout Assets
uses: clansty/checkout@main
with:
repository: MuNET-OSS/AquaMai-Build-Assets
token: ${{ secrets.BUILD_ASSETS_PAT }}
path: build-assets
max-attempts: 50
min-retry-interval: 1
max-retry-interval: 5

- name: Copy Assets
shell: powershell
run: |
Write-Host "Copying assets..."
Copy-Item -Path "build-assets/SDEZ/*" -Destination "AquaMai/Libs/" -Recurse -Force

- name: Setup Nuget
run: |
dotnet nuget list source
if (-not (dotnet nuget list source | Select-String "nuget.org")) {
dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org
}

- name: Install Frontend Dependencies
shell: powershell
run: |
corepack enable
Push-Location MaiChartManager\Front
pnpm install
Pop-Location

- name: Build
shell: powershell
run: |
.\Packaging\Build.ps1 -Mode Canary

- name: Upload to Alist
shell: powershell
env:
ALIST_TOKEN: ${{ secrets.ALIST_TOKEN }}
run: |
$alistUrl = "https://alist.c5y.moe"

# 找到构建产物
$appxFile = Get-ChildItem -Path "Packaging" -Filter "MaiChartManager_Canary_*.appx" | Select-Object -First 1
if (-not $appxFile) {
throw "No appx file found!"
}

Write-Host "Uploading $($appxFile.Name)..."

# 上传文件
$remotePath = "/SBGA/MaiChartManager Canary/$($appxFile.Name)"
$encodedPath = [System.Uri]::EscapeDataString($remotePath)

$headers = @{
"Authorization" = $env:ALIST_TOKEN
"File-Path" = $encodedPath
}

Invoke-RestMethod -Uri "$alistUrl/api/fs/put" -Method Put -InFile $appxFile.FullName -Headers $headers

Write-Host "Upload complete: $remotePath"

- name: Update AppInstaller Config
shell: powershell
run: |
# 1. 获取构建好的 Appx 文件名来提取版本号
$appxFile = Get-ChildItem -Path "Packaging" -Filter "MaiChartManager_Canary_*.appx" | Select-Object -First 1
if (-not $appxFile) { throw "Appx file not found for version extraction!" }

# 2. 提取版本号 (假设文件名格式为 MaiChartManager_Canary_1.2.3.4.appx)
$version = $appxFile.Name -replace 'MaiChartManager_Canary_', '' -replace '.appx', ''
Write-Host "Detected Version: $version"

# 3. 执行更新脚本
& "D:\sign\mcm-canary-update.ps1" -Version $version
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ riderModule.iml
/_ReSharper.Caches/
.vs
*.user
*.code-workspace
/MaiChartManager/Resources/AquaMai.dll
node_modules
Loading