Build Windows EXE #11
This file contains 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 EXE | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- v* | |
env: | |
APP_NAME: iwrqk | |
permissions: | |
contents: write | |
jobs: | |
build_windows_exe: | |
name: Build EXE | |
runs-on: windows-latest | |
outputs: | |
artifact_name: ${{ steps.set_artifact.outputs.name }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.16' | |
channel: 'stable' | |
- name: Install dependencies | |
run: flutter pub get | |
- name: Build Windows EXE | |
run: flutter build windows --release | |
- name: Verify build files | |
shell: pwsh # 显式声明使用 PowerShell | |
run: | | |
cd build/windows/x64/runner/Release | |
Get-ChildItem # 替代 ls -al | |
if (-not (Test-Path "${{ env.APP_NAME }}.exe")) { | |
Write-Error "EXE file missing!" | |
exit 1 | |
} | |
- name: Generate artifact name | |
id: set_artifact | |
shell: bash | |
run: | | |
timestamp=$(date +%s) | |
echo "name=windows_artifact_${timestamp}_${{ github.run_number }}" >> $GITHUB_OUTPUT | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.set_artifact.outputs.name }} | |
path: | | |
build/windows/x64/runner/Release/${{ env.APP_NAME }}.exe | |
build/windows/x64/runner/Release/*.dll | |
build/windows/x64/runner/Release/data/** | |
if-no-files-found: error | |
retention-days: 1 | |
publish_release: | |
needs: build_windows_exe | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ needs.build_windows_exe.outputs.artifact_name }} | |
- name: Verify downloaded files | |
run: | | |
ls -R | |
[ -f "${{ env.APP_NAME }}.exe" ] || exit 1 | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
${{ env.APP_NAME }}.exe | |
*.dll | |
data/**/* | |
tag_name: ${{ github.ref_name || format('manual-{0}', github.run_id) }} | |
generate_release_notes: true |