update: build #9
This file contains 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 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the code | |
- uses: actions/checkout@v3 | |
# Setup Java environment for Android build | |
- uses: actions/setup-java@v3 | |
with: | |
java-version: "17" | |
distribution: "adopt" # You can keep 'temurin' if needed | |
# Gradle cache for faster builds | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} | |
restore-keys: | | |
${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} | |
${{ runner.os }}-gradle- | |
${{ runner.os }}- | |
- uses: actions/cache@v4 | |
with: | |
path: /usr/local/lib/android/sdk | |
key: ${{ runner.os }}-android-sdk-cache | |
# Setup Flutter environment | |
- uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
cache: true | |
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:" | |
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:" | |
pub-cache-key: "flutter-pub:os:-:channel:-:version:-:arch:-:hash:" | |
pub-cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:" | |
# Get Flutter dependencies | |
- run: flutter pub get | |
# Create .env file for environment variables | |
- name: Create .env file | |
run: | | |
cat <<EOF > .env | |
GITHUBTOKEN=${{ secrets.GITHUBTOKEN }} | |
EOF | |
# Build APK with additional flags for optimization | |
- run: flutter build apk --release | |
# Upload to Telegram | |
- name: Upload to Telegram | |
run: | | |
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument" \ | |
-F chat_id=${{ secrets.TELEGRAM_CHAT_ID }} \ | |
-F document=@build/app/outputs/flutter-apk/app-release.apk \ | |
-F caption=app |