mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
Updates `softprops/action-gh-release` from 1 to 2 - [Release notes](https://github.com/softprops/action-gh-release/releases) - [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md) - [Commits](https://github.com/softprops/action-gh-release/compare/v1...v2) Updates `peter-evans/create-pull-request` from 5 to 6 - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/v5...v6) Updates `kentaro-m/auto-assign-action` from 1.2.5 to 2.0.0 - [Release notes](https://github.com/kentaro-m/auto-assign-action/releases) - [Commits](https://github.com/kentaro-m/auto-assign-action/compare/v1.2.5...v2.0.0) Updates `andymckay/cancel-action` from 0.3 to 0.5 - [Release notes](https://github.com/andymckay/cancel-action/releases) - [Commits](https://github.com/andymckay/cancel-action/compare/0.3...0.5) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Constrat <56174894+Constrat@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
472 lines
16 KiB
YAML
472 lines
16 KiB
YAML
name: ci
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
branches-ignore:
|
|
- "master"
|
|
paths:
|
|
- "3rdparty/include/**"
|
|
- "include/**"
|
|
- "src/**"
|
|
- "cmake/**"
|
|
- "CMakeLists.txt"
|
|
- "MAA.sln"
|
|
- ".github/workflows/ci.yml"
|
|
- "!**/*.md"
|
|
pull_request:
|
|
branches:
|
|
- "dev"
|
|
paths:
|
|
- "3rdparty/include/**"
|
|
- "include/**"
|
|
- "src/**"
|
|
- "cmake/**"
|
|
- "CMakeLists.txt"
|
|
- "MAA.sln"
|
|
- "!**/*.md"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
meta:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
tag: ${{ steps.set_tag.outputs.tag }}
|
|
prerelease: ${{ steps.set_pre.outputs.prerelease }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
path: temp
|
|
show-progress: false
|
|
|
|
- name: Fetch history
|
|
if: ${{ !startsWith(github.ref, 'refs/pull/') }}
|
|
run: |
|
|
git init
|
|
cp $GITHUB_WORKSPACE/temp/.git/config ./.git
|
|
rm -rf $GITHUB_WORKSPACE/temp
|
|
# git config remote.origin.fetch '+refs/*:refs/*'
|
|
git fetch --filter=tree:0 # --update-head-ok
|
|
git reset --hard origin/$(git branch --show-current) || true
|
|
git checkout ${{ github.ref_name }}
|
|
|
|
- name: Set tag
|
|
id: set_tag
|
|
run: |
|
|
${{ startsWith(github.ref, 'refs/pull/') && 'cd temp' || '' }}
|
|
echo tag=$(git describe --tags --match "v*" ${{ github.ref }} || git rev-parse --short HEAD) | tee -a $GITHUB_OUTPUT
|
|
exit ${PIPESTATUS[0]}
|
|
|
|
- name: Judge pre-release
|
|
id: set_pre
|
|
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
|
run: |
|
|
if [[ '${{ steps.set_tag.outputs.tag }}' =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
echo prerelease=false | tee -a $GITHUB_OUTPUT
|
|
else
|
|
echo prerelease=true | tee -a $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Generate changelog
|
|
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
|
run: |
|
|
this_tag=${{ steps.set_tag.outputs.tag }}
|
|
if [[ '${{ steps.set_pre.outputs.prerelease }}' != 'false' ]]; then
|
|
last_tag=$(git describe --tags --match "v*" --abbrev=0 --exclude='${{ steps.set_tag.outputs.tag }}')
|
|
else
|
|
last_tag=$(git describe --tags --match "v*" --abbrev=0 --exclude='${{ steps.set_tag.outputs.tag }}' --exclude='*-*')
|
|
fi
|
|
echo >> CHANGELOG.md
|
|
echo "**Full Changelog**: [$last_tag -> $this_tag](https://github.com/MaaAssistantArknights/MaaAssistantArknights/compare/${last_tag}...${this_tag})" >> CHANGELOG.md
|
|
|
|
- name: Upload changelog to Github
|
|
uses: actions/upload-artifact@v4
|
|
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
|
with:
|
|
name: changelog
|
|
path: CHANGELOG.md
|
|
|
|
windows:
|
|
needs: meta
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- msbuild_target: x64
|
|
lowercase_target: x64
|
|
- msbuild_target: ARM64
|
|
lowercase_target: arm64
|
|
env:
|
|
MAABUILDER_TARGET_PLATFORM: ${{ matrix.msbuild_target }}
|
|
runs-on: windows-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
show-progress: false
|
|
submodules: recursive
|
|
|
|
- name: Cache .nuke/temp, ~/.nuget/packages
|
|
id: cache-nuget
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
.nuke/temp
|
|
~/.nuget/packages
|
|
key: ${{ runner.os }}-${{ matrix.msbuild_target }}-${{ hashFiles('**/global.json', '**/*.csproj') }}
|
|
|
|
- name: Restore dependencies
|
|
if: steps.cache-nuget.outputs.cache-hit != 'true'
|
|
run: dotnet restore
|
|
|
|
- name: Bootstrap MaaDeps
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
python3 maadeps-download.py ${{ matrix.lowercase_target }}-windows
|
|
|
|
- name: Create fake event file
|
|
shell: bash
|
|
run: cp -v "$GITHUB_EVENT_PATH" ./event.json
|
|
|
|
- name: Merge Event Data with Inputs
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
shell: bash
|
|
run: |
|
|
cat "$GITHUB_EVENT_PATH" | jq '. + { "inputs": {"ReleaseSimulation": "${{ needs.meta.outputs.tag }}"} }' | tee ./event.json
|
|
|
|
- name: Taggify Version
|
|
run: |
|
|
$csprojPath = "src/MaaWpfGui/MaaWpfGui.csproj"
|
|
$csprojPath = Resolve-Path -Path $csprojPath
|
|
$tag = '${{ needs.meta.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)
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build
|
|
run: |
|
|
$env:GITHUB_WORKFLOW = 'dev-build-win' # pretend this is a dev-build-win workflow
|
|
$env:GITHUB_EVENT_PATH = "$pwd\\event.json"
|
|
$env:GITHUB_REF = "refs/heads/not_master"
|
|
$env:MAA_BUILDER_MAA_VERSION = '${{ needs.meta.outputs.tag }}'
|
|
./build.cmd DevBuild
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Cleanup checksum file
|
|
run: |
|
|
rm -vf ./artifacts/checksum.json
|
|
shell: bash
|
|
|
|
- name: Upload MAA to Github
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: MAA-win-${{ matrix.lowercase_target }}
|
|
path: artifacts
|
|
|
|
ubuntu:
|
|
needs: meta
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
arch: [aarch64, x86_64]
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
show-progress: false
|
|
submodules: recursive
|
|
|
|
- name: Install cross compile toolchains
|
|
if: ${{ matrix.arch != 'x86_64' }}
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install g++-12-aarch64-linux-gnu g++-12-aarch64-linux-gnu
|
|
|
|
- name: Setup ccache
|
|
uses: Chocobo1/setup-ccache-action@v1
|
|
with:
|
|
remove_stale_cache: false
|
|
|
|
- name: Bootstrap MaaDeps
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
python3 maadeps-download.py ${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux
|
|
|
|
- name: Build MAA
|
|
run: |
|
|
mkdir -p build
|
|
cmake -B build \
|
|
-DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux' \
|
|
-DINSTALL_THIRD_LIBS=ON \
|
|
-DINSTALL_RESOURCE=ON \
|
|
-DINSTALL_PYTHON=ON \
|
|
-DMAA_VERSION='${{ needs.meta.outputs.tag }}'
|
|
cmake --build build --parallel $(nproc --all)
|
|
|
|
mkdir -p install
|
|
cmake --install build --prefix install
|
|
env:
|
|
CC: ${{ matrix.arch == 'x86_64' && 'ccache gcc-12' || 'ccache aarch64-linux-gnu-gcc-12' }}
|
|
CXX: ${{ matrix.arch == 'x86_64' && 'ccache g++-12' || 'ccache aarch64-linux-gnu-g++-12' }}
|
|
|
|
- name: Setup Cross Compile Toolchains for CLI
|
|
uses: ./src/maa-cli/.github/actions/setup
|
|
with:
|
|
os: ubuntu-latest
|
|
target_arch: ${{ matrix.arch }}
|
|
|
|
- name: Build CLI
|
|
run: |
|
|
cargo build --release --locked --package maa-cli --features vendored-openssl
|
|
cp -v target/$CARGO_BUILD_TARGET/release/maa $GITHUB_WORKSPACE/install/maa
|
|
cargo build --release --locked --package maa-cli --no-default-features \
|
|
--features git2,vendored-openssl
|
|
cp -v target/$CARGO_BUILD_TARGET/release/maa $GITHUB_WORKSPACE/appimage-maa
|
|
working-directory: src/maa-cli
|
|
|
|
- name: Build Appimage
|
|
run: |
|
|
sudo add-apt-repository universe
|
|
sudo apt update
|
|
sudo apt install libfuse2
|
|
mkdir -pv release
|
|
mkdir -pv Maa.AppDir/usr/share/maa
|
|
cp -r install/* Maa.AppDir/usr/share/maa/
|
|
wget -c https://raw.githubusercontent.com/MaaAssistantArknights/design/main/logo/maa-logo_512x512.png -O Maa.AppDir/maa.png
|
|
mkdir -pv Maa.AppDir/usr/share/icons/hicolor/512x512/apps/
|
|
cp -v Maa.AppDir/maa.png Maa.AppDir/usr/share/icons/hicolor/512x512/apps/
|
|
cp -v appimage-maa Maa.AppDir/usr/share/maa/maa
|
|
chmod a+x Maa.AppDir/usr/share/maa/maa
|
|
|
|
cat > Maa.AppDir/maa.desktop <<EOF
|
|
[Desktop Entry]
|
|
Type=Application
|
|
Name=MaaAssistantArknights
|
|
Icon=maa
|
|
Exec=AppRun
|
|
Terminal=true
|
|
Categories=Game;StrategyGame;
|
|
Comment=An Arknights assistant
|
|
EOF
|
|
|
|
ln -sv usr/share/maa/maa Maa.AppDir/AppRun
|
|
mkdir -pv Maa.AppDir/usr/share/metainfo/
|
|
cp -v tools/AppImage/io.github.maaassistantarknights.maaassistantarknights.metainfo.xml Maa.AppDir/usr/share/metainfo/
|
|
wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
|
|
# appimagetool with embedded runtime does not support cross build, till AppImage/appimagetool 7a10b8
|
|
wget "https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-${{ matrix.arch }}"
|
|
chmod a+x appimagetool-x86_64.AppImage
|
|
ARCH=${{ matrix.arch }} ./appimagetool-x86_64.AppImage --runtime-file runtime-${{ matrix.arch }} Maa.AppDir
|
|
chmod a+x MaaAssistantArknights-${{ matrix.arch }}.AppImage
|
|
mv -v MaaAssistantArknights-${{ matrix.arch }}.AppImage $GITHUB_WORKSPACE/release/MAA-${{ needs.meta.outputs.tag }}-linux-${{ matrix.arch }}.AppImage
|
|
|
|
- name: Tar files
|
|
run: |
|
|
mkdir -p release
|
|
cd install
|
|
tar czvf $GITHUB_WORKSPACE/release/MAA-${{ needs.meta.outputs.tag }}-linux-${{ matrix.arch }}.tar.gz .
|
|
|
|
- name: Upload MAA to Github
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: MAA-linux-${{ matrix.arch }}
|
|
path: |
|
|
release/*.AppImage
|
|
release/*.tar.gz
|
|
|
|
macOS-Core:
|
|
needs: meta
|
|
runs-on: macos-14
|
|
strategy:
|
|
matrix:
|
|
arch: [arm64, x86_64]
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
show-progress: false
|
|
|
|
- name: Install Dependencies
|
|
run: |
|
|
brew install ninja
|
|
|
|
- name: Bootstrap MaaDeps
|
|
run: |
|
|
[[ ${{ matrix.arch }} = "arm64" ]] && triplet="arm64-osx" || triplet="x64-osx"
|
|
python3 maadeps-download.py ${triplet}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Configure MaaCore
|
|
run: |
|
|
cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES='${{ matrix.arch }}' -DMAA_VERSION='${{ needs.meta.outputs.tag }}'
|
|
|
|
- name: Build MaaCore
|
|
run: |
|
|
cmake --build build
|
|
cmake --install build --prefix install
|
|
|
|
- name: Upload MAA to Github
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: MAACore-macos-${{ matrix.arch }}
|
|
path: "install/*.dylib"
|
|
|
|
macOS-GUI:
|
|
needs: [meta, macOS-Core]
|
|
runs-on: macos-14
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
show-progress: false
|
|
submodules: recursive
|
|
|
|
- name: Download Arm64 MAA from Github
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: MAACore-macos-arm64
|
|
path: install-arm64
|
|
|
|
- name: Download x64 MAA from Github
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: MAACore-macos-x86_64
|
|
path: install-x86_64
|
|
|
|
- name: Install Developer ID Certificate
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
uses: ssrobins/import-codesign-certs@v2
|
|
with:
|
|
p12-file-base64: ${{ secrets.HGUANDL_SIGN_CERT_P12 }}
|
|
p12-password: ${{ secrets.HGUANDL_SIGN_CERT_PASSWD }}
|
|
|
|
- name: Build Universal Binaries
|
|
run: |
|
|
mkdir build
|
|
for LIB_NAME in $(ls install-arm64); do
|
|
lipo -create install-arm64/$LIB_NAME install-x86_64/$LIB_NAME -output build/$LIB_NAME
|
|
done
|
|
|
|
- name: Build XCFramework
|
|
run: |
|
|
xcodebuild -create-xcframework -library libMaaCore.dylib -headers ../include -output MaaCore.xcframework
|
|
xcodebuild -create-xcframework -library libfastdeploy_ppocr.dylib -output fastdeploy_ppocr.xcframework
|
|
xcodebuild -create-xcframework -library libonnxruntime.*.dylib -output ONNXRuntime.xcframework
|
|
xcodebuild -create-xcframework -library libopencv*.dylib -output OpenCV.xcframework
|
|
working-directory: build
|
|
|
|
- name: Setup GUI Version
|
|
run: |
|
|
RELEASE_COUNT=$(git ls-remote --tags origin | grep refs/tags/v | awk 'END{print NR}')
|
|
echo 'MARKETING_VERSION = ${{ needs.meta.outputs.tag }}' | tee src/MaaMacGui/Version.xcconfig
|
|
echo 'CURRENT_PROJECT_VERSION = '"${RELEASE_COUNT}" | tee -a src/MaaMacGui/Version.xcconfig
|
|
|
|
- name: Build MAA
|
|
run: |
|
|
if ${{ startsWith(github.ref, 'refs/tags/v') }}; then
|
|
xcodebuild -project MeoAsstMac.xcodeproj -scheme MAA archive -archivePath MAA.xcarchive -configuration Release
|
|
else
|
|
xcodebuild CODE_SIGN_IDENTITY="-" DEVELOPMENT_TEAM="-" ONLY_ACTIVE_ARCH=NO -project MeoAsstMac.xcodeproj -scheme MAA archive -archivePath MAA.xcarchive -configuration Debug
|
|
fi
|
|
working-directory: src/MaaMacGui
|
|
|
|
- name: Export MAA
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
xcodebuild -exportArchive -archivePath MAA.xcarchive -exportOptionsPlist ExportOptions.plist -exportPath Export
|
|
working-directory: src/MaaMacGui
|
|
|
|
- name: Create Disk Image
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
mkdir Image
|
|
mv Export/MAA.app Image/
|
|
ln -s /Applications Image/
|
|
hdiutil create -volname MAA -srcfolder Image -ov -fs APFS -format ULMO MAA.dmg
|
|
working-directory: src/MaaMacGui
|
|
|
|
- name: Archive Debug Symbols
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
ditto -c -k --keepParent MAA.app.dSYM MAA.app.dSYM.zip
|
|
working-directory: src/MaaMacGui/MAA.xcarchive/dSYMs
|
|
|
|
- name: Place Packages
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
GIT_TAG=${{ needs.meta.outputs.tag }}
|
|
APP_DMG=MAA-${GIT_TAG}-macos-universal.dmg
|
|
APP_SYM=MAAComponent-DebugSymbol-${GIT_TAG}-macos-universal.zip
|
|
mkdir -p release
|
|
mv src/MaaMacGui/MAA.dmg release/${APP_DMG}
|
|
mv src/MaaMacGui/MAA.xcarchive/dSYMs/MAA.app.dSYM.zip release/${APP_SYM}
|
|
|
|
- name: Notarize Image
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
find . -name "*.dmg" | while read dmg; do
|
|
codesign -s "$NOTARY_TEAM" --timestamp ${dmg}
|
|
xcrun notarytool submit --apple-id "$NOTARY_USER" --password "$NOTARY_PASSWD" --team-id "$NOTARY_TEAM" --wait ${dmg}
|
|
xcrun stapler staple ${dmg}
|
|
done
|
|
env:
|
|
NOTARY_USER: ${{ secrets.HGUANDL_NOTARY_AAPL_ID }}
|
|
NOTARY_PASSWD: ${{ secrets.HGUANDL_NOTARY_PASSWD }}
|
|
NOTARY_TEAM: ${{ secrets.HGUANDL_SIGN_IDENTITY }}
|
|
working-directory: release
|
|
|
|
- name: Upload MAA to Github
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: MAA-macos-universal
|
|
path: ${{ startsWith(github.ref, 'refs/tags/v') && 'release/MAA*' || 'src/MaaMacGui/MAA.xcarchive/**' }}
|
|
|
|
release:
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
needs: [meta, windows, ubuntu, macOS-GUI]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download MAA from Github
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: assets
|
|
|
|
- name: Cleanup files
|
|
run: |
|
|
mv -vf assets/changelog/* .
|
|
rm -rf assets/MAACore-macos-*
|
|
cd assets
|
|
# find . -type f | xargs mv -fvt .
|
|
find . -type f | while read f; do mv -fvt . $f; done
|
|
|
|
- name: Release to Github
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
body_path: CHANGELOG.md
|
|
files: |
|
|
assets/*
|
|
prerelease: ${{ needs.meta.outputs.prerelease != 'false' }}
|
|
|
|
- name: Trigger secondary workflows # ref: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
|
|
run: |
|
|
gh workflow run --repo $GITHUB_REPOSITORY release-ota
|
|
env:
|
|
GH_TOKEN: ${{ secrets.MISTEOWORKFLOW }}
|