feat:新增版本名称,累充活动名,兑换码等远程数据供软件访问 #178
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: install | |
| on: | |
| push: | |
| tags: | |
| - "v[0-9]+.[0-9]+.[0-9]+*" | |
| branches: | |
| - "**" | |
| paths: | |
| - ".github/workflows/install.yml" | |
| - "assets/**" | |
| - "**.py" | |
| pull_request: | |
| branches: | |
| - "**" | |
| paths: | |
| - ".github/workflows/install.yml" | |
| - "assets/**" | |
| - "**.py" | |
| workflow_dispatch: | |
| env: | |
| MAA_FRAMEWORK_VERSION: "v5.8.1" | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| meta: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - id: set_tag | |
| run: | | |
| # 检查标签格式 | |
| if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*)?$ ]]; then | |
| is_release=true | |
| tag=${GITHUB_REF#refs/tags/} | |
| echo "Release tag format is valid: $tag" | |
| else | |
| is_release=false | |
| # 获取最新的发布标签 | |
| tag=$(curl -sX GET "https://api.github.com/repos/${{ github.repository }}/releases/latest" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | awk '/tag_name/{print $4}' FS='["|"]') | |
| if [[ ! $tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then | |
| echo "No valid release tag found, using v0.0.0" | |
| tag="v0.0.0" | |
| fi | |
| tag=$(date "+$tag-%y%m%d-$(git rev-parse --short HEAD)") | |
| fi | |
| if [ "$is_release" != "true" ] ; then | |
| prefix=${tag%-*-*} | |
| suffix=${tag#$prefix-} | |
| tag="$prefix-ci.$suffix" | |
| fi | |
| # 检查是否为预发布版本 | |
| is_prerelease=false | |
| if [[ $tag =~ .*alpha.* || $tag =~ .*beta.* || $tag =~ .*rc.* || $tag =~ .*dev.* || $tag =~ .*-ci.* ]]; then | |
| is_prerelease=true | |
| echo "This is a pre-release version" | |
| fi | |
| echo tag=$tag | tee -a $GITHUB_OUTPUT | |
| echo is_release=$is_release | tee -a $GITHUB_OUTPUT | |
| echo is_prerelease=$is_prerelease | tee -a $GITHUB_OUTPUT | |
| outputs: | |
| tag: ${{ steps.set_tag.outputs.tag }} | |
| is_release: ${{ steps.set_tag.outputs.is_release }} | |
| is_prerelease: ${{ steps.set_tag.outputs.is_prerelease }} | |
| windows: | |
| needs: meta | |
| strategy: | |
| matrix: | |
| include: | |
| - arch: x86_64 | |
| runner: windows-latest | |
| - arch: aarch64 | |
| runner: windows-11-arm | |
| fail-fast: false | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Set platform variables | |
| id: platform | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.arch }}" = "x86_64" ]; then | |
| echo "tag=x64" >> $GITHUB_OUTPUT | |
| else | |
| echo "tag=arm64" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Download MaaFramework | |
| uses: robinraju/release-downloader@v1 | |
| with: | |
| repository: MaaXYZ/MaaFramework | |
| fileName: "MAA-win-${{ matrix.arch }}*" | |
| tag: ${{ env.MAA_FRAMEWORK_VERSION }} | |
| out-file-path: "deps" | |
| extract: true | |
| - name: Download MFAAvalonia | |
| id: download_mfa | |
| uses: robinraju/release-downloader@v1 | |
| with: | |
| repository: MaaXYZ/MFAAvalonia | |
| fileName: "MFAAvalonia-*-win-${{ steps.platform.outputs.tag }}*" | |
| latest: true | |
| out-file-path: "MFA" | |
| extract: true | |
| - name: Clean up MFAAvalonia archive on Windows | |
| shell: bash | |
| run: | | |
| ARCHIVE_FILE_PATH="${{ fromJson(steps.download_mfa.outputs.downloaded_files)[0] }}" | |
| rm -f "${ARCHIVE_FILE_PATH}" | |
| echo "Archive cleanup command executed for MFAAvalonia on Windows." | |
| - name: Remove built-in runtime in MFA | |
| shell: bash | |
| run: | | |
| rm -rf MFA/runtimes | |
| - name: Convert PNG to ICO | |
| if: matrix.arch == 'x86_64' | |
| shell: bash | |
| run: | | |
| # 安装 ImageMagick | |
| choco install imagemagick -y | |
| # 转换 PNG 到 ICO | |
| magick convert assets/logo.png -define icon:auto-resize=256,128,64,48,32,24,16 MR3A.ico | |
| - name: Modify MFAAvalonia exe icon | |
| if: matrix.arch == 'x86_64' | |
| shell: bash | |
| run: | | |
| # 下载 rcedit | |
| curl -L https://github.com/electron/rcedit/releases/download/v2.0.0/rcedit-x64.exe -o rcedit.exe | |
| # 修改 exe 图标 | |
| ./rcedit.exe "MFA/MFAAvalonia.exe" --set-icon "MR3A.ico" | |
| echo "MFAAvalonia icon modified successfully" | |
| - name: Setup Embed Python on Windows | |
| shell: bash | |
| run: | | |
| python tools/ci/setup_embed_python.py | |
| - name: Download Python dependencies | |
| shell: bash | |
| run: | | |
| ./install/python/python.exe -m pip install -r requirements.txt | |
| - name: Install on Windows | |
| shell: bash | |
| run: | | |
| if [ -d "MFA" ]; then | |
| echo "Copying MFA files to install directory..." | |
| mkdir -p install | |
| cp -rpvn MFA/. install/ | |
| if [ -f "install/MFAAvalonia.exe" ]; then | |
| mv -f install/MFAAvalonia.exe install/MR3A.exe | |
| elif [ -f "install/MFAAvalonia" ]; then | |
| mv -f install/MFAAvalonia install/MR3A | |
| fi | |
| echo "MFA files copied successfully." | |
| else | |
| echo "MFA directory not found, skipping copy." | |
| fi | |
| # 安装 Python 依赖 | |
| ./install/python/python.exe -m pip install -r tools/requirements.txt | |
| ./install/python/python.exe tools/ci/install.py ${{ needs.meta.outputs.tag }} win ${{ matrix.arch }} | |
| - name: Copy custom icons | |
| shell: bash | |
| run: | | |
| # 删除 MFAA 自带的 Assets 文件夹 | |
| if [ -d "install/Assets" ]; then | |
| rm -rf install/Assets | |
| echo "Removed original Assets folder" | |
| fi | |
| # MFAA 版本的图标放根目录 | |
| if [ -f "MR3A.ico" ]; then | |
| cp MR3A.ico install/logo.ico | |
| echo "Copied custom icon to install/logo.ico" | |
| fi | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: MR3A-win-${{ matrix.arch }}-${{ needs.meta.outputs.tag }} | |
| path: "install" | |
| linux: | |
| needs: meta | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| arch: [aarch64, x86_64] | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Set platform variables | |
| id: platform | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.arch }}" = "x86_64" ]; then | |
| echo "tag=x64" >> $GITHUB_OUTPUT | |
| else | |
| echo "tag=arm64" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Download MaaFramework for Linux | |
| uses: robinraju/release-downloader@v1 | |
| with: | |
| repository: MaaXYZ/MaaFramework | |
| fileName: "MAA-linux-${{ matrix.arch }}*" | |
| tag: ${{ env.MAA_FRAMEWORK_VERSION }} | |
| out-file-path: "deps" | |
| extract: true | |
| - name: Download MFAAvalonia for Linux | |
| id: download_mfa | |
| uses: robinraju/release-downloader@v1 | |
| with: | |
| repository: MaaXYZ/MFAAvalonia | |
| fileName: "MFAAvalonia-*-linux-${{ steps.platform.outputs.tag }}*" | |
| latest: true | |
| out-file-path: "MFA" | |
| extract: true | |
| - name: Clean up MFAAvalonia archive on Linux | |
| shell: bash | |
| run: | | |
| ARCHIVE_FILE_PATH="${{ fromJson(steps.download_mfa.outputs.downloaded_files)[0] }}" | |
| rm -f "${ARCHIVE_FILE_PATH}" | |
| echo "Archive cleanup command executed for MFAAvalonia on Linux." | |
| - name: Remove built-in runtime in MFA | |
| shell: bash | |
| run: | | |
| rm -rf MFA/runtimes | |
| - name: Setup Embed Python on Linux | |
| shell: bash | |
| run: | | |
| python3 tools/ci/setup_embed_python.py | |
| EMBED_PYTHON_PATH="./install/python/bin/python3" | |
| if [ -f "$EMBED_PYTHON_PATH" ]; then | |
| echo "Setting execute permission for $EMBED_PYTHON_PATH" | |
| chmod +x "$EMBED_PYTHON_PATH" | |
| else | |
| echo "Warning: Embedded Python executable not found at $EMBED_PYTHON_PATH. Skipping chmod." | |
| fi | |
| - name: Convert PNG to ICO | |
| shell: bash | |
| run: | | |
| # 安装 ImageMagick(如果未安装) | |
| sudo apt-get update && sudo apt-get install -y imagemagick | |
| # 转换 PNG 到 ICO | |
| convert assets/logo.png -define icon:auto-resize=256,128,64,48,32,24,16 MR3A.ico | |
| - name: Download Python dependencies | |
| shell: bash | |
| run: | | |
| ./install/python/bin/python3 -m pip install -r requirements.txt | |
| - name: Install on Linux | |
| shell: bash | |
| run: | | |
| if [ -d "MFA" ]; then | |
| echo "Copying MFA files to install directory on Linux..." | |
| mkdir -p install | |
| rsync -av --ignore-existing MFA/ install/ | |
| echo "MFA files copied successfully." | |
| else | |
| echo "MFA directory not found on Linux, skipping copy." | |
| fi | |
| # 安装 Python 依赖 | |
| ./install/python/bin/python3 -m pip install -r tools/requirements.txt | |
| ./install/python/bin/python3 tools/ci/install.py ${{ needs.meta.outputs.tag }} linux ${{ matrix.arch }} | |
| - name: Copy custom icons | |
| shell: bash | |
| run: | | |
| # 删除 MFAA 自带的 Assets 文件夹 | |
| if [ -d "install/Assets" ]; then | |
| rm -rf install/Assets | |
| echo "Removed original Assets folder" | |
| fi | |
| # MFAA 版本的图标放根目录 | |
| if [ -f "MR3A.ico" ]; then | |
| cp MR3A.ico install/logo.ico | |
| echo "Copied custom icon to install/logo.ico" | |
| fi | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: MR3A-linux-${{ matrix.arch }}-${{ needs.meta.outputs.tag }} | |
| path: "install" | |
| macos: | |
| needs: meta | |
| strategy: | |
| matrix: | |
| include: | |
| - arch: x86_64 | |
| runner: macos-15-intel | |
| - arch: aarch64 | |
| runner: macos-latest | |
| fail-fast: false | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Set platform variables | |
| id: platform | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.arch }}" = "x86_64" ]; then | |
| echo "tag=x64" >> $GITHUB_OUTPUT | |
| else | |
| echo "tag=arm64" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Download MaaFramework for macOS | |
| uses: robinraju/release-downloader@v1 | |
| with: | |
| repository: MaaXYZ/MaaFramework | |
| fileName: "MAA-macos-${{ matrix.arch }}*" | |
| tag: ${{ env.MAA_FRAMEWORK_VERSION }} | |
| out-file-path: "deps" | |
| extract: true | |
| - name: Download MFAAvalonia for macOS | |
| id: download_mfa | |
| uses: robinraju/release-downloader@v1 | |
| with: | |
| repository: MaaXYZ/MFAAvalonia | |
| fileName: "MFAAvalonia-*-osx-${{ steps.platform.outputs.tag }}*" | |
| latest: true | |
| out-file-path: "MFA" | |
| extract: true | |
| - name: Clean up MFAAvalonia archive on macOS | |
| shell: bash | |
| run: | | |
| ARCHIVE_FILE_PATH="${{ fromJson(steps.download_mfa.outputs.downloaded_files)[0] }}" | |
| rm -f "${ARCHIVE_FILE_PATH}" | |
| echo "Archive cleanup command executed for MFAAvalonia on macOS." | |
| - name: Remove built-in runtime in MFA | |
| shell: bash | |
| run: | | |
| rm -rf MFA/runtimes | |
| - name: Convert PNG to ICO | |
| shell: bash | |
| run: | | |
| # 安装 ImageMagick(如果未安装) | |
| brew install imagemagick | |
| # 转换 PNG 到 ICO | |
| magick convert assets/logo.png -define icon:auto-resize=256,128,64,48,32,24,16 MR3A.ico | |
| - name: Setup Embed Python on macOS | |
| shell: bash | |
| run: | | |
| python3 tools/ci/setup_embed_python.py | |
| EMBED_PYTHON_PATH="./install/python/bin/python3" | |
| if [ -f "$EMBED_PYTHON_PATH" ]; then | |
| echo "Setting execute permission for $EMBED_PYTHON_PATH" | |
| chmod +x "$EMBED_PYTHON_PATH" | |
| else | |
| echo "Warning: Embedded Python executable not found at $EMBED_PYTHON_PATH. Skipping chmod." | |
| fi | |
| - name: Download Python dependencies | |
| shell: bash | |
| run: | | |
| ./install/python/bin/python3 -m pip install -r requirements.txt | |
| - name: Install on macOS | |
| shell: bash | |
| run: | | |
| if [ -d "MFA" ]; then | |
| echo "Copying MFA files to install directory on macOS..." | |
| mkdir -p install | |
| rsync -av --ignore-existing MFA/ install/ | |
| echo "MFA files copied successfully." | |
| else | |
| echo "MFA directory not found on macOS, skipping copy." | |
| fi | |
| # 安装 Python 依赖 | |
| ./install/python/bin/python3 -m pip install -r tools/requirements.txt | |
| ./install/python/bin/python3 tools/ci/install.py ${{ needs.meta.outputs.tag }} macos ${{ matrix.arch }} | |
| - name: Copy custom icons | |
| shell: bash | |
| run: | | |
| # 删除 MFAA 自带的 Assets 文件夹 | |
| if [ -d "install/Assets" ]; then | |
| rm -rf install/Assets | |
| echo "Removed original Assets folder" | |
| fi | |
| # MFAA 版本的图标放根目录 | |
| if [ -f "MR3A.ico" ]; then | |
| cp MR3A.ico install/logo.ico | |
| echo "Copied custom icon to install/logo.ico" | |
| fi | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: MR3A-macos-${{ matrix.arch }}-${{ needs.meta.outputs.tag }} | |
| path: "install" | |
| changelog: | |
| name: Generate changelog | |
| needs: meta | |
| runs-on: ubuntu-latest | |
| outputs: | |
| release_body: ${{ steps.git-cliff.outputs.content }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Generate a changelog | |
| uses: orhun/git-cliff-action@v4 | |
| id: git-cliff | |
| with: | |
| config: .github/cliff.toml | |
| # 正式版:使用 tag-pattern 只匹配正式版标签,包含所有从上一个正式版以来的提交 | |
| # 预发布版:正常生成,只包含从上一个标签以来的提交 | |
| args: >- | |
| -vv --latest --strip header | |
| ${{ needs.meta.outputs.is_prerelease == 'false' && '--tag-pattern "^v[0-9]+\\.[0-9]+\\.[0-9]+$"' || '' }} | |
| env: | |
| OUTPUT: CHANGES.md | |
| GITHUB_REPO: ${{ github.repository }} | |
| release: | |
| if: ${{ needs.meta.outputs.is_release == 'true' }} | |
| needs: [meta, windows, linux, macos, changelog] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: assets | |
| - name: Process and package artifacts | |
| run: | | |
| cd assets | |
| for f in *; do | |
| if [[ $f == *"win"* ]]; then | |
| (cd "$f" && zip -r "../$f.zip" .) | |
| else | |
| echo "Processing Unix artifact: $f" | |
| if [[ -f "$f/MaaPiCli" ]]; then | |
| chmod +x "$f/MaaPiCli" | |
| echo "Set execute permission for $f/MaaPiCli" | |
| fi | |
| find "$f" -type f -name "MFAAvalonia*" -exec chmod +x {} \; 2>/dev/null || true | |
| echo "Set execute permission for all MFAAvalonia files" | |
| find "$f" -type f -name "MFAUpdater*" -exec chmod +x {} \; 2>/dev/null || true | |
| echo "Set execute permission for all MFAUpdater files" | |
| if [[ -f "$f/MR3A" ]]; then | |
| chmod +x "$f/MR3A" | |
| echo "Set execute permission for $f/MR3A" | |
| fi | |
| PYTHON_PATHS=( | |
| "$f/python/bin/python3" | |
| "$f/python/python" | |
| "$f/python/bin/python" | |
| "$f/python/python.exe" | |
| ) | |
| for PYTHON_PATH in "${PYTHON_PATHS[@]}"; do | |
| if [[ -f "$PYTHON_PATH" ]]; then | |
| chmod +x "$PYTHON_PATH" | |
| echo "Set execute permission for $PYTHON_PATH" | |
| fi | |
| done | |
| tar -cpzf "$f.tar.gz" -C "$f" . | |
| echo "Created archive with preserved permissions: $f.tar.gz" | |
| fi | |
| done | |
| - uses: softprops/action-gh-release@v2 | |
| with: | |
| files: assets/* | |
| tag_name: ${{ needs.meta.outputs.tag }} | |
| body: ${{ needs.changelog.outputs.release_body }} | |
| draft: false | |
| prerelease: ${{ needs.meta.outputs.is_prerelease == 'true' }} | |
| - name: Trigger MirrorChyanUploading | |
| if: false | |
| # if: ${{ github.repository_owner == 'MaaXYZ' }} | |
| shell: bash | |
| run: | | |
| gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_release.yml -f tag=${{ needs.meta.outputs.tag }} | |
| gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_release_note.yml -f tag=${{ needs.meta.outputs.tag }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |