mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-01 01:10:34 +08:00
* feat(MaaUnified): MaaUnified构建完成,作为submodule加入 * fix(MaaUnified): 修复自动构建时 submodule拉取错误问题 * feat(MaaUnified): MaaUnified submodule更换为组织仓库 * ci: do not fetch useless module --------- Co-authored-by: MistEO <mistereo@hotmail.com>
404 lines
15 KiB
YAML
404 lines
15 KiB
YAML
name: Release Pipeline (Nightly OTA)
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "0 22 * * *" # Runs daily at 22:00 UTC
|
|
workflow_dispatch:
|
|
inputs:
|
|
release_body:
|
|
description: "Release note"
|
|
type: string
|
|
required: false
|
|
ref:
|
|
description: "Commit to build (git checkout)"
|
|
type: string
|
|
required: false
|
|
limit_maa:
|
|
description: "Number of releases to fetch from MaaAssistantArknights"
|
|
required: true
|
|
default: 10
|
|
type: number
|
|
limit_maarelease:
|
|
description: "Number of releases to fetch from MaaRelease"
|
|
required: true
|
|
default: 10
|
|
type: number
|
|
|
|
jobs:
|
|
build-win-nightly:
|
|
name: Build Nightly for Windows
|
|
if: github.repository_owner == 'MaaAssistantArknights'
|
|
runs-on: windows-latest
|
|
strategy:
|
|
matrix:
|
|
arch: [x64]
|
|
fail-fast: false
|
|
outputs:
|
|
tag: ${{ steps.set_tag.outputs.tag }}
|
|
pre_version: ${{ steps.set_tag.outputs.pre_version }}
|
|
main_tag_name: ${{ steps.push_main_tag.outputs.main_tag_name }}
|
|
changelog: ${{ steps.read_changelog.outputs.content }}
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
with:
|
|
# repository: 'MaaAssistantArknights/MaaAssistantArknights'
|
|
#ref: ${{ inputs.ref }}
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
fetch-depth: 250
|
|
|
|
- name: Fetch tags
|
|
run: |
|
|
git fetch --depth=250 --tags
|
|
|
|
- name: Fetch submodules
|
|
shell: bash
|
|
run: bash ./.github/scripts/sync-optional-submodules.sh --init --depth 1 src/MaaUtils 3rdparty/EmulatorExtras
|
|
|
|
- name: Checkout ref (if provided)
|
|
if: inputs.ref != ''
|
|
run: |
|
|
git checkout --progress --recurse-submodules ${{ inputs.ref }}
|
|
|
|
- name: Check for Changes and Set tag
|
|
id: set_tag
|
|
run: |
|
|
# Fetch the latest tag from the repository
|
|
$latest_tag = git describe --tags --abbrev=0
|
|
|
|
Write-Output "Previous Tag: $latest_tag"
|
|
Write-Output "latest_tag=$latest_tag" >> $env:GITHUB_OUTPUT
|
|
|
|
# Check for changes between the latest tag and HEAD
|
|
$recent_changes = git log "$latest_tag..HEAD" --oneline
|
|
|
|
if (-not $recent_changes) {
|
|
Write-Output "No commits. Cancelling workflow..."
|
|
Write-Output "cancel_run=true" >> $env:GITHUB_ENV
|
|
exit 0
|
|
} else {
|
|
Write-Output "Recent commits: $recent_changes"
|
|
Write-Output "Commits found. Continuing build..."
|
|
Write-Output "cancel_run=false" >> $env:GITHUB_ENV
|
|
}
|
|
|
|
# Get the full description of the current commit
|
|
$described = git describe --tags --long --match 'v*'
|
|
Write-Output "New Described: $described"
|
|
$ids = $described -split "-"
|
|
|
|
if ($ids.Length -eq 3) {
|
|
# Extract and parse the current version
|
|
$current_version = $ids[0].Substring(1)
|
|
$parts = $current_version -split '\.'
|
|
if ($parts.Length -ne 3) {
|
|
Write-Error "Invalid version format: $current_version. Expected 'major.minor.patch'."
|
|
exit 1
|
|
}
|
|
|
|
# Increment the patch version
|
|
$parts[2] = [int]$parts[2] + 1
|
|
$new_version = "$($parts[0]).$($parts[1]).$($parts[2])"
|
|
|
|
# Construct the new tag and pre_version
|
|
$ver = "v$new_version"
|
|
$pre_version = $ids[0]
|
|
$dist = "{0:D3}" -f [int]$ids[1]
|
|
|
|
Write-Output "pre_version=$pre_version" >> $env:GITHUB_OUTPUT
|
|
Write-Output "New Tag: $ver-alpha.1.d$dist.$($ids[2])"
|
|
Write-Output "tag=$ver-alpha.1.d$dist.$($ids[2])" >> $env:GITHUB_OUTPUT
|
|
|
|
exit 0
|
|
}
|
|
|
|
if ($ids.Length -eq 4) {
|
|
$dist = "{0:D3}" -f [int]$ids[2]
|
|
$pre_version = "$($ids[0])-$($ids[1])"
|
|
|
|
Write-Output "Pre Version: $pre_version"
|
|
Write-Output "pre_version=$pre_version" >> $env:GITHUB_OUTPUT
|
|
|
|
Write-Output "tag: $pre_version.d$dist.$($ids[3])"
|
|
Write-Output "tag=$pre_version.d$dist.$($ids[3])" >> $env:GITHUB_OUTPUT
|
|
|
|
exit 0
|
|
}
|
|
|
|
exit 1
|
|
|
|
- name: Stop if no changes
|
|
if: env.cancel_run == 'true'
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
curl -s -L -X POST `
|
|
-H "Accept: application/vnd.github+json" `
|
|
-H "Authorization: Bearer ${{ secrets.MAA_ACTION_READ_WRITE }}" `
|
|
-H "X-GitHub-Api-Version: 2022-11-28" `
|
|
"https://api.github.com/repos/MaaAssistantArknights/MaaAssistantArknights/actions/runs/${{ github.run_id }}/cancel" > $null
|
|
|
|
gh run watch ${{ github.run_id }}
|
|
|
|
- name: Generate changelog
|
|
id: generate_changelog
|
|
run: |
|
|
python3 tools/ChangelogGenerator/changelog_generator.py --latest "${{ steps.set_tag.outputs.latest_tag }}" --tag "${{ steps.set_tag.outputs.tag }}"
|
|
Get-Content .\changelog.md | Select-Object -Skip 2 | Out-File -FilePath changelog_notag.md -Encoding utf8
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
PYTHONIOENCODING: "utf-8"
|
|
|
|
- name: Stop if no changes
|
|
if: steps.generate_changelog.outputs.cancel_run == 'true'
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
curl -s -L -X POST `
|
|
-H "Accept: application/vnd.github+json" `
|
|
-H "Authorization: Bearer ${{ secrets.MAA_ACTION_READ_WRITE }}" `
|
|
-H "X-GitHub-Api-Version: 2022-11-28" `
|
|
"https://api.github.com/repos/MaaAssistantArknights/MaaAssistantArknights/actions/runs/${{ github.run_id }}/cancel" > $null
|
|
|
|
gh run watch ${{ github.run_id }}
|
|
|
|
- name: Read changelog to variable
|
|
id: read_changelog
|
|
uses: juliangruber/read-file-action@v1
|
|
with:
|
|
path: ./changelog_notag.md
|
|
|
|
- name: Cache MaaDeps
|
|
id: cache-maadeps
|
|
uses: actions/cache@v5
|
|
continue-on-error: true
|
|
with:
|
|
path: |
|
|
./src/MaaUtils/MaaDeps
|
|
key: ${{ runner.os }}-${{ matrix.arch }}-maadeps-${{ hashFiles('tools/maadeps-download.py') }}
|
|
|
|
- name: Bootstrap MaaDeps
|
|
if: steps.cache-maadeps.outputs.cache-hit != 'true'
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
python3 tools/maadeps-download.py ${{ matrix.arch }}-windows
|
|
|
|
- name: Configure, build and install
|
|
run: |
|
|
cmake -B build --preset ${{ matrix.arch == 'arm64' && 'windows-publish-arm64' || 'windows-publish-x64' }} -DMAA_HASH_VERSION='${{ steps.set_tag.outputs.tag }}'
|
|
cmake --build --preset ${{ matrix.arch == 'arm64' && 'windows-publish-arm64' || 'windows-publish-x64' }} --parallel $env:NUMBER_OF_PROCESSORS
|
|
cmake --install build --config RelWithDebInfo
|
|
|
|
- name: Download MaaFramework
|
|
if: matrix.arch == 'x64'
|
|
uses: robinraju/release-downloader@v1
|
|
with:
|
|
repository: MaaXYZ/MaaFramework
|
|
tag: v5.9.2
|
|
fileName: "*win-x86_64*.zip"
|
|
extract: true
|
|
out-file-path: MaaFramework-temp
|
|
|
|
- name: Copy MaaWin32ControlUnit
|
|
if: matrix.arch == 'x64'
|
|
run: |
|
|
cp MaaFramework-temp/bin/*Win32ControlUnit* install/
|
|
|
|
- name: Setup .NET SDK
|
|
uses: actions/setup-dotnet@v5
|
|
with:
|
|
dotnet-version: '10.0.202'
|
|
|
|
- name: Cache .nuke/temp, ~/.nuget/packages
|
|
id: cache-nuget
|
|
uses: actions/cache@v5
|
|
continue-on-error: true
|
|
with:
|
|
path: |
|
|
.nuke/temp
|
|
~/.nuget/packages
|
|
key: ${{ runner.os }}-${{ matrix.arch }}-nuget-${{ hashFiles('**/*.csproj', 'global.json') }}
|
|
|
|
- name: Restore dependencies
|
|
if: steps.cache-nuget.outputs.cache-hit != 'true'
|
|
run: dotnet restore src/MaaWpfGui/MaaWpfGui.csproj
|
|
|
|
- name: Taggify version for csproj
|
|
run: |
|
|
$csprojPath = "src/MaaWpfGui/MaaWpfGui.csproj"
|
|
$csprojPath = Resolve-Path -Path $csprojPath
|
|
$tag = '${{ steps.set_tag.outputs.tag }}' -replace '.*?/', ''
|
|
if ($tag -match '\d+(\.\d+){1,3}') {
|
|
$match = $Matches[0]
|
|
} else {
|
|
$match = "0.0.1"
|
|
}
|
|
[xml]$csproj = Get-Content -Path $csprojPath
|
|
$node = $csproj.Project.PropertyGroup | where {$_.ApplicationVersion -ne $null}
|
|
$node.InformationalVersion = $tag
|
|
$node.Version = $match
|
|
$node.FileVersion = $match
|
|
$node.AssemblyVersion = $match
|
|
$csproj.Save($csprojPath)
|
|
|
|
- name: Publish WPF GUI
|
|
run: |
|
|
dotnet publish src/MaaWpfGui/MaaWpfGui.csproj -c Release -p:Platform=${{ matrix.arch == 'arm64' && 'ARM64' || 'x64' }} -o install
|
|
|
|
- name: Collect PDB files
|
|
run: |
|
|
cp build/bin/RelWithDebInfo/*.pdb install/
|
|
Compress-Archive -Path install/*.pdb -DestinationPath install/MAAComponent-DebugSymbol-${{ steps.set_tag.outputs.tag }}-win-${{ matrix.arch }}.zip
|
|
continue-on-error: true
|
|
|
|
- name: Upload PDB files
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: MAAComponent-DebugSymbol-win-${{ matrix.arch }}
|
|
path: install/MAAComponent-DebugSymbol-${{ steps.set_tag.outputs.tag }}-win-${{ matrix.arch }}.zip
|
|
|
|
- name: Organize install files
|
|
shell: bash
|
|
run: |
|
|
rm -rf install/MAAComponent-DebugSymbol-*.zip
|
|
rm -rf install/*.pdb
|
|
rm -rf install/msvc-debug
|
|
rm -rf install/*.h
|
|
|
|
cp tools/DependencySetup_依赖库安装.bat install
|
|
|
|
- name: Upload MAA to GitHub
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: MAA-win-${{ matrix.arch }}
|
|
path: install
|
|
|
|
- name: Push tag to main repo
|
|
id: push_main_tag
|
|
run: |
|
|
git config user.name 'github-actions[bot]'
|
|
git config user.email 'github-actions[bot]@users.noreply.github.com'
|
|
|
|
$main_tag_name=$(echo "alpha/${{ steps.set_tag.outputs.tag }}")
|
|
git tag $main_tag_name -f
|
|
git push --tags origin HEAD:refs/tags/$main_tag_name -f
|
|
echo "main_tag_name=$main_tag_name" >> $env:GITHUB_OUTPUT
|
|
|
|
push-tag:
|
|
name: Push Tag to MaaRelease
|
|
if: github.repository_owner == 'MaaAssistantArknights'
|
|
needs: build-win-nightly
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout MaaRelease
|
|
uses: actions/checkout@v6
|
|
with:
|
|
repository: ${{ format('{0}/{1}', github.repository_owner, 'MaaRelease') }}
|
|
fetch-depth: 0
|
|
token: ${{ secrets.MAARELEASE_RELEASE }}
|
|
show-progress: false
|
|
|
|
- name: Commit and setup tag
|
|
run: |
|
|
git config user.name 'github-actions[bot]'
|
|
git config user.email 'github-actions[bot]@users.noreply.github.com'
|
|
git checkout --orphan __temp
|
|
git rm -rf .
|
|
git commit --allow-empty --message ${{ needs.build-win-nightly.outputs.tag }}
|
|
git tag ${{ needs.build-win-nightly.outputs.tag }} || exit 0 # do nothing if the tag already exists
|
|
git push --tags origin HEAD:refs/tags/${{ needs.build-win-nightly.outputs.tag }}
|
|
|
|
make-ota:
|
|
name: Build and Upload Nightly OTA for Windows
|
|
if: github.repository_owner == 'MaaAssistantArknights'
|
|
needs: [build-win-nightly, push-tag]
|
|
strategy:
|
|
matrix:
|
|
target: [x64]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Show tag version
|
|
run: |
|
|
echo ${{ needs.build-win-nightly.outputs.tag }}
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
with:
|
|
path: MaaAssistantArknights
|
|
token: ${{ secrets.MAARELEASE_RELEASE }}
|
|
show-progress: false
|
|
|
|
- name: Download MAA from GitHub
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
name: MAA-win-${{ matrix.target }}
|
|
path: ${{ format('{0}/{1}', 'build-ota', needs.build-win-nightly.outputs.tag) }}
|
|
|
|
- name: Fetch release information
|
|
run: |
|
|
mkdir -pv build-ota && cd build-ota
|
|
|
|
# Convert inputs to integers
|
|
limit_maa=${{ inputs.limit_maa || 10 }}
|
|
limit_maa=${limit_maa%.*}
|
|
echo "Parsed limit_maa: $limit_maa"
|
|
|
|
limit_maarelease=${{ inputs.limit_maarelease || 10 }}
|
|
limit_maarelease=${limit_maarelease%.*}
|
|
echo "Parsed limit_maarelease: $limit_maarelease"
|
|
|
|
gh release list --repo 'MaaAssistantArknights/MaaAssistantArknights' --limit $limit_maa | tee ./release_maa.txt
|
|
gh release list --repo "${{ github.repository_owner }}/MaaRelease" --limit $limit_maarelease | tee ./release_mr.txt
|
|
echo ${{ needs.build-win-nightly.outputs.tag }} > ./config
|
|
|
|
cat ./release_maa.txt | awk '{ print $1 }' > ./tags_maa.txt
|
|
cat ./release_mr.txt | awk '{ print $1 }' > ./tags_mr.txt
|
|
|
|
comm <(sort ./tags_maa.txt) <(sort ./tags_mr.txt) | awk '{ print $1 }' >> ./config
|
|
|
|
echo "config:"
|
|
cat ./config
|
|
|
|
echo "release_tag=$(head -n 1 ./config)" >> $GITHUB_ENV
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build OTA
|
|
run: |
|
|
cd build-ota
|
|
|
|
pushd ${{ needs.build-win-nightly.outputs.tag }}
|
|
zip -r MAA-${{ env.release_tag }}-win-${{ matrix.target }}.zip ./*
|
|
popd
|
|
|
|
$GITHUB_WORKSPACE/MaaAssistantArknights/tools/OTAPacker/build.sh 'MaaAssistantArknights/MaaAssistantArknights' ./config ${{ matrix.target }} "${{ github.repository_owner }}/MaaRelease"
|
|
mv -v ${{ needs.build-win-nightly.outputs.tag }}/*.zip ./MAA-${{ env.release_tag }}-win-${{ matrix.target }}.zip
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Upload to MaaRelease
|
|
uses: svenstaro/upload-release-action@v2
|
|
with:
|
|
repo_name: ${{ format('{0}/{1}', github.repository_owner, 'MaaRelease') }}
|
|
repo_token: ${{ secrets.MAARELEASE_RELEASE }}
|
|
file_glob: true
|
|
file: build-ota/*.zip
|
|
tag: ${{ env.release_tag }}
|
|
prerelease: true
|
|
overwrite: true
|
|
body: |
|
|
${{ inputs.release_body || '' }}
|
|
|
|
${{ needs.build-win-nightly.outputs.changelog }}
|
|
|
|
**Full Changelog**: [${{ needs.build-win-nightly.outputs.pre_version }} -> ${{ needs.build-win-nightly.outputs.main_tag_name }}](https://github.com/${{ github.repository }}/compare/${{ needs.build-win-nightly.outputs.pre_version }}...${{ needs.build-win-nightly.outputs.main_tag_name }})
|
|
|
|
- name: Setup release mirror
|
|
run: |
|
|
gh workflow --repo MaaAssistantArknights/MaaRelease run release-mirrors.yml
|
|
gh workflow --repo MaaAssistantArknights/MaaRelease run mirrorchyan_alpha.yml
|
|
gh workflow --repo MaaAssistantArknights/MaaRelease run mirrorchyan_alpha_release_note.yml
|
|
env:
|
|
GH_TOKEN: ${{ secrets.MISTEOWORKFLOW }}
|