From 6a4ee9e80f6bceb77fbef6c5124379fd52c0ee0b Mon Sep 17 00:00:00 2001 From: root Date: Thu, 19 Feb 2026 22:08:36 +0800 Subject: [PATCH] feat: add CI/CD workflows and EAS build config (Sprint 5) --- .gitea/workflows/build.yml | 37 +++++++++++++ .gitea/workflows/ci.yml | 31 +++++++++++ BUILDING.md | 103 +++++++++++++++++++++++++++++++++++++ app.json | 5 +- eas.json | 25 +++++++++ 5 files changed, 199 insertions(+), 2 deletions(-) create mode 100644 .gitea/workflows/build.yml create mode 100644 .gitea/workflows/ci.yml create mode 100644 BUILDING.md create mode 100644 eas.json diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..59d4201 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,37 @@ +name: Build (EAS) + +# Triggered on push to main branch. +# IMPORTANT: Set EXPO_TOKEN as a Gitea Actions secret before running this workflow. +# Go to: Repo → Settings → Actions → Secrets → Add secret: EXPO_TOKEN +# Get your token at: https://expo.dev/accounts/[username]/settings/access-tokens + +on: + push: + branches: + - main + +jobs: + eas-build: + name: EAS Build (Android Preview APK) + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Install EAS CLI + run: npm install -g eas-cli + + - name: Build Android APK (preview) + run: eas build --platform android --profile preview --non-interactive + env: + EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..d097914 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI + +on: + push: + branches: + - dev + - 'sprint/**' + +jobs: + lint-and-typecheck: + name: Lint & TypeScript Check + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run ESLint + run: npx eslint . --ext .ts,.tsx --max-warnings 0 + + - name: Run TypeScript check + run: npx tsc --noEmit diff --git a/BUILDING.md b/BUILDING.md new file mode 100644 index 0000000..478da47 --- /dev/null +++ b/BUILDING.md @@ -0,0 +1,103 @@ +# Building TerritoryLog with EAS + +This document explains how to build TerritoryLog APKs and production bundles using **Expo Application Services (EAS)**. + +--- + +## Prerequisites + +### 1. Install EAS CLI + +```bash +npm install -g eas-cli +``` + +Verify installation: + +```bash +eas --version +# Should output >= 12.0.0 +``` + +### 2. Log in to Expo Account + +```bash +eas login +``` + +You will be prompted for your Expo username and password. If you don't have an account, create one at [https://expo.dev](https://expo.dev). + +--- + +## Building + +### Preview Build (APK — for internal testing) + +This generates a standard `.apk` file that can be installed directly on Android devices without the Play Store. + +```bash +eas build --platform android --profile preview +``` + +Once the build completes, EAS will provide a download URL for the APK. + +### Production Build (AAB — for Play Store submission) + +This generates an `.aab` (Android App Bundle) optimized for Play Store distribution. + +```bash +eas build --platform android --profile production +``` + +### Development Build (for local development with Expo Go replacement) + +```bash +eas build --platform android --profile development +``` + +--- + +## About Keystores + +> **EAS manages keystores automatically.** On your first build, EAS will generate and securely store a keystore on Expo's servers. You don't need to manually create or manage a keystore. If you need to use an existing keystore, see the [EAS credentials documentation](https://docs.expo.dev/app-signing/managed-credentials/). + +--- + +## CI/CD — Setting Up `EXPO_TOKEN` in Gitea + +The CI/CD pipeline in `.gitea/workflows/build.yml` requires an `EXPO_TOKEN` secret to authenticate with EAS without interactive login. + +### Steps to set up: + +1. **Generate an Expo access token:** + - Go to [https://expo.dev/accounts/\[your-username\]/settings/access-tokens](https://expo.dev/accounts/) + - Click **"Create Token"** + - Name it something like `gitea-ci` and copy the token value + +2. **Add the secret to Gitea:** + - In this repo, go to **Settings → Actions → Secrets** + - Click **"Add Secret"** + - Name: `EXPO_TOKEN` + - Value: *(paste your token)* + - Click **"Save"** + +3. The `build.yml` workflow will now authenticate automatically when triggered by a push to `main`. + +--- + +## Build Profiles Summary + +| Profile | Output | Distribution | Use Case | +|---------------|----------|--------------|------------------------------| +| `development` | APK | Internal | Dev client for local testing | +| `preview` | APK | Internal | QA / internal testing | +| `production` | AAB | Play Store | Public release | + +--- + +## Useful Links + +- [EAS Build documentation](https://docs.expo.dev/build/introduction/) +- [EAS CLI reference](https://docs.expo.dev/eas-cli/) +- [Android app signing with EAS](https://docs.expo.dev/app-signing/managed-credentials/) +- [Expo access tokens](https://docs.expo.dev/accounts/programmatic-access/) diff --git a/app.json b/app.json index 3c2022d..0202532 100644 --- a/app.json +++ b/app.json @@ -13,13 +13,14 @@ }, "ios": { "supportsTablet": false, - "bundleIdentifier": "space.juankibin.territorylog" + "bundleIdentifier": "com.juankibin.territorylog" }, "android": { "adaptiveIcon": { "backgroundColor": "#1A6B72" }, - "package": "space.juankibin.territorylog" + "package": "com.juankibin.territorylog", + "versionCode": 1 }, "web": { "bundler": "metro" diff --git a/eas.json b/eas.json new file mode 100644 index 0000000..d0aa009 --- /dev/null +++ b/eas.json @@ -0,0 +1,25 @@ +{ + "cli": { + "version": ">= 12.0.0" + }, + "build": { + "development": { + "developmentClient": true, + "distribution": "internal" + }, + "preview": { + "distribution": "internal", + "android": { + "buildType": "apk" + } + }, + "production": { + "android": { + "buildType": "app-bundle" + } + } + }, + "submit": { + "production": {} + } +}