release shell #16
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: Build Multi Platform | |
| permissions: | |
| contents: write | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: ["master"] | |
| tags: ["v*"] | |
| jobs: | |
| build-desktop: | |
| name: Build ${{ matrix.platform.name }} | |
| runs-on: ${{ matrix.platform.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - name: linux | |
| os: ubuntu-latest | |
| build_command: flutter build linux --release | |
| artifact_base: ailurus-linux | |
| package_extension: AppImage | |
| - name: windows | |
| os: windows-latest | |
| build_command: flutter build windows --release | |
| artifact_base: ailurus-windows | |
| package_extension: zip | |
| - name: macos | |
| os: macos-latest | |
| build_command: flutter build macos --release | |
| artifact_base: ailurus-macos | |
| package_extension: dmg | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: stable | |
| cache: true | |
| - name: Install Linux dependencies | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev | |
| - name: Enable desktop targets | |
| run: | | |
| flutter config --enable-linux-desktop | |
| flutter config --enable-windows-desktop | |
| flutter config --enable-macos-desktop | |
| - name: Get dependencies | |
| run: flutter pub get | |
| - name: Resolve package name | |
| id: package_meta | |
| shell: bash | |
| run: | | |
| APP_VERSION=$(grep '^version:' pubspec.yaml | sed 's/version:[[:space:]]*//' | cut -d+ -f1) | |
| echo "name=${{ matrix.platform.artifact_base }}-${APP_VERSION}.${{ matrix.platform.package_extension }}" >> "$GITHUB_OUTPUT" | |
| - name: Build desktop app | |
| run: ${{ matrix.platform.build_command }} | |
| - name: Package Linux AppImage | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get install -y desktop-file-utils wget | |
| rm -rf AppDir dist | |
| mkdir -p AppDir/usr dist | |
| cp build/linux/x64/release/bundle/ailurus AppDir/usr/ | |
| cp -r build/linux/x64/release/bundle/lib AppDir/usr/ | |
| cp -r build/linux/x64/release/bundle/data AppDir/usr/ | |
| cp assets/icons/app_icon_source.png AppDir/ailurus.png | |
| cat > AppDir/AppRun <<'EOF' | |
| #!/bin/sh | |
| HERE="$(dirname "$(readlink -f "$0")")" | |
| exec "$HERE/usr/ailurus" "$@" | |
| EOF | |
| chmod +x AppDir/AppRun | |
| cat > AppDir/ailurus.desktop <<'EOF' | |
| [Desktop Entry] | |
| Type=Application | |
| Name=Ailurus | |
| Exec=ailurus | |
| Icon=ailurus | |
| Categories=Utility; | |
| Terminal=false | |
| EOF | |
| desktop-file-validate AppDir/ailurus.desktop | |
| wget -q https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool.AppImage | |
| chmod +x appimagetool.AppImage | |
| ARCH=x86_64 ./appimagetool.AppImage --appimage-extract-and-run AppDir "dist/${{ steps.package_meta.outputs.name }}" | |
| - name: Package Windows ZIP | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| if (Test-Path dist) { Remove-Item dist -Recurse -Force } | |
| New-Item -ItemType Directory -Path dist | Out-Null | |
| Compress-Archive -Path build/windows/x64/runner/Release/* -DestinationPath "dist/${{ steps.package_meta.outputs.name }}" | |
| - name: Package macOS DMG | |
| if: runner.os == 'macOS' | |
| run: | | |
| rm -rf dist | |
| mkdir -p dist | |
| hdiutil create -volname "Ailurus" -srcfolder "build/macos/Build/Products/Release/ailurus.app" -ov -format UDZO "dist/${{ steps.package_meta.outputs.name }}" | |
| - name: Upload desktop artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.platform.name }}-package | |
| path: dist/${{ steps.package_meta.outputs.name }} | |
| if-no-files-found: error | |
| - name: Upload desktop release asset | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| shell: bash | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1 || gh release create "${GITHUB_REF_NAME}" --generate-notes >/dev/null 2>&1 || true | |
| gh release upload "${GITHUB_REF_NAME}" "dist/${{ steps.package_meta.outputs.name }}" --clobber | |
| build-android-release: | |
| name: Build signed android apk | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| environment: release | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '17' | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: stable | |
| cache: true | |
| - name: Get dependencies | |
| run: flutter pub get | |
| - name: Restore Android keystore | |
| run: | | |
| echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 -d > android/release-keystore.jks | |
| - name: Create key.properties | |
| run: | | |
| cat > android/key.properties <<EOF | |
| storePassword=${{ secrets.ANDROID_STORE_PASSWORD }} | |
| keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }} | |
| keyAlias=${{ secrets.ANDROID_KEY_ALIAS }} | |
| storeFile=release-keystore.jks | |
| EOF | |
| - name: Build signed Android APK | |
| run: flutter build apk --release | |
| - name: Verify APK signature | |
| run: | | |
| BUILD_TOOLS_VERSION=$(ls "$ANDROID_HOME/build-tools" | sort -V | tail -n 1) | |
| "$ANDROID_HOME/build-tools/$BUILD_TOOLS_VERSION/apksigner" verify --print-certs build/app/outputs/flutter-apk/app-release.apk | |
| - name: Generate checksums | |
| run: | | |
| sha256sum build/app/outputs/flutter-apk/app-release.apk > build/app/outputs/flutter-apk/app-release.apk.sha256 | |
| - name: Upload Android artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ailurus-android-signed | |
| path: | | |
| build/app/outputs/flutter-apk/app-release.apk | |
| build/app/outputs/flutter-apk/app-release.apk.sha256 | |
| if-no-files-found: error | |
| - name: Upload Android release assets | |
| shell: bash | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1 || gh release create "${GITHUB_REF_NAME}" --generate-notes >/dev/null 2>&1 || true | |
| gh release upload "${GITHUB_REF_NAME}" \ | |
| build/app/outputs/flutter-apk/app-release.apk \ | |
| build/app/outputs/flutter-apk/app-release.apk.sha256 \ | |
| --clobber |