flutter 3.10.0 #92
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: Build Windows | |
| on: | |
| push: | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build Windows | |
| runs-on: windows-latest | |
| steps: | |
| - name: 签出仓库 | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: 初始化 GitVersion | |
| uses: gittools/actions/gitversion/[email protected] | |
| with: | |
| versionSpec: '6.0.x' | |
| - name: 计算版本 Version | |
| id: gitversion | |
| uses: gittools/actions/gitversion/[email protected] | |
| with: | |
| overrideConfig: | | |
| assembly-versioning-scheme=MajorMinorPatchTag | |
| assembly-file-versioning-format="{Major}.{Minor}.{Patch}.{BuildMetaData ?? 0}" | |
| - name: 初始化 Flutter 环境 | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: stable | |
| cache: true | |
| architecture: x64 | |
| - name: 初始化 Rust 工具链 | |
| uses: actions-rust-lang/[email protected] | |
| - name: 还原依赖 | |
| run: flutter pub get | |
| - name: 生成代码 | |
| run: dart run build_runner build --delete-conflicting-outputs | |
| - name: 构建项目 | |
| shell: pwsh | |
| run: |- | |
| flutter build windows ` | |
| --build-name=${{ steps.gitversion.outputs.majorMinorPatch }} ` | |
| --build-number=${{ steps.gitversion.outputs.buildMetaData }} | |
| - name: 上传产物 | |
| id: binary-artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binary | |
| path: build/windows/x64/runner/Release/**/* | |
| compression-level: 9 | |
| - name: 还原证书 | |
| id: restore-cert | |
| shell: pwsh | |
| if: env.CERTIFICATE != '' | |
| env: | |
| CERTIFICATE: ${{ secrets.CERTIFICATE }} | |
| CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }} | |
| run: |- | |
| $certFile = (New-TemporaryFile).FullName + '.pfx' | |
| [System.IO.File]::WriteAllBytes($certFile, [System.Convert]::FromBase64String($env:CERTIFICATE)) | |
| $Private:Password = ConvertTo-SecureString -String $env:CERTIFICATE_PASSWORD -AsPlainText | |
| $Private:Certificate = Get-PfxCertificate $certFile -Password $Private:Password | |
| $Private:Certificate.Subject | |
| Write-Output "CERTIFICATE_PATH=$certFile" >> "$env:GITHUB_OUTPUT" | |
| Write-Output "CERTIFICATE_SUBJECT=$($Private:Certificate.Subject)" >> "$env:GITHUB_OUTPUT" | |
| - name: 构建 MSIX | |
| id: msix | |
| shell: pwsh | |
| if: steps.restore-cert.conclusion == 'success' | |
| env: | |
| CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }} | |
| run: |- | |
| dart run msix:create ` | |
| --certificate-path '${{ steps.restore-cert.outputs.CERTIFICATE_PATH }}' ` | |
| --certificate-password $env:CERTIFICATE_PASSWORD ` | |
| --build-windows false ` | |
| --version '${{ steps.gitversion.outputs.assemblySemVer }}' ` | |
| --publisher '${{ steps.restore-cert.outputs.CERTIFICATE_SUBJECT }}' | |
| - name: 上传 MSIX | |
| id: msix-artifact | |
| if: steps.msix.conclusion == 'success' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: msix | |
| path: build/windows/x64/runner/Release/pixez.msix | |
| compression-level: 9 | |
| - name: 生成 MSIX 安装器 | |
| id: installer | |
| if: steps.msix.conclusion == 'success' | |
| uses: frg2089/MsixInstaller@v2 | |
| with: | |
| msix: build/windows/x64/runner/Release/pixez.msix | |
| - name: 上传 MSIX 安装器 | |
| id: installer-artifact | |
| if: steps.installer.conclusion == 'success' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: installer | |
| path: ${{ steps.installer.outputs.path }} | |
| compression-level: 9 | |
| - name: 生成校验和 | |
| shell: pwsh | |
| run: |- | |
| Write-Output '### Build Success :rocket:' >> $env:GITHUB_STEP_SUMMARY | |
| if ($env:CERTIFICATE_SUBJECT) { | |
| Write-Output "Publisher: $env:CERTIFICATE_SUBJECT" >> $env:GITHUB_STEP_SUMMARY | |
| } | |
| Write-Output '|File|SHA256|' >> $env:GITHUB_STEP_SUMMARY | |
| Write-Output '|:-|:-:|' >> $env:GITHUB_STEP_SUMMARY | |
| Write-Output "|[binary](${{ steps.binary-artifact.outputs.artifact-url }})|${{ steps.binary-artifact.outputs.artifact-digest }}|" >> $env:GITHUB_STEP_SUMMARY | |
| if ('${{ steps.msix-artifact.conclusion }}' -eq 'success') { | |
| Write-Output "|[msix](${{ steps.msix-artifact.outputs.artifact-url }})|${{ steps.msix-artifact.outputs.artifact-digest }}|" >> $env:GITHUB_STEP_SUMMARY | |
| } | |
| if ('${{ steps.installer-artifact.conclusion }}' -eq 'success') { | |
| Write-Output "|[installer](${{ steps.installer-artifact.outputs.artifact-url }})|${{ steps.installer-artifact.outputs.artifact-digest }}|" >> $env:GITHUB_STEP_SUMMARY | |
| } | |
| Write-Output '' >> $env:GITHUB_STEP_SUMMARY | |
| Write-Output '### MSIX 安装教程' >> $env:GITHUB_STEP_SUMMARY | |
| Write-Output '' >> $env:GITHUB_STEP_SUMMARY |