fix: default analytics off for all installs, not just F-Droid (#74) #43
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: Release Build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| concurrency: | |
| group: release-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| release: | |
| name: Build and Release APK | |
| if: github.actor != 'github-actions[bot]' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Required to create releases and push commits | |
| pull-requests: read # Required to read merged PRs for release notes | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 # Fetch all history for proper versioning | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Gradle Build Cache | |
| uses: gradle/actions/setup-gradle@v6 | |
| - name: Set up Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version-file: './workout-logger/pubspec.yaml' | |
| channel: 'stable' | |
| cache: true | |
| pub-cache-key: "flutter-pub-:os:-:channel:-:version:-:arch:-${{ hashFiles('workout-logger/pubspec.lock') }}" | |
| - name: Install dependencies | |
| working-directory: ./workout-logger | |
| run: | | |
| flutter pub get --enforce-lockfile | |
| : "${PUB_CACHE:?PUB_CACHE is not set}" | |
| mapfile -t targets < <(find "$PUB_CACHE" -type f -path '*/jni-*/src/CMakeLists.txt') | |
| if [ "${#targets[@]}" -eq 0 ]; then | |
| echo "Error: no jni-*/src/CMakeLists.txt files found under \$PUB_CACHE" >&2 | |
| exit 1 | |
| fi | |
| for f in "${targets[@]}"; do | |
| if ! grep -q -- '-Wl,--build-id=none' "$f"; then | |
| sed -i -e 's/-Wl,/-Wl,--build-id=none,/' "$f" | |
| fi | |
| done | |
| - name: Bump version | |
| if: github.event_name == 'push' | |
| id: bump_version | |
| run: | | |
| dart scripts/bump_version.dart patch | |
| echo "Version bumped successfully" | |
| - name: Read version | |
| id: version | |
| run: | | |
| VERSION=$(grep '^version:' workout-logger/pubspec.yaml | sed 's/version: //' | cut -d'+' -f1) | |
| echo "value=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Configure Git | |
| if: github.event_name == 'push' | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Commit version bump | |
| if: github.event_name == 'push' | |
| id: commit_version | |
| run: | | |
| git add workout-logger/pubspec.yaml | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| echo "committed=false" >> $GITHUB_OUTPUT | |
| else | |
| git commit -m "chore: bump version to ${{ steps.version.outputs.value }}" | |
| git push origin HEAD:${{ github.ref_name }} | |
| echo "committed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Git tag | |
| if: github.event_name == 'push' && steps.commit_version.outputs.committed == 'true' | |
| run: | | |
| git tag "v${{ steps.version.outputs.value }}" | |
| git push origin "v${{ steps.version.outputs.value }}" | |
| - name: Get merged PRs for release notes | |
| if: github.event_name == 'push' && steps.commit_version.outputs.committed == 'true' | |
| id: merged_prs | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| NEW_TAG="v${{ steps.version.outputs.value }}" | |
| PREV_TAG=$(git tag --sort=-version:refname | grep '^v' | grep -v "^${NEW_TAG}$" | head -1) | |
| if [ -n "$PREV_TAG" ]; then | |
| SINCE_DATE=$(git log -1 --format=%aI "$PREV_TAG") | |
| PR_LIST=$(gh pr list \ | |
| --state merged \ | |
| --base main \ | |
| --limit 50 \ | |
| --search "merged:>=${SINCE_DATE}" \ | |
| --json number,title,author \ | |
| --template '{{range .}}- #{{.number}} {{.title}} (@{{.author.login}}){{"\n"}}{{end}}' 2>/dev/null || echo "") | |
| else | |
| PR_LIST=$(gh pr list \ | |
| --state merged \ | |
| --base main \ | |
| --limit 10 \ | |
| --json number,title,author \ | |
| --template '{{range .}}- #{{.number}} {{.title}} (@{{.author.login}}){{"\n"}}{{end}}' 2>/dev/null || echo "") | |
| fi | |
| [ -z "$PR_LIST" ] && PR_LIST="_No merged pull requests found since the last release._" | |
| { | |
| echo "list<<EOF" | |
| echo "$PR_LIST" | |
| echo "EOF" | |
| } >> $GITHUB_OUTPUT | |
| - name: Decode release keystore | |
| run: | | |
| if [ -z "${{ secrets.KEYSTORE_BASE64 }}" ]; then | |
| echo "Error: KEYSTORE_BASE64 secret is not configured in repository secrets." | |
| exit 1 | |
| fi | |
| echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > /tmp/repforge-release.jks | |
| - name: Build APK | |
| working-directory: ./workout-logger | |
| env: | |
| KEYSTORE_PATH: /tmp/repforge-release.jks | |
| KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }} | |
| KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
| run: flutter build apk --release --split-per-abi | |
| - name: Rename APKs | |
| run: | | |
| V="${{ steps.version.outputs.value }}" | |
| DIR="workout-logger/build/app/outputs/flutter-apk" | |
| mv "$DIR/app-arm64-v8a-release.apk" "$DIR/repforge-v${V}-arm64-v8a.apk" 2>/dev/null || true | |
| mv "$DIR/app-armeabi-v7a-release.apk" "$DIR/repforge-v${V}-armeabi-v7a.apk" 2>/dev/null || true | |
| mv "$DIR/app-x86_64-release.apk" "$DIR/repforge-v${V}-x86_64.apk" 2>/dev/null || true | |
| - name: Sanitize ref name for artifact | |
| id: sanitize_ref | |
| run: echo "ref_name=$(echo '${{ github.ref_name }}' | tr '/' '-')" >> $GITHUB_OUTPUT | |
| - name: Upload APK artifact (manual run) | |
| if: github.event_name == 'workflow_dispatch' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: repforge-v${{ steps.version.outputs.value }}-${{ steps.sanitize_ref.outputs.ref_name }} | |
| path: workout-logger/build/app/outputs/flutter-apk/repforge-v${{ steps.version.outputs.value }}-*.apk | |
| retention-days: 7 | |
| - name: Create GitHub Release | |
| if: github.event_name == 'push' && steps.commit_version.outputs.committed == 'true' | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| tag_name: v${{ steps.version.outputs.value }} | |
| name: RepForge v${{ steps.version.outputs.value }} | |
| body: | | |
| ## RepForge v${{ steps.version.outputs.value }} | |
| ### π± Download | |
| Download the APK file below to install on your Android device. | |
| ### π Merged Pull Requests | |
| ${{ steps.merged_prs.outputs.list }} | |
| ### π Build Information | |
| - **Version**: ${{ steps.version.outputs.value }} | |
| - **Build Date**: ${{ github.event.head_commit.timestamp }} | |
| - **Commit**: ${{ github.sha }} | |
| files: | | |
| workout-logger/build/app/outputs/flutter-apk/repforge-v${{ steps.version.outputs.value }}-*.apk | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |