Update README.md #73
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
| on: push | |
| name: build and test app | |
| jobs: | |
| build: | |
| name: install dependencies | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17' | |
| - name: Clone repository | |
| uses: actions/checkout@v4 | |
| - name: Download Latest apps.db Asset from sunO2/GStore-repositorys Release | |
| run: | | |
| REPO_OWNER="sunO2" | |
| REPO_NAME="GStore-repositorys" | |
| ASSET_NAME="apps.db" # Replace with the actual asset name if different | |
| RELEASE_INFO=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/latest") | |
| ASSET_URL=$(echo "$RELEASE_INFO" | jq -r ".assets[] | select(.name == \"$ASSET_NAME\") | .browser_download_url") | |
| if [[ -z "$ASSET_URL" ]]; then | |
| echo "::warning::No asset named '$ASSET_NAME' found in latest release of sunO2/GStore-repositorys. Using existing apps.db or workflow might fail if it's missing." | |
| exit 0 # Continue workflow, but warn that apps.db update might have failed | |
| fi | |
| echo "Downloading asset '$ASSET_NAME' from: $ASSET_URL" | |
| curl -L -o downloaded_apps.db "$ASSET_URL" # Download asset to 'downloaded_apps.db' | |
| mkdir -p assets/app/db | |
| cp downloaded_apps.db assets/app/db/apps.db # Copy downloaded asset to destination, renaming it to apps.db | |
| echo "Successfully updated assets/app/db/apps.db from release asset" | |
| - name: Get version from pubspec.yaml | |
| id: get_version | |
| run: | | |
| VERSION=$(sed -n 's/^version: \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p' ./pubspec.yaml) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| # Cache flutter dependencies for faster builds | |
| - name: Cache Flutter pub | |
| uses: actions/cache@v3 | |
| id: flutter-pub-cache | |
| with: | |
| path: ~/.pub-cache | |
| key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pub- | |
| - name: Set up Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: 3.24.3 | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - run: flutter test | |
| - run: flutter build apk --no-shrink --target-platform android-arm,android-arm64,android-x64 --split-per-abi | |
| - run: flutter build appbundle | |
| - name: Get latest commit message | |
| id: get_commit_msg | |
| run: | | |
| COMMIT_MSG=$(git log -1 --pretty=%B) | |
| echo "message=${COMMIT_MSG}" >> $GITHUB_OUTPUT | |
| - name: Create Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.get_version.outputs.version }} | |
| release_name: ${{ steps.get_version.outputs.version }} | |
| body: ${{ steps.get_commit_msg.outputs.message }} | |
| draft: false | |
| prerelease: false | |
| - name: Upload Release AAB | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./build/app/outputs/bundle/release/app-release.aab | |
| asset_name: app-release.aab | |
| asset_content_type: application/zip | |
| - name: Upload Release APK32 | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk | |
| asset_name: GStore-armeabi-v7a-release.apk | |
| asset_content_type: application/zip | |
| - name: Upload Release APK64 | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./build/app/outputs/flutter-apk/app-arm64-v8a-release.apk | |
| asset_name: GStore-arm64-v8a-release.apk | |
| asset_content_type: application/zip | |
| - name: Upload Release x86_64 | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./build/app/outputs/flutter-apk/app-x86_64-release.apk | |
| asset_name: GStore-x86_64-release.apk | |
| asset_content_type: application/zip |