This commit is contained in:
rang 2025-10-25 15:43:13 +08:00
parent f5e7113239
commit fac5ddda79

View file

@ -9,158 +9,194 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
test: # test:
name: Test # name: Test
runs-on: ubuntu-latest # runs-on: ubuntu-latest
steps: # steps:
- name: Checkout repository # - name: Checkout repository
uses: actions/checkout@v4 # uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Flutter Environment
uses: ./.github/actions/flutter-setup # Path to the composite action directory
# Pass inputs if needed (optional, using defaults here)
# with: # with:
# flutter-channel: 'stable' # submodules: recursive
# java-version: '17'
# Debug: Echo current directory contents
- name: List root directory contents
run: |
pwd
ls -la
# Debug: Recursive directory structure # - name: Setup Flutter Environment
- name: Show full directory structure # uses: ./.github/actions/flutter-setup # Path to the composite action directory
run: | # # Pass inputs if needed (optional, using defaults here)
echo "Full directory structure:" # # with:
tree -L 3 # # flutter-channel: 'stable'
# # java-version: '17'
# # Debug: Echo current directory contents
# - name: List root directory contents
# run: |
# pwd
# ls -la
# Debug: Submodule status and details # # Debug: Recursive directory structure
- name: Check submodule status # - name: Show full directory structure
run: | # run: |
echo "Submodule status:" # echo "Full directory structure:"
git submodule status # tree -L 3
echo "\nSubmodule details:" # # Debug: Submodule status and details
git submodule foreach 'echo $path: && pwd && ls -la' # - name: Check submodule status
# run: |
# echo "Submodule status:"
# git submodule status
# - name: Run static analysis # echo "\nSubmodule details:"
# run: flutter analyze # git submodule foreach 'echo $path: && pwd && ls -la'
- name: Check formatting # # - name: Run static analysis
run: | # # run: flutter analyze
dart format -o none --set-exit-if-changed lib/
- name: Run tests # - name: Check formatting
run: flutter test # run: |
# dart format -o none --set-exit-if-changed lib/
build_android: # - name: Run tests
name: Build Android APKs # run: flutter test
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Flutter Environment
uses: ./.github/actions/flutter-setup # Path to the composite action directory
with:
flutter-channel: stable
java-version: 17
- name: Accept Android SDK Licenses # build_android:
run: | # name: Build Android APKs
yes | sudo $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses # needs: test
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# with:
# submodules: recursive
# - name: Setup Flutter Environment
# uses: ./.github/actions/flutter-setup # Path to the composite action directory
# with:
# flutter-channel: stable
# java-version: 17
- name: Decode android/upload.jks # - name: Accept Android SDK Licenses
run: echo "${{ secrets.UPLOAD_KEYSTORE_JKS }}" | base64 --decode > android/upload.jks # run: |
# yes | sudo $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses
- name: Decode android/key.properties # - name: Decode android/upload.jks
run: echo "${{ secrets.KEY_PROPERTIES }}" | base64 --decode > android/key.properties # run: echo "${{ secrets.UPLOAD_KEYSTORE_JKS }}" | base64 --decode > android/upload.jks
- name: Build APKs # - name: Decode android/key.properties
run: flutter build apk --release --split-per-abi # run: echo "${{ secrets.KEY_PROPERTIES }}" | base64 --decode > android/key.properties
- name: Build Universal APK # - name: Build APKs
run: flutter build apk --release # run: flutter build apk --release --split-per-abi
- name: Rename Universal APK # - name: Build Universal APK
run: mv build/app/outputs/flutter-apk/{app-release,app-universal-release}.apk # run: flutter build apk --release
- name: Build App Bundle # - name: Rename Universal APK
run: flutter build appbundle --release # run: mv build/app/outputs/flutter-apk/{app-release,app-universal-release}.apk
- name: Upload Android APK Artifact # - name: Build App Bundle
uses: actions/upload-artifact@v4 # run: flutter build appbundle --release
with:
name: android-release-artifacts
path: |
build/app/outputs/flutter-apk/*-release*.apk
build/app/outputs/bundle/release/*.aab
build_linux: # - name: Upload Android APK Artifact
needs: test # uses: actions/upload-artifact@v4
runs-on: ubuntu-latest # with:
# name: android-release-artifacts
# path: |
# build/app/outputs/flutter-apk/*-release*.apk
# build/app/outputs/bundle/release/*.aab
steps: # build_linux:
- name: Checkout repository # needs: test
uses: actions/checkout@v4 # runs-on: ubuntu-latest
with:
submodules: recursive
- name: Setup Flutter Environment
uses: ./.github/actions/flutter-setup # Path to the composite action directory
- name: Install Linux dependencies # steps:
run: | # - name: Checkout repository
sudo apt-get update -y # uses: actions/checkout@v4
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev locate libfuse2 # with:
# Download and install appimagetool # submodules: recursive
wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage # - name: Setup Flutter Environment
chmod +x appimagetool-x86_64.AppImage # uses: ./.github/actions/flutter-setup # Path to the composite action directory
sudo mv appimagetool-x86_64.AppImage /usr/local/bin/appimagetool
shell: bash
- name: setup fastforge
run: |
dart pub global activate fastforge
- name: Build Linux AppImage and deb
run: fastforge package --platform linux --targets deb,appimage
- name: Rename Linux Artifacts # - name: Install Linux dependencies
run: | # run: |
# Find and rename .deb file # sudo apt-get update -y
DEB_FILE=$(find dist/ -name "*.deb" -type f) # sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev locate libfuse2
if [ -n "$DEB_FILE" ]; then # # Download and install appimagetool
mv "$DEB_FILE" dist/vaani-linux-amd64.deb # wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
echo "Renamed DEB: $DEB_FILE to dist/vaani-linux-amd64.deb" # chmod +x appimagetool-x86_64.AppImage
else # sudo mv appimagetool-x86_64.AppImage /usr/local/bin/appimagetool
echo "Error: .deb file not found in dist/" # shell: bash
exit 1 # - name: setup fastforge
fi # run: |
# dart pub global activate fastforge
# - name: Build Linux AppImage and deb
# run: fastforge package --platform linux --targets deb,appimage
# Find and rename .AppImage file # - name: Rename Linux Artifacts
APPIMAGE_FILE=$(find dist/ -name "*.AppImage" -type f) # run: |
if [ -n "$APPIMAGE_FILE" ]; then # # Find and rename .deb file
mv "$APPIMAGE_FILE" dist/vaani-linux-amd64.AppImage # DEB_FILE=$(find dist/ -name "*.deb" -type f)
echo "Renamed AppImage: $APPIMAGE_FILE to dist/vaani-linux-amd64.AppImage" # if [ -n "$DEB_FILE" ]; then
else # mv "$DEB_FILE" dist/vaani-linux-amd64.deb
echo "Error: .AppImage file not found in dist/" # echo "Renamed DEB: $DEB_FILE to dist/vaani-linux-amd64.deb"
exit 1 # else
fi # echo "Error: .deb file not found in dist/"
shell: bash # exit 1
# fi
- name: Upload Linux Artifacts # # Find and rename .AppImage file
uses: actions/upload-artifact@v4 # APPIMAGE_FILE=$(find dist/ -name "*.AppImage" -type f)
with: # if [ -n "$APPIMAGE_FILE" ]; then
name: linux-release-artifacts # mv "$APPIMAGE_FILE" dist/vaani-linux-amd64.AppImage
path: | # echo "Renamed AppImage: $APPIMAGE_FILE to dist/vaani-linux-amd64.AppImage"
dist/vaani-linux-amd64.deb # else
dist/vaani-linux-amd64.AppImage # echo "Error: .AppImage file not found in dist/"
# exit 1
# fi
# shell: bash
build_windows: # - name: Upload Linux Artifacts
needs: test # uses: actions/upload-artifact@v4
runs-on: windows-latest # with:
# name: linux-release-artifacts
# path: |
# dist/vaani-linux-amd64.deb
# dist/vaani-linux-amd64.AppImage
# build_windows:
# needs: test
# runs-on: windows-latest
# permissions:
# contents: write
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# with:
# submodules: recursive
# - name: Setup Flutter
# uses: subosito/flutter-action@v2
# with:
# flutter-version: "3.32.0"
# cache: true
# - name: Restore Packages
# run: |
# flutter pub get
# - name: Install flutter_distributor
# run: dart pub global activate flutter_distributor
# - name: Build Windows
# run: |
# flutter_distributor package --platform windows --targets msix,zip --skip-clean
# - name: Upload Windows Artifacts
# uses: actions/upload-artifact@v4
# with:
# name: windows-release-artifacts
# path: |
# dist/*/*.msix
# dist/*/*.zip
build_macos:
# needs: test
runs-on: macos-latest
permissions: permissions:
contents: write contents: write
steps: steps:
@ -168,34 +204,41 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
submodules: recursive submodules: recursive
- name: Setup Flutter - name: Setup Flutter
uses: subosito/flutter-action@v2 uses: subosito/flutter-action@v2
with: with:
flutter-version: "3.32.0" flutter-version: "3.32.0"
cache: true cache: true
- name: Restore Packages
- name: Restore packages
run: | run: |
flutter pub get flutter pub get
- name: Install appdmg
run: npm install -g appdmg
- name: Install flutter_distributor - name: Install flutter_distributor
run: dart pub global activate flutter_distributor run: dart pub global activate flutter_distributor
- name: Build Windows - name: Build MacOS
run: | run: |
flutter_distributor package --platform windows --targets msix,zip --skip-clean flutter_distributor package --platform macos --targets dmg,zip --skip-clean
- name: Upload Windows Artifacts - name: Upload MacOS to Artifacts
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: windows-release-artifacts name: macos-release-artifacts
path: | path: |
dist/*/*.msix dist/*/*.dmg
dist/*/*.zip dist/*/*.zip
# Job 4: Create GitHub Release (NEW - runs only on tag pushes) # Job 4: Create GitHub Release (NEW - runs only on tag pushes)
create_release: create_release:
name: Create GitHub Release name: Create GitHub Release
needs: [build_android, build_linux, build_windows] # Depends on successful builds # needs: [build_android, build_linux, build_windows, build_macos] # Depends on successful builds
needs: build_macos # Depends on successful builds
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: write # Need write access to create release contents: write # Need write access to create release
@ -220,12 +263,18 @@ jobs:
name: linux-release-artifacts name: linux-release-artifacts
path: ./release-artifacts/linux path: ./release-artifacts/linux
- name: Download Linux Artifacts - name: Download Windows Artifacts
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: windows-release-artifacts name: windows-release-artifacts
path: ./release-artifacts/windows path: ./release-artifacts/windows
- name: Download Macos Artifacts
uses: actions/download-artifact@v4
with:
name: macos-release-artifacts
path: ./release-artifacts/macos
- name: List downloaded files (for debugging) - name: List downloaded files (for debugging)
run: ls -R ./release-artifacts run: ls -R ./release-artifacts
shell: bash shell: bash