github_apk_updater 1.0.4
github_apk_updater: ^1.0.4 copied to clipboard
Auto-update your Flutter Android app via GitHub Releases. Zero cost, zero third-party services, zero server needed. Just push to GitHub — users get update dialog automatically.
github_apk_updater #
Auto-update your Flutter Android app via GitHub Releases — no server, no third-party service.
How It Works #
You push code to GitHub
→ GitHub Actions builds APK automatically
→ Uploads APK to GitHub Releases (free)
→ Updates version.json
User opens your app
→ App checks version.json silently
→ If new version exists → shows update dialog
→ User taps Update Now → downloads & installs
⚠️ Required: Copy Workflow File (Do This First) #
Every project using this package needs a GitHub Actions workflow file. Without this file, GitHub will NOT build your APK automatically.
Step 1 — Create this folder in your project root:
your_project/
└── .github/
└── workflows/
└── build_apk.yml ← create this file
Step 2 — Paste this into build_apk.yml:
name: Build & Release APK
on:
push:
branches:
- main
permissions:
contents: write
jobs:
build:
name: Build APK
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: Get Flutter packages
run: flutter pub get
- name: Build APK
run: flutter build apk --release
- name: Get version from pubspec
id: get_version
run: |
VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //' | sed 's/+.*//' | tr -d ' ')
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.get_version.outputs.VERSION }}
name: v${{ steps.get_version.outputs.VERSION }}
files: build/app/outputs/flutter-apk/app-release.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update version.json
run: |
VERSION=${{ steps.get_version.outputs.VERSION }}
REPO="${{ github.repository }}"
APK_URL="https://github.com/$REPO/releases/download/v$VERSION/app-release.apk"
printf '{\n "latest_version": "%s",\n "apk_url": "%s",\n "force_update": false,\n "release_notes": "New update available!"\n}\n' "$VERSION" "$APK_URL" > version.json
- name: Commit version.json
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add version.json
git diff --staged --quiet || git commit -m "chore: bump version.json to v${{ steps.get_version.outputs.VERSION }}"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Step 3 — Add version.json to your project root:
{
"latest_version": "1.0.0",
"apk_url": "https://github.com/USERNAME/REPO/releases/download/v1.0.0/app-release.apk",
"force_update": false,
"release_notes": "Initial release."
}
Install Package #
dependencies:
github_apk_updater: ^1.0.0
Add to Your App #
import 'package:github_apk_updater/github_apk_updater.dart';
final updater = GithubApkUpdater(
config: UpdaterConfig(
githubUsername: 'your_username', // ← your GitHub username
githubRepo: 'your_repo', // ← your GitHub repo name
),
);
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
updater.check(context);
});
}
Every Push Routine #
# 1. Bump version in pubspec.yaml
# example: 1.0.0+1 → 1.0.1+2
# 2. Push
git pull --rebase && git add . && git commit -m "update" && git push origin main
Configuration Options #
| Option | Default | Description |
|---|---|---|
githubUsername |
required | Your GitHub username |
githubRepo |
required | Your repository name |
branch |
main |
Branch with version.json |
dialogTitle |
Update Available |
Dialog title |
updateButtonText |
Update Now |
Update button label |
laterButtonText |
Later |
Dismiss button label |
Force Update #
Set force_update: true in version.json — users cannot skip the update.
Custom UI #
final info = await updater.getUpdateInfo();
if (info != null && info.hasUpdate) {
// use info.latestVersion, info.apkUrl, info.releaseNotes
}
Android Permission #
Add to android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>