Skip to content

Build and Release Android APK #12

Build and Release Android APK

Build and Release Android APK #12

Workflow file for this run

name: Build and Release Android APK
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g., v1.0.0)'
required: false
default: ''
jobs:
build-arm64:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Install dependencies
run: npm ci
- name: Setup Expo
uses: expo/expo-github-action@v8
with:
expo-version: latest
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Get version from app.json
id: get_version
run: |
VERSION=$(node -p "require('./app.json').expo.version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "App version: $VERSION"
- name: Prebuild Android
run: npx expo prebuild --platform android --clean
- name: Build APK (arm64-v8a)
run: |
cd android
./gradlew assembleRelease \
-PreactNativeArchitectures=arm64-v8a \
--no-daemon
env:
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g"
- name: Rename and Upload arm64-v8a APK
run: |
VERSION=${{ steps.get_version.outputs.version }}
mv android/app/build/outputs/apk/release/app-release.apk \
huawei-manager-v${VERSION}-arm64-v8a.apk
- name: Upload arm64-v8a APK
uses: actions/upload-artifact@v4
with:
name: apk-arm64-v8a
path: huawei-manager-*.apk
retention-days: 7
build-armv7:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Install dependencies
run: npm ci
- name: Setup Expo
uses: expo/expo-github-action@v8
with:
expo-version: latest
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Get version from app.json
id: get_version
run: |
VERSION=$(node -p "require('./app.json').expo.version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "App version: $VERSION"
- name: Prebuild Android
run: npx expo prebuild --platform android --clean
- name: Build APK (armeabi-v7a)
run: |
cd android
./gradlew assembleRelease \
-PreactNativeArchitectures=armeabi-v7a \
--no-daemon
env:
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g"
- name: Rename and Upload armeabi-v7a APK
run: |
VERSION=${{ steps.get_version.outputs.version }}
mv android/app/build/outputs/apk/release/app-release.apk \
huawei-manager-v${VERSION}-armeabi-v7a.apk
- name: Upload armeabi-v7a APK
uses: actions/upload-artifact@v4
with:
name: apk-armeabi-v7a
path: huawei-manager-*.apk
retention-days: 7
build-universal:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Install dependencies
run: npm ci
- name: Setup Expo
uses: expo/expo-github-action@v8
with:
expo-version: latest
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Get version from app.json
id: get_version
run: |
VERSION=$(node -p "require('./app.json').expo.version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "App version: $VERSION"
- name: Prebuild Android
run: npx expo prebuild --platform android --clean
- name: Build Universal APK
run: |
cd android
./gradlew assembleRelease --no-daemon
env:
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g"
- name: Rename and Upload Universal APK
run: |
VERSION=${{ steps.get_version.outputs.version }}
mv android/app/build/outputs/apk/release/app-release.apk \
huawei-manager-v${VERSION}-universal.apk
- name: Upload Universal APK
uses: actions/upload-artifact@v4
with:
name: apk-universal
path: huawei-manager-*.apk
retention-days: 7
release:
runs-on: ubuntu-latest
needs: [build-arm64, build-armv7, build-universal]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get previous tag
id: prev_tag
run: |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
echo "prev_tag=$PREV_TAG" >> $GITHUB_OUTPUT
echo "Previous tag: $PREV_TAG"
- name: Generate Release Notes from PRs
id: release_notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PREV_TAG="${{ steps.prev_tag.outputs.prev_tag }}"
REPO="${{ github.repository }}"
# Get commits since last tag (or all if no previous tag)
if [ -n "$PREV_TAG" ]; then
COMMITS=$(git log ${PREV_TAG}..HEAD --pretty=format:"%H" 2>/dev/null || echo "")
else
COMMITS=$(git log --pretty=format:"%H" 2>/dev/null || echo "")
fi
# Find merged PRs from commits
echo "## What's Changed" > release_notes.md
echo "" >> release_notes.md
PR_FOUND=false
for COMMIT in $COMMITS; do
# Get PR number from commit (if merged via PR)
PR_DATA=$(gh api "repos/${REPO}/commits/${COMMIT}/pulls" --jq '.[0] | {number, title, user: .user.login, html_url}' 2>/dev/null || echo "")
if [ -n "$PR_DATA" ] && [ "$PR_DATA" != "null" ]; then
PR_NUM=$(echo "$PR_DATA" | jq -r '.number')
PR_TITLE=$(echo "$PR_DATA" | jq -r '.title')
PR_USER=$(echo "$PR_DATA" | jq -r '.user')
PR_URL=$(echo "$PR_DATA" | jq -r '.html_url')
# Check if already added (avoid duplicates)
if ! grep -q "#${PR_NUM}" release_notes.md 2>/dev/null; then
echo "* ${PR_TITLE} by @${PR_USER} in [#${PR_NUM}](${PR_URL})" >> release_notes.md
PR_FOUND=true
fi
fi
done
if [ "$PR_FOUND" = false ]; then
echo "* Various improvements and bug fixes" >> release_notes.md
fi
echo "" >> release_notes.md
# Add full changelog link
if [ -n "$PREV_TAG" ]; then
echo "**Full Changelog**: https://github.com/${REPO}/compare/${PREV_TAG}...v${{ needs.build-arm64.outputs.version }}" >> release_notes.md
fi
# Output for use in release body
{
echo 'notes<<EOF'
cat release_notes.md
echo 'EOF'
} >> $GITHUB_OUTPUT
- name: Download all APKs
uses: actions/download-artifact@v4
with:
path: apks
merge-multiple: true
- name: List APKs
run: ls -la apks/
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
name: Huawei Manager v${{ needs.build-arm64.outputs.version }}
body: |
## Huawei Manager v${{ needs.build-arm64.outputs.version }}
${{ steps.release_notes.outputs.notes }}
---
### Downloads
- **arm64-v8a** - For modern 64-bit devices (recommended)
- **armeabi-v7a** - For older 32-bit devices
- **universal** - Works on all devices (larger size)
### Installation
1. Download the appropriate APK for your device
2. Enable "Install from unknown sources" in Settings
3. Open the APK file to install
files: apks/*.apk
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release (Manual Trigger)
if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != ''
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.version }}
name: Huawei Manager ${{ github.event.inputs.version }}
body: |
## Huawei Manager ${{ github.event.inputs.version }}
${{ steps.release_notes.outputs.notes }}
---
### Downloads
- **arm64-v8a** - For modern 64-bit devices (recommended)
- **armeabi-v7a** - For older 32-bit devices
- **universal** - Works on all devices (larger size)
### Installation
1. Download the appropriate APK for your device
2. Enable "Install from unknown sources" in Settings
3. Open the APK file to install
files: apks/*.apk
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}