Build all flutter archs #68
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 all flutter archs" | |
| on: | |
| workflow_dispatch: | |
| release: | |
| types: [ created ] | |
| jobs: | |
| do_tests: | |
| name: Flutter Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| assets | |
| lib | |
| test | |
| scripts | |
| - uses: subosito/flutter-action@v2 | |
| with: | |
| cache: true | |
| - name: Download dependencies | |
| run: flutter pub get | |
| - name: Run tests | |
| run: flutter test | |
| gen_icons: | |
| name: Generate icons & commit/push them | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Check latest commit to assets | |
| id: assets | |
| # This job should not run when the latest commit to assets is older than 1 day | |
| # This is to reduce unnecessary running minutes | |
| run: | | |
| COMMITS=$(curl -s "https://api.github.com/repos/${{ github.repository }}/commits?path=assets&page=1&per_page=1") | |
| DAYS=$(echo $COMMITS | jq -r "((now - (.[0].commit.committer.date | fromdateiso8601) ) / (60*60*24) | trunc)") | |
| echo "days=$DAYS" >> $GITHUB_OUTPUT | |
| - uses: actions/checkout@v4 | |
| if: steps.assets.output.days == 0 | |
| with: | |
| ref: main | |
| - uses: subosito/flutter-action@v2 | |
| if: steps.assets.output.days == 0 | |
| with: | |
| cache: true | |
| - name: Download dependencies | |
| run: flutter pub get | |
| - name: Generate flutter launcher icons | |
| if: steps.assets.output.days == 0 | |
| run: flutter pub run flutter_launcher_icons | |
| # Commit all changed files back to the repository | |
| - uses: stefanzweifel/git-auto-commit-action@v5 | |
| if: steps.assets.output.days == 0 | |
| with: | |
| commit_message: Generated icon files | |
| file_pattern: '*.xml *.json *.png' | |
| build_web: | |
| name: Build & publish for gh-pages | |
| if: github.event_name == 'release' && always() | |
| runs-on: ubuntu-latest | |
| needs: [ do_tests, gen_icons, build_ios ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Setup node for publishing AltStore repo | |
| uses: actions/setup-node@v1 | |
| with: | |
| node-version: '10.x' | |
| - uses: subosito/flutter-action@v2 | |
| with: | |
| cache: true | |
| - run: flutter pub get | |
| - name: Run altstore-github | |
| run: npx altstore-github --config web/altstore.template.json > web/altstore.json | |
| # Implement this troguh other action - run: dart run sqflite_common_ffi_web:setup | |
| - name: Deploy | |
| uses: bluefireteam/flutter-gh-pages@v9 | |
| with: | |
| compileToWasm: true | |
| baseHref: /${{ github.event.repository.name }}/ | |
| build_ios: | |
| name: Build iOS ipa | |
| needs: [ do_tests, gen_icons ] | |
| runs-on: macos-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: subosito/flutter-action@v2 | |
| with: | |
| cache: true | |
| - uses: maxim-lobanov/setup-xcode@v1 | |
| with: | |
| xcode-version: 16.4 | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| #with: | |
| # sparse-checkout: | | |
| # assets | |
| # lib | |
| # scripts | |
| # ios | |
| - name: Gathering dependencies | |
| run: flutter pub get | |
| - name: Build ios xcarchive | |
| run: flutter build ipa --release --no-codesign | |
| - name: Package xcarchive to ipa | |
| run: | | |
| brew install ldid | |
| chmod +x ${PWD}/scripts/package_ipa.sh | |
| ${PWD}/scripts/package_ipa.sh ${PWD}/build/ios/archive/Runner.xcarchive . | |
| - name: Get current date | |
| id: date | |
| run: echo "date={$(date +'%Y-%m-%d')}" >> $GITHUB_ENV | |
| - name: Push artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: HW-manager-${{ env.date }}.ipa | |
| path: ./hw_manager_flutter.ipa | |
| - name: Upload files to a GitHub release | |
| if: github.event_name == 'release' | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| asset_name: hw-manager-${{ github.ref_name }}.ipa | |
| file: ./hw_manager_flutter.ipa | |
| tag: ${{ github.ref }} | |
| build_android: | |
| name: Build APK split by arch | |
| needs: [ do_tests, gen_icons ] | |
| runs-on: macos-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: 'Set up JDK 17' | |
| uses: 'actions/setup-java@v1' | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| # Set up JDK 17 using the "actions/setup-java" action. | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v3 | |
| with: | |
| packages: 'cmake;3.22.1 ndk;27.0.12077973 build-tools;30.0.3 platforms;android-31 platforms;android-32 platforms;android-33' | |
| - uses: subosito/flutter-action@v2 | |
| with: | |
| cache: true | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| #with: | |
| # sparse-checkout: | | |
| # assets | |
| # lib | |
| # scripts | |
| # ios | |
| - name: Gathering dependencies | |
| run: flutter pub get | |
| - name: Decode Keystore | |
| run: | | |
| echo "${{ secrets.JKS_B64 }}" | base64 --decode > android/app/keystore.jks | |
| - name: Create key.properties | |
| run: | | |
| echo "storePassword=${{ secrets.JKS_PW }}" > android/key.properties | |
| echo "keyPassword=${{ secrets.KEY_PW }}" >> android/key.properties | |
| echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties | |
| echo "storeFile=keystore.jks" >> android/key.properties | |
| - name: Build apk | |
| id: 'apkbuild' | |
| run: 'flutter doctor -v; flutter build apk --split-per-abi && ls build/app/outputs/flutter-apk && echo "apkbuild=build/app/outputs/flutter-apk/" >> $GITHUB_ENV' | |
| - name: Get current date | |
| id: date | |
| run: echo "date={$(date +'%Y-%m-%d')}" >> $GITHUB_ENV | |
| - name: Push artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: HW-manager-${{ env.date }} | |
| path: build/app/outputs/flutter-apk/ | |
| - name: Upload files to a GitHub release | |
| if: github.event_name == 'release' | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file_glob: true | |
| file: build/app/outputs/flutter-apk/* | |
| tag: ${{ github.ref }} |