name: Release Pipeline on: push: tags: - "v*" branches-ignore: - "master" paths: - ".github/workflows/ci.yml" - "3rdparty/include/**" - "cmake/**" - "CMakeLists.txt" - "include/**" - "src/**" - "tools/maadeps-download.py" - "!**/*.md" pull_request: branches: - "dev" paths: - ".github/workflows/ci.yml" - "3rdparty/include/**" - "cmake/**" - "CMakeLists.txt" - "include/**" - "src/**" - "tools/maadeps-download.py" - "!**/*.md" workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: meta: name: Gather Meta Information # Prevent duplicate runs on organization branches with PRs if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name runs-on: ubuntu-latest outputs: tag: ${{ steps.set_tag.outputs.tag }} prerelease: ${{ steps.set_pre.outputs.prerelease }} steps: - name: Checkout repository uses: actions/checkout@v5 with: fetch-depth: 0 show-progress: false - name: Set tag id: set_tag run: | if [[ "${{ github.ref }}" == refs/tags/v* ]]; then # For tag pushes, use the tag name tag="${{ github.ref_name }}" else # For PRs and branch pushes, use git describe or fallback tag=$(git describe --tags --match "v*" HEAD 2>/dev/null || echo "v0.0.1-$(git rev-parse --short HEAD)") fi echo "tag=${tag}" | tee -a $GITHUB_OUTPUT - name: Check if it is a 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: Finalize 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 echo >> CHANGELOG.md echo "[已有 Mirror酱 CDK?前往 Mirror酱 高速下载](https://mirrorchyan.com/zh/projects?rid=MAA&source=maagh-release)" >> CHANGELOG.md - name: Upload changelog to GitHub uses: actions/upload-artifact@v5 if: startsWith(github.ref, 'refs/tags/v') with: name: changelog path: CHANGELOG.md windows: name: Build for Windows # Prevent duplicate runs on organization branches with PRs if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name needs: meta strategy: matrix: arch: [arm64, x64] fail-fast: false runs-on: windows-latest steps: - name: Checkout repository uses: actions/checkout@v5 with: show-progress: false - name: Fetch submodules run: | git submodule update --init --depth 1 src/MaaUtils git submodule update --init --depth 1 3rdparty/EmulatorExtras - name: Cache MaaDeps id: cache-maadeps uses: actions/cache@v4 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: Config cmake run: | mkdir -p build cmake -B build ${{ matrix.arch == 'arm64' && '-A ARM64' }} -DCMAKE_BUILD_TYPE=Release -DMAADEPS_TRIPLET='maa-${{ matrix.arch }}-windows' -DINSTALL_RESOURCE=ON -DINSTALL_PYTHON=ON -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' -DBUILD_WPF_GUI=OFF - name: Build run: | cmake --build build --config Release --parallel $env:NUMBER_OF_PROCESSORS - name: Install run: | mkdir -p install cmake --install build --prefix install --config Release - name: Cache .nuke/temp, ~/.nuget/packages id: cache-nuget uses: actions/cache@v4 with: path: | .nuke/temp ~/.nuget/packages key: ${{ runner.os }}-${{ matrix.arch }}-nuget-${{ hashFiles('**/*.csproj') }} - 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 = '${{ 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) - name: Publish WPF GUI continue-on-error: true run: | dotnet publish src/MaaWpfGui/MaaWpfGui.csproj -c Release -o install - name: Organize install files shell: bash run: | rm -rf install/*.pdb rm -rf install/msvc-debug rm -rf install/*.h cp tools/DependencySetup_依赖库安装.bat install - name: Zip files run: | cd install Compress-Archive -Destination MAA-${{ needs.meta.outputs.tag }}-win-${{ matrix.arch }}.zip -Path ./* - name: Upload MAA to GitHub uses: actions/upload-artifact@v5 with: name: MAA-win-${{ matrix.arch }} path: install/*.zip ubuntu: name: Build for Ubuntu # Prevent duplicate runs on organization branches with PRs if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name needs: meta runs-on: ubuntu-latest strategy: matrix: arch: [aarch64, x86_64] fail-fast: false steps: - name: Checkout repository uses: actions/checkout@v5 with: show-progress: false - name: Fetch submodules run: | git submodule update --init --depth 1 src/MaaUtils git submodule update --init --depth 1 3rdparty/EmulatorExtras git submodule update --init --depth 1 src/maa-cli - name: Cache MaaDeps id: cache-maadeps uses: actions/cache@v4 with: path: ./src/MaaUtils/MaaDeps key: ${{ runner.os }}-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-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 == 'x86_64' && 'x64' || 'arm64' }}-linux - name: Config cmake run: | mkdir -p build cmake -B build \ -DCMAKE_BUILD_TYPE=Release \ -DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux' \ -DINSTALL_RESOURCE=ON \ -DINSTALL_PYTHON=ON \ -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' \ -DCMAKE_TOOLCHAIN_FILE=src/MaaUtils/MaaDeps/cmake/maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux-toolchain.cmake - name: Build run: | cmake --build build --config Release --parallel $(nproc) env: CLICOLOR_FORCE: 1 - name: Install run: | mkdir -p install cmake --install build --prefix install --config Release - 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 < "AuthKey_${APPSTORE_KEYID}.p8" dmg="MAA-${{ needs.meta.outputs.tag }}-macos-universal.dmg" xcrun notarytool submit -k "AuthKey_${APPSTORE_KEYID}.p8" -d "$APPSTORE_KEYID" -i "$ISSUER_ID" --wait ${dmg} env: APPSTORE_KEYID: ${{ secrets.HGUANDL_APPSTORE_KEYID }} APPSTORE_KEY: ${{ secrets.HGUANDL_APPSTORE_KEY }} ISSUER_ID: ${{ secrets.HGUANDL_APPSTORE_ISSUER }} - name: Attach notarization tickets if: startsWith(github.ref, 'refs/tags/v') run: | dmg="MAA-${{ needs.meta.outputs.tag }}-macos-universal.dmg" xcrun stapler staple ${dmg} working-directory: release - name: Upload MAA to GitHub uses: actions/upload-artifact@v5 with: name: MAA-macos-universal path: ${{ startsWith(github.ref, 'refs/tags/v') && 'release/MAA*' || 'src/MaaMacGui/MAA.xcarchive/**' }} release: name: Publish Release # Prevent duplicate runs on organization branches with PRs if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) && startsWith(github.ref, 'refs/tags/v') needs: [meta, windows, ubuntu, macOS-Core, macOS-GUI] runs-on: ubuntu-latest steps: - name: Download MAA from GitHub uses: actions/download-artifact@v6 with: path: assets - name: Clean up 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: Publish release to GitHub uses: softprops/action-gh-release@v2.4.1 with: body_path: CHANGELOG.md files: | assets/* prerelease: ${{ needs.meta.outputs.prerelease != 'false' }} - name: Trigger MirrorChyan-related workflows run: | gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan.yml gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_release_note.yml env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Trigger OTA release workflow # 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.yml env: GH_TOKEN: ${{ secrets.MISTEOWORKFLOW }} - name: Create issue if failed if: failure() uses: actions-cool/issues-helper@v3 with: actions: "create-issue" title: "Errors occured during release ${{ needs.meta.outputs.tag }}" body: | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}