Skip to content

Add build workflow and push notification script #43

Add build workflow and push notification script

Add build workflow and push notification script #43

Workflow file for this run

name: Build & Publish Release APK
on:
push:
tags:
- "*"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
- name: checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: "adopt"
java-version: "20"
cache: "gradle"
- name: Setup Bun
uses: antongolub/action-setup-bun@v1
with:
bun-version: "1.0.26"
cache: true
cache-bin: true
- name: Prepare Tag
shell: bash
id: tag
run: |
if [[ ${{ github.ref_name }} == v* ]]; then
tag="${{ github.ref_name }}"
echo "prerelease=false" >> $GITHUB_OUTPUT
else
tag="$(date +'vdev.%y.%m.%d.%H%M%S')"
echo "prerelease=true" >> $GITHUB_OUTPUT
fi
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: Bump version in app.json
run: |
tag=${{ steps.tag.outputs.tag }}
# change version in app.json
sed -i "s/\"version\": \".*\"/\"version\": \"${tag:1}\"/g" app.json
- name: Install dependencies
run: bun install
- name: Create google-services.json
run: echo ${{ secrets.GOOGLE_SERVICES_JSON }} > google-services.json
- name: Build Expo
run: bun run build:android
- name: Build Signed APK
run: |
cd android
chmod +x ./gradlew
./gradlew assembleRelease \
--build-cache \
-Pandroid.injected.signing.store.file=$GITHUB_WORKSPACE/android/app/keystore.jks \
-Pandroid.injected.signing.store.password="${{ secrets.STORE_PASSWORD }}" \
-Pandroid.injected.signing.key.alias="key0" \
-Pandroid.injected.signing.key.password="${{ secrets.KEY_PASSWORD }}" \
-Pandroid.enableProguardInReleaseBuilds=true
env:
EXPO_PUBLIC_API_URL: ${{ secrets.EXPO_PUBLIC_API_URL }}
EXPO_PUBLIC_CLIENT_SECRET: ${{ secrets.EXPO_PUBLIC_CLIENT_SECRET }}
- name: Rename APK
shell: bash
run: |
cd android/app/build/outputs/apk/release
tag=${{ steps.tag.outputs.tag }}
for file in app-*.apk; do name=$(echo $file | cut -d'-' -f2-3); new_name="prevanced-manager-${name%-release*}-$tag.apk"; mv "$file" "$new_name"; done
- name: Release APK
uses: ncipollo/release-action@v1
with:
artifacts: android/app/build/outputs/apk/release/*.apk
tag: ${{ steps.tag.outputs.tag }}
prerelease: ${{ steps.tag.outputs.prerelease }}
generateReleaseNotes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Sync app.json version
if: steps.tag.outputs.prerelease == 'false'
continue-on-error: true
run: |
tag=${{ steps.tag.outputs.tag }}
cd $GITHUB_WORKSPACE
git checkout main
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
sed -i "s/\"version\": \".*\"/\"version\": \"${tag:1}\"/g" app.json
git add app.json android/app/build.gradle
git commit -m "chore: bump version to $tag"
git push origin main
notify:
needs: build
uses: ./.github/workflows/notify.yml
with:
release_tag: ${{ needs.build.outputs.tag }}