fix(*) #167
Workflow file for this run
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: app-build-action | |
| # 推送Tag时触发 或者 手动触发 | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag_name: | |
| description: 'Tag name for the release' | |
| required: false | |
| default: 'v1.0.0' | |
| push: | |
| tags: | |
| - "v*" | |
| jobs: | |
| build-android: | |
| runs-on: macos-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| # 签出代码 | |
| - name: 签出代码 | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.tag_name }} | |
| # APK签名设置 | |
| - name: 下载Android keystore | |
| id: android_keystore | |
| uses: timheuer/base64-to-file@v1.2 | |
| with: | |
| fileName: key.jks | |
| encodedString: ${{ secrets.KEYSTORE_BASE64 }} | |
| - name: 创建key.properties | |
| run: | | |
| echo "storeFile=${{ steps.android_keystore.outputs.filePath }}" > android/key.properties | |
| echo "storePassword=${{ secrets.STORE_PASSWORD }}" >> android/key.properties | |
| echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties | |
| echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties | |
| # 设置JAVA环境 | |
| - name: 设置JAVA环境 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'zulu' | |
| java-version: "17" | |
| cache: 'gradle' | |
| # 设置Flutter | |
| - name: 设置Flutter环境 | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: stable | |
| cache: true | |
| # 更新Flutter的packages | |
| - name: 更新Flutter的packages | |
| run: flutter pub get | |
| # 打包APK | |
| - name: 打包APK | |
| run: flutter build apk --release --split-per-abi | |
| # 上传APK至Artifacts | |
| - name: 上传APK至Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: android | |
| path: | | |
| build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk | |
| build/app/outputs/flutter-apk/app-arm64-v8a-release.apk | |
| build/app/outputs/flutter-apk/app-x86_64-release.apk | |
| # 读取版本信息 | |
| - name: 读取版本信息 | |
| id: version | |
| uses: juliangruber/read-file-action@v1 | |
| with: | |
| path: assets/version.json | |
| # 上传至Release | |
| - name: 上传至Release | |
| uses: softprops/action-gh-release@v2.2.1 | |
| with: | |
| name: "${{ github.event.inputs.tag_name }}" | |
| body: "${{ fromJson(steps.version.outputs.content).version_desc }}" | |
| prerelease: false | |
| token: ${{ secrets.TOKEN }} | |
| files: | | |
| build/app/outputs/flutter-apk/app-x86_64-release.apk | |
| build/app/outputs/flutter-apk/app-arm64-v8a-release.apk | |
| build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk | |
| # 完成 | |
| - name: 输出任务状态 | |
| if: always() | |
| run: echo "🍏 Android job's status is ${{ job.status }}." | |
| build-windows: | |
| runs-on: windows-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| # 签出代码 | |
| - name: 签出代码 | |
| uses: actions/checkout@v4 | |
| with: | |
| channel: stable | |
| # 设置Flutter环境 | |
| - name: 设置Flutter环境 | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: stable | |
| cache: true | |
| - name: 启用Flutter桌面支持 | |
| run: flutter config --enable-windows-desktop | |
| - name: 更新Flutter的packages | |
| run: flutter pub get | |
| # 安装 Inno Setup 6(fastforge 的依赖) | |
| - name: Install Inno Setup 6 | |
| run: | | |
| $url = "https://jrsoftware.org/download.php/is.exe" | |
| $output = "${{ runner.temp }}\innosetup.exe" | |
| Write-Host "Downloading Inno Setup 6..." | |
| Invoke-WebRequest -Uri $url -OutFile $output | |
| Write-Host "Installing Inno Setup 6..." | |
| Start-Process -FilePath $output -ArgumentList "/VERYSILENT", "/SUPPRESSMSGBOXES", "/NORESTART" -Wait | |
| # 添加到PATH | |
| $innoPath = "C:\Program Files (x86)\Inno Setup 6" | |
| echo "$innoPath" >> $env:GITHUB_PATH | |
| - name: Copy Chinese language pack | |
| run: | | |
| $sourceFile = "windows\packaging\exe\ChineseSimplified.isl" | |
| $targetDir = "C:\Program Files (x86)\Inno Setup 6\Languages" | |
| $targetFile = "$targetDir\ChineseSimplified.isl" | |
| if (Test-Path $sourceFile) { | |
| Copy-Item $sourceFile $targetFile -Force | |
| Write-Host "Chinese language pack copied successfully" | |
| } else { | |
| Write-Host "Chinese language pack not found in project" | |
| } | |
| # 安装 fastforge | |
| - name: Install fastforge | |
| run: dart pub global activate fastforge | |
| # 获取 Flutter 版本号 | |
| - name: Get Flutter app version from pubspec.yaml | |
| id: get_version | |
| shell: pwsh | |
| run: | | |
| $lines = Get-Content pubspec.yaml | |
| foreach ($line in $lines) { | |
| if ($line -match '^\s*version:\s*(\S+)') { | |
| $v = $matches[1] -replace '[`"''`]', '' | |
| "version=$v" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
| Write-Host "✅ Version: $v" | |
| exit 0 | |
| } | |
| } | |
| Write-Error "Version not found" | |
| exit 1 | |
| # 使用 fastforge 打包 Windows exe | |
| - name: Package Windows exe | |
| run: fastforge package --platform windows --targets exe | |
| # 重命名生成的安装程序 | |
| - name: Rename Windows installer | |
| run: | | |
| $VERSION = "${{ steps.get_version.outputs.version }}" | |
| # fastforge 生成的文件通常在 dist 目录中 | |
| $DIST_DIR = "dist\$VERSION" | |
| $INSTALLER_NAME = "PureLive-$VERSION-windows-x64-setup.exe" | |
| # 查找生成的 exe 文件 | |
| Get-ChildItem "$DIST_DIR" -Filter "*.exe" | ForEach-Object { | |
| $SRC = $_.FullName | |
| Write-Host "Found installer: $SRC" | |
| Copy-Item $SRC $INSTALLER_NAME -Force | |
| Write-Host "Renamed to: $INSTALLER_NAME" | |
| } | |
| # 上传Windows应用至Artifacts | |
| - name: 上传Windows应用至Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-installer | |
| path: PureLive-${{ steps.get_version.outputs.version }}-windows-x64-setup.exe | |
| retention-days: 1 | |
| # 读取版本信息 | |
| - name: 读取版本信息 | |
| id: version | |
| uses: juliangruber/read-file-action@v1 | |
| with: | |
| path: assets/version.json | |
| # 上传至Release | |
| - name: 上传至Release | |
| uses: softprops/action-gh-release@v2.2.1 | |
| with: | |
| name: "${{ github.event.inputs.tag_name }}" | |
| body: "${{ fromJson(steps.version.outputs.content).version_desc }}" | |
| prerelease: false | |
| token: ${{ secrets.TOKEN }} | |
| files: | | |
| PureLive-${{ steps.get_version.outputs.version }}-windows-x64-setup.exe | |
| # 完成 | |
| - name: 输出任务状态 | |
| if: always() | |
| run: echo "🍏 Windows job's status is ${{ job.status }}." | |
| build-macos: | |
| runs-on: macos-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| # 签出代码 | |
| - name: 签出代码 | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.tag_name }} | |
| # 设置Flutter | |
| - name: 设置Flutter环境 | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: stable | |
| cache: true | |
| # 更新Flutter的packages | |
| - name: 更新Flutter的packages | |
| run: flutter pub get | |
| - name: Build macOS Release | |
| run: flutter build macos --release | |
| # 获取 Flutter 版本号 | |
| - name: Get Flutter app version from pubspec.yaml | |
| id: get_version | |
| shell: pwsh | |
| run: | | |
| $lines = Get-Content pubspec.yaml | |
| foreach ($line in $lines) { | |
| if ($line -match '^\s*version:\s*(\S+)') { | |
| $v = $matches[1] -replace '[`"''`]', '' | |
| "version=$v" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
| Write-Host "✅ Version: $v" | |
| exit 0 | |
| } | |
| } | |
| Write-Error "Version not found" | |
| exit 1 | |
| - name: Install create-dmg | |
| run: brew install create-dmg | |
| - name: Create DMG | |
| run: | | |
| create-dmg \ | |
| --volname "PureLive" \ | |
| --window-pos 200 120 \ | |
| --window-size 800 400 \ | |
| --icon-size 100 \ | |
| --app-drop-link 600 185 \ | |
| "PureLive-${{ steps.get_version.outputs.version }}-macOS.dmg" \ | |
| "build/macos/Build/Products/Release/纯粹直播.app" | |
| working-directory: ./ | |
| # 上传 DMG 至 Artifacts | |
| - name: 上传 DMG 至 Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: macOS | |
| path: PureLive-${{ steps.get_version.outputs.version }}-macOS.dmg | |
| # 读取版本信息 | |
| - name: 读取版本信息 | |
| id: version | |
| uses: juliangruber/read-file-action@v1 | |
| with: | |
| path: assets/version.json | |
| # 上传至 Release | |
| - name: 上传至 Release | |
| uses: softprops/action-gh-release@v2.2.1 | |
| with: | |
| name: "${{ github.event.inputs.tag_name }}" | |
| body: "${{ fromJson(steps.version.outputs.content).version_desc }}" | |
| prerelease: false | |
| token: ${{ secrets.TOKEN }} | |
| files: | | |
| PureLive-${{ steps.get_version.outputs.version }}-macOS.dmg | |
| # 完成 | |
| - name: 输出任务状态 | |
| if: always() | |
| run: echo "🍏 macOS job's status is ${{ job.status }}." |