Fix actions #41
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 and Release | |
| on: | |
| push: | |
| branches: [main] | |
| paths-ignore: | |
| - 'pubspec.yaml' | |
| workflow_dispatch: | |
| jobs: | |
| quality-checks: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Setup Flutter from submodule | |
| run: | | |
| export PATH="$PATH:$PWD/flutter/bin" | |
| echo "$PWD/flutter/bin" >> $GITHUB_PATH | |
| flutter --version | |
| flutter config --no-analytics | |
| flutter precache | |
| - name: Get dependencies | |
| run: flutter pub get | |
| - name: Verify formatting | |
| run: dart format --set-exit-if-changed lib test | |
| - name: Analyze code | |
| run: flutter analyze lib test | |
| - name: Run tests | |
| run: flutter test | |
| version-bump: | |
| needs: quality-checks | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| build_number: ${{ steps.version.outputs.build_number }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Configure Git | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| - name: Get current version from pubspec.yaml | |
| id: current_version | |
| run: | | |
| CURRENT_VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //' | sed 's/+.*//') | |
| CURRENT_BUILD_NUMBER=$(grep '^version:' pubspec.yaml | sed 's/.*+//') | |
| echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo "current_build_number=$CURRENT_BUILD_NUMBER" >> $GITHUB_OUTPUT | |
| echo "Current version: $CURRENT_VERSION+$CURRENT_BUILD_NUMBER" | |
| - name: Bump version | |
| id: version | |
| run: | | |
| CURRENT_VERSION=${{ steps.current_version.outputs.current_version }} | |
| CURRENT_BUILD_NUMBER=${{ steps.current_version.outputs.current_build_number }} | |
| # Parse version components | |
| IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" | |
| MAJOR=${VERSION_PARTS[0]} | |
| MINOR=${VERSION_PARTS[1]} | |
| PATCH=${VERSION_PARTS[2]} | |
| PATCH=$((PATCH + 1)) | |
| NEW_VERSION="$MAJOR.$MINOR.$PATCH" | |
| NEW_BUILD_NUMBER=$((CURRENT_BUILD_NUMBER + 1)) | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| echo "build_number=$NEW_BUILD_NUMBER" >> $GITHUB_OUTPUT | |
| echo "New version: $NEW_VERSION+$NEW_BUILD_NUMBER" | |
| # Update pubspec.yaml with new version and build number | |
| sed -i "s/^version: .*/version: $NEW_VERSION+$NEW_BUILD_NUMBER/" pubspec.yaml | |
| echo "Updated pubspec.yaml with new version" | |
| - name: Commit and push version bump | |
| run: | | |
| git add pubspec.yaml | |
| git commit -m "Bump version to ${{ steps.version.outputs.version }}+${{ steps.version.outputs.build_number }} [skip ci]" | |
| git push origin main | |
| - name: Create and push tag | |
| run: | | |
| NEW_VERSION=${{ steps.version.outputs.version }} | |
| git tag -a "v$NEW_VERSION" -m "Release version $NEW_VERSION" | |
| git push origin "v$NEW_VERSION" | |
| build-android: | |
| needs: version-bump | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "zulu" | |
| java-version: "17" | |
| - name: Setup Flutter from submodule | |
| run: | | |
| export PATH="$PATH:$PWD/flutter/bin" | |
| echo "$PWD/flutter/bin" >> $GITHUB_PATH | |
| flutter --version | |
| flutter config --no-analytics | |
| flutter precache | |
| - name: Get dependencies | |
| run: flutter pub get | |
| - name: Decode Android keystore | |
| run: | | |
| echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 --decode > android/app/keystore.jks | |
| echo "storePassword=${{ secrets.ANDROID_STORE_PASSWORD }}" > android/key.properties | |
| echo "keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}" >> android/key.properties | |
| echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" >> android/key.properties | |
| echo "storeFile=keystore.jks" >> android/key.properties | |
| - name: Build APK for x86_64 | |
| run: flutter build apk --release --build-name=${{ needs.version-bump.outputs.version }} --build-number=${{ needs.version-bump.outputs.build_number }} --target-platform android-x64 --split-per-abi | |
| - name: Build APK for armeabi-v7a | |
| run: flutter build apk --release --build-name=${{ needs.version-bump.outputs.version }} --build-number=${{ needs.version-bump.outputs.build_number }} --target-platform android-arm --split-per-abi | |
| - name: Build APK for arm64 | |
| run: flutter build apk --release --build-name=${{ needs.version-bump.outputs.version }} --build-number=${{ needs.version-bump.outputs.build_number }} --target-platform android-arm64 --split-per-abi | |
| - name: Build App Bundle | |
| run: flutter build appbundle --release --build-name=${{ needs.version-bump.outputs.version }} --build-number=${{ needs.version-bump.outputs.build_number }} | |
| - name: Upload APK artifact | |
| if: github.actor != 'nektos/act' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: android-apk | |
| path: build/app/outputs/flutter-apk/app-*-release.apk | |
| - name: Upload AAB artifact | |
| if: github.actor != 'nektos/act' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: android-aab | |
| path: build/app/outputs/bundle/release/app-release.aab | |
| build-ios: | |
| needs: version-bump | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Setup Flutter from submodule | |
| run: | | |
| export PATH="$PATH:$PWD/flutter/bin" | |
| echo "$PWD/flutter/bin" >> $GITHUB_PATH | |
| flutter --version | |
| flutter config --no-analytics | |
| flutter precache --ios | |
| - name: Get dependencies | |
| run: flutter pub get | |
| - name: Build iOS (no signing) | |
| run: | | |
| flutter build ios --release --no-codesign --build-name=${{ needs.version-bump.outputs.version }} | |
| - name: Create iOS archive | |
| run: | | |
| cd build/ios/iphoneos | |
| zip -r ../../../block_drop_ios_${{ needs.version-bump.outputs.version }}.zip Runner.app | |
| - name: Upload iOS artifact | |
| if: github.actor != 'nektos/act' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ios-app | |
| path: block_drop_ios_${{ needs.version-bump.outputs.version }}.zip | |
| build-macos: | |
| needs: version-bump | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Setup Flutter from submodule | |
| run: | | |
| export PATH="$PATH:$PWD/flutter/bin" | |
| echo "$PWD/flutter/bin" >> $GITHUB_PATH | |
| flutter --version | |
| flutter config --no-analytics | |
| flutter precache --macos | |
| - name: Get dependencies | |
| run: flutter pub get | |
| - name: Build macOS | |
| run: flutter build macos --release --build-name=${{ needs.version-bump.outputs.version }} | |
| - name: Create macOS archive | |
| run: | | |
| cd build/macos/Build/Products/Release | |
| zip -r ../../../../../block_drop_macos_${{ needs.version-bump.outputs.version }}.zip block_drop.app | |
| - name: Upload macOS artifact | |
| if: github.actor != 'nektos/act' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-app | |
| path: block_drop_macos_${{ needs.version-bump.outputs.version }}.zip | |
| build-windows: | |
| needs: version-bump | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Setup Flutter from submodule | |
| run: | | |
| $env:PATH = "$env:PATH;$PWD\flutter\bin" | |
| echo "$PWD\flutter\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| flutter --version | |
| flutter config --no-analytics | |
| flutter precache --windows | |
| - name: Get dependencies | |
| run: flutter pub get | |
| - name: Build Windows | |
| run: flutter build windows --release --build-name=${{ needs.version-bump.outputs.version }} | |
| - name: Create Windows archive | |
| run: | | |
| cd build/windows/x64/runner/Release | |
| 7z a ../../../../../block_drop_windows_${{ needs.version-bump.outputs.version }}.zip * | |
| - name: Upload Windows artifact | |
| if: github.actor != 'nektos/act' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-app | |
| path: block_drop_windows_${{ needs.version-bump.outputs.version }}.zip | |
| build-linux: | |
| needs: version-bump | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Install Linux dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev | |
| - name: Setup Flutter from submodule | |
| run: | | |
| export PATH="$PATH:$PWD/flutter/bin" | |
| echo "$PWD/flutter/bin" >> $GITHUB_PATH | |
| flutter --version | |
| flutter config --no-analytics | |
| flutter precache --linux | |
| - name: Get dependencies | |
| run: flutter pub get | |
| - name: Build Linux | |
| run: flutter build linux --release --build-name=${{ needs.version-bump.outputs.version }} | |
| - name: Create Linux archive | |
| run: | | |
| cd build/linux/x64/release/bundle | |
| tar -czf ../../../../../block_drop_linux_${{ needs.version-bump.outputs.version }}.tar.gz * | |
| - name: Upload Linux artifact | |
| if: github.actor != 'nektos/act' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-app | |
| path: block_drop_linux_${{ needs.version-bump.outputs.version }}.tar.gz | |
| build-web: | |
| needs: version-bump | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Setup Flutter from submodule | |
| run: | | |
| export PATH="$PATH:$PWD/flutter/bin" | |
| echo "$PWD/flutter/bin" >> $GITHUB_PATH | |
| flutter --version | |
| flutter config --no-analytics | |
| flutter precache --web | |
| - name: Get dependencies | |
| run: flutter pub get | |
| - name: Build Web | |
| run: flutter build web --release --build-name=${{ needs.version-bump.outputs.version }} | |
| - name: Create Web archive | |
| run: | | |
| cd build/web | |
| zip -r ../../block_drop_web_${{ needs.version-bump.outputs.version }}.zip * | |
| - name: Upload Web artifact | |
| if: github.actor != 'nektos/act' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: web-app | |
| path: block_drop_web_${{ needs.version-bump.outputs.version }}.zip | |
| create-release: | |
| needs: | |
| [ | |
| version-bump, | |
| build-android, | |
| build-ios, | |
| build-macos, | |
| build-windows, | |
| build-linux, | |
| build-web, | |
| ] | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get Flutter version from submodule | |
| id: flutter_version | |
| run: | | |
| FLUTTER_VERSION=$(cd flutter && git describe --tags --exact-match HEAD 2>/dev/null || git rev-parse --short HEAD) | |
| echo "flutter_version=$FLUTTER_VERSION" >> $GITHUB_OUTPUT | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.version-bump.outputs.version }} | |
| name: Block Drop v${{ needs.version-bump.outputs.version }} | |
| body: | | |
| - **Android APKs**: Multiple APKs are provided for different CPU architectures: | |
| - `arm64-v8a`: Most common for modern Android phones and tablets | |
| - `armeabi-v7a`: For older devices with 32-bit ARM processors | |
| - `x86_64`: For emulators or some rare x86 Android devices | |
| - **Android AAB**: Optimized for Google Play — lets the Play Store deliver architecture-specific APKs automatically. | |
| - **iOS**: iOS builds require signing before installation (not publicly distributed here). | |
| - **macOS** / **Windows** / **Linux**: Native desktop builds. | |
| - **Web**: Web version for browser access. Unzip and serve with a local web server. | |
| Built with Flutter ${{ steps.flutter_version.outputs.flutter_version }} | |
| draft: false | |
| prerelease: false | |
| files: | | |
| artifacts/android-apk/app-*-release.apk | |
| artifacts/android-aab/app-release.aab | |
| artifacts/ios-app/block_drop_ios_${{ needs.version-bump.outputs.version }}.zip | |
| artifacts/macos-app/block_drop_macos_${{ needs.version-bump.outputs.version }}.zip | |
| artifacts/windows-app/block_drop_windows_${{ needs.version-bump.outputs.version }}.zip | |
| artifacts/linux-app/block_drop_linux_${{ needs.version-bump.outputs.version }}.tar.gz | |
| artifacts/web-app/block_drop_web_${{ needs.version-bump.outputs.version }}.zip |