Skip to content

Commit ec011dc

Browse files
author
Lalit Sharma
committed
feat: add GitHub Actions workflow for developing APK and update package version to 1.1.52-SNAPSHOT
1 parent d83be74 commit ec011dc

3 files changed

Lines changed: 204 additions & 3 deletions

File tree

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
name: Develop APK Dev Release
2+
3+
on:
4+
push:
5+
branches: [develop]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: develop-apk-release-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
build_and_release:
14+
name: Build APK + Create Dev Release
15+
runs-on: [self-hosted, macOS, eclipse-timer]
16+
permissions:
17+
contents: write
18+
env:
19+
GOOGLE_MAPS_ANDROID_API_KEY: ${{ secrets.GOOGLE_MAPS_ANDROID_API_KEY }}
20+
SENTRY_DISABLE_AUTO_UPLOAD: "true"
21+
SENTRY_DISABLE_XCODE_DEBUG_UPLOAD: "true"
22+
SENTRY_ALLOW_FAILURE: "true"
23+
SENTRY_CLI_EXECUTABLE: "/usr/bin/true"
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Install pnpm
30+
uses: pnpm/action-setup@v4
31+
32+
- name: Setup Node
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: 20
36+
cache: pnpm
37+
38+
- name: Install dependencies
39+
run: pnpm install --frozen-lockfile --prefer-offline
40+
41+
- name: Setup Java
42+
uses: actions/setup-java@v4
43+
with:
44+
distribution: temurin
45+
java-version: "17"
46+
cache: gradle
47+
48+
- name: Setup Android SDK tools
49+
uses: android-actions/setup-android@v3
50+
51+
- name: Install Android SDK packages
52+
run: |
53+
set -euo pipefail
54+
55+
sdk_root=""
56+
for candidate in \
57+
"${ANDROID_SDK_ROOT:-}" \
58+
"${ANDROID_HOME:-}" \
59+
"$HOME/Library/Android/sdk" \
60+
"$HOME/Android/Sdk" \
61+
"/usr/local/share/android-sdk" \
62+
"/opt/homebrew/share/android-sdk"
63+
do
64+
if [ -n "$candidate" ] && [ -d "$candidate" ]; then
65+
sdk_root="$candidate"
66+
break
67+
fi
68+
done
69+
70+
if [ ! -d "$sdk_root" ]; then
71+
echo "Android SDK directory not found."
72+
echo "Install Android SDK on the runner or set ANDROID_SDK_ROOT/ANDROID_HOME."
73+
exit 1
74+
fi
75+
76+
missing_packages=()
77+
[ -d "$sdk_root/platform-tools" ] || missing_packages+=("platform-tools")
78+
[ -d "$sdk_root/platforms/android-36" ] || missing_packages+=("platforms;android-36")
79+
[ -d "$sdk_root/build-tools/36.0.0" ] || missing_packages+=("build-tools;36.0.0")
80+
[ -d "$sdk_root/ndk/27.1.12297006" ] || missing_packages+=("ndk;27.1.12297006")
81+
82+
if [ "${#missing_packages[@]}" -eq 0 ]; then
83+
echo "All required Android SDK packages are already installed in $sdk_root."
84+
exit 0
85+
fi
86+
87+
echo "Installing missing Android SDK packages: ${missing_packages[*]}"
88+
yes | sdkmanager --licenses >/dev/null || true
89+
sdkmanager "${missing_packages[@]}"
90+
91+
- name: Setup EAS CLI
92+
uses: expo/expo-github-action@v8
93+
with:
94+
eas-version: latest
95+
token: ${{ secrets.EXPO_TOKEN }}
96+
packager: pnpm
97+
98+
- name: Validate Google Maps Android key
99+
run: |
100+
if [ -z "$GOOGLE_MAPS_ANDROID_API_KEY" ]; then
101+
echo "Missing GOOGLE_MAPS_ANDROID_API_KEY GitHub secret."
102+
echo "Add it in: Settings -> Secrets and variables -> Actions."
103+
exit 1
104+
fi
105+
106+
- name: Build Android APK
107+
working-directory: apps/mobile
108+
env:
109+
EAS_LOCAL_BUILD_ARTIFACTS_DIR: ${{ github.workspace }}/artifacts/raw
110+
run: |
111+
set -euo pipefail
112+
113+
sdk_root=""
114+
for candidate in \
115+
"${ANDROID_SDK_ROOT:-}" \
116+
"${ANDROID_HOME:-}" \
117+
"$HOME/Library/Android/sdk" \
118+
"$HOME/Android/Sdk" \
119+
"/usr/local/share/android-sdk" \
120+
"/opt/homebrew/share/android-sdk"
121+
do
122+
if [ -n "$candidate" ] && [ -d "$candidate" ]; then
123+
sdk_root="$candidate"
124+
break
125+
fi
126+
done
127+
128+
if [ ! -d "$sdk_root" ]; then
129+
echo "Android SDK directory not found."
130+
echo "Install Android SDK on the runner or set ANDROID_SDK_ROOT/ANDROID_HOME."
131+
exit 1
132+
fi
133+
134+
export ANDROID_SDK_ROOT="$sdk_root"
135+
export ANDROID_HOME="$sdk_root"
136+
escaped_sdk_root="${sdk_root// /\\ }"
137+
printf 'sdk.dir=%s\n' "$escaped_sdk_root" > android/local.properties
138+
echo "Using Android SDK at $sdk_root"
139+
140+
pnpm exec eas build --profile production-apk --platform android --local --non-interactive
141+
142+
- name: Prepare dev release metadata
143+
id: release_meta
144+
run: |
145+
set -euo pipefail
146+
147+
mkdir -p artifacts/release
148+
version="$(node -p "JSON.parse(require('fs').readFileSync('apps/mobile/package.json', 'utf8')).version")"
149+
short_sha="${GITHUB_SHA::7}"
150+
run_id="${GITHUB_RUN_ID}"
151+
run_attempt="${GITHUB_RUN_ATTEMPT}"
152+
153+
apk_source="$(find artifacts/raw -type f -name '*.apk' | grep -iv 'wear' | head -n 1 || true)"
154+
if [ -z "$apk_source" ]; then
155+
apk_source="$(find artifacts/raw -type f -name '*.apk' | head -n 1 || true)"
156+
fi
157+
158+
if [ -z "$apk_source" ]; then
159+
echo "Missing Android APK artifact in artifacts/raw."
160+
exit 1
161+
fi
162+
163+
tag_name="dev-v${version}-r${run_id}-a${run_attempt}-${short_sha}"
164+
release_name="Eclipse Timer Dev v${version} (run ${run_id}.${run_attempt}, ${short_sha})"
165+
apk_asset_name="eclipse-timer-dev-v${version}-${short_sha}.apk"
166+
apk_target="artifacts/release/${apk_asset_name}"
167+
notes_file="artifacts/release/dev-release-notes.md"
168+
169+
cp "$apk_source" "$apk_target"
170+
171+
{
172+
echo "Automated develop APK build."
173+
echo ""
174+
echo "- Branch: \`${GITHUB_REF_NAME}\`"
175+
echo "- Commit: \`${GITHUB_SHA}\`"
176+
echo "- Version: \`${version}\`"
177+
} > "$notes_file"
178+
179+
{
180+
echo "tag_name=${tag_name}"
181+
echo "release_name=${release_name}"
182+
echo "apk_path=${apk_target}"
183+
echo "notes_path=${notes_file}"
184+
} >> "$GITHUB_OUTPUT"
185+
186+
- name: Upload APK artifact
187+
uses: actions/upload-artifact@v4
188+
with:
189+
name: develop-apk-${{ github.run_id }}
190+
path: ${{ steps.release_meta.outputs.apk_path }}
191+
if-no-files-found: error
192+
193+
- name: Create GitHub dev release
194+
uses: softprops/action-gh-release@v2
195+
with:
196+
tag_name: ${{ steps.release_meta.outputs.tag_name }}
197+
name: ${{ steps.release_meta.outputs.release_name }}
198+
body_path: ${{ steps.release_meta.outputs.notes_path }}
199+
prerelease: true
200+
generate_release_notes: false
201+
files: ${{ steps.release_meta.outputs.apk_path }}

apps/mobile/app.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ const pkg = require("./package.json") as { version?: string };
66
const googleMapsAndroidApiKey = process.env.GOOGLE_MAPS_ANDROID_API_KEY?.trim();
77
const packageVersion = pkg.version;
88

9-
if (typeof packageVersion !== "string" || !/^\d+\.\d+\.\d+$/.test(packageVersion)) {
9+
if (typeof packageVersion !== "string" || !/^\d+\.\d+\.\d+(?:-SNAPSHOT)?$/.test(packageVersion)) {
1010
throw new Error(
11-
`[app.config] apps/mobile/package.json version must be x.y.z. Found: ${JSON.stringify(packageVersion)}`,
11+
`[app.config] apps/mobile/package.json version must be x.y.z or x.y.z-SNAPSHOT. Found: ${JSON.stringify(packageVersion)}`,
1212
);
1313
}
1414

apps/mobile/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eclipse-timer/mobile",
3-
"version": "1.1.51",
3+
"version": "1.1.52-SNAPSHOT",
44
"private": true,
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)