diff --git a/.github/workflows/frontend-admin-build-local.yml b/.github/workflows/frontend-admin-build-local.yml new file mode 100644 index 00000000..6866a930 --- /dev/null +++ b/.github/workflows/frontend-admin-build-local.yml @@ -0,0 +1,158 @@ +name: Frontend Admin - EAS Build + +on: + push: + branches: [main, pre-prod] + paths: + - "frontend-admin/**" + pull_request: + branches: [main, pre-prod] + paths: + - "frontend-admin/**" + +jobs: + typecheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: frontend-admin/package-lock.json + + - name: Install dependencies + working-directory: frontend-admin + run: npm ci + + - name: Typecheck + working-directory: frontend-admin + run: npx tsc --noEmit + + build-apk: + needs: typecheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: frontend-admin/package-lock.json + + - 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 EAS CLI + run: npm install -g eas-cli + + - name: Install dependencies + working-directory: frontend-admin + run: npm ci + + - name: Inject EAS project ID + working-directory: frontend-admin + run: | + jq '.expo.extra.eas.projectId = "${{ secrets.EXPO_PROJECT_ID }}"' app.json > app.tmp.json + mv app.tmp.json app.json + + - name: Determine build profile & env + id: config + run: | + if [ "${{ github.ref_name }}" = "main" ] || [ "${{ github.base_ref }}" = "main" ]; then + echo "profile=production" >> $GITHUB_OUTPUT + echo "channel=production" >> $GITHUB_OUTPUT + echo "api_url=https://mln-uber.club" >> $GITHUB_OUTPUT + echo "apk_name=admin-panel-production-$(date +%Y%m%d-%H%M).apk" >> $GITHUB_OUTPUT + else + echo "profile=pre-prod" >> $GITHUB_OUTPUT + echo "channel=pre-prod" >> $GITHUB_OUTPUT + echo "api_url=https://5.181.0.112.nip.io" >> $GITHUB_OUTPUT + echo "apk_name=admin-panel-preview-$(date +%Y%m%d-%H%M).apk" >> $GITHUB_OUTPUT + fi + + - name: Build APK (local) + working-directory: frontend-admin + env: + EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} + EXPO_PUBLIC_API_URL: ${{ steps.config.outputs.api_url }} + EAS_BUILD_NO_EXPO_GO_WARNING: true + run: eas build --platform android --profile ${{ steps.config.outputs.profile }} --local --non-interactive + + - name: Rename APK + working-directory: frontend-admin + run: mv *.apk ${{ steps.config.outputs.apk_name }} + + - name: Upload APK to RustFS + working-directory: frontend-admin + env: + AWS_ACCESS_KEY_ID: ${{ secrets.RUSTFS_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.RUSTFS_SECRET_KEY }} + AWS_DEFAULT_REGION: us-east-1 + run: | + aws s3 cp ${{ steps.config.outputs.apk_name }} \ + s3://apk-builds/${{ steps.config.outputs.profile }}/${{ steps.config.outputs.apk_name }} \ + --endpoint-url https://rustfs.uber-stup.club \ + --no-verify-ssl + + ota-update: + needs: build-apk + runs-on: ubuntu-latest + # Ne publie pas sur les PR, seulement sur les pushs + if: github.event_name == 'push' + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: frontend-admin/package-lock.json + + - name: Install dependencies + working-directory: frontend-admin + run: npm ci + + - name: Install EAS CLI + run: npm install -g eas-cli + + - name: Determine channel & env + id: config + run: | + if [ "${{ github.ref_name }}" = "main" ]; then + echo "channel=production" >> $GITHUB_OUTPUT + echo "api_url=https://mln-uber.club" >> $GITHUB_OUTPUT + echo "message=Production update $(date +%Y%m%d-%H%M)" >> $GITHUB_OUTPUT + else + echo "channel=pre-prod" >> $GITHUB_OUTPUT + echo "api_url=https://5.181.0.112.nip.io" >> $GITHUB_OUTPUT + echo "message=Preview update $(date +%Y%m%d-%H%M)" >> $GITHUB_OUTPUT + fi + + - name: Publish OTA update to Xavia + working-directory: frontend-admin + env: + EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} + EXPO_PUBLIC_API_URL: ${{ steps.config.outputs.api_url }} + XAVIA_SERVER_URL: https://ota.uber-stup.club + run: | + npx expo export --platform android + curl -X POST "$XAVIA_SERVER_URL/api/updates" \ + -H "Authorization: Bearer ${{ secrets.XAVIA_API_KEY }}" \ + -H "Content-Type: application/json" \ + -d '{ + "channel": "${{ steps.config.outputs.channel }}", + "message": "${{ steps.config.outputs.message }}", + "platform": "android" + }' diff --git a/.github/workflows/frontend-admin-build.yml b/.github/workflows/frontend-admin-build.yml deleted file mode 100644 index 498c1a3a..00000000 --- a/.github/workflows/frontend-admin-build.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: Frontend Admin - EAS Build - -on: - push: - branches: [main, pre-prod] - paths: - - "frontend-admin/**" - pull_request: - branches: [main, pre-prod] - paths: - - "frontend-admin/**" - -jobs: - typecheck: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: npm - cache-dependency-path: frontend-admin/package-lock.json - - - name: Install dependencies - working-directory: frontend-admin - run: npm ci - - - name: Typecheck - working-directory: frontend-admin - run: npx tsc --noEmit - - build-apk: - needs: typecheck - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: npm - cache-dependency-path: frontend-admin/package-lock.json - - - name: Setup Expo & EAS CLI - uses: expo/expo-github-action@v8 - with: - eas-version: latest - token: ${{ secrets.EXPO_TOKEN }} - - - name: Install dependencies - working-directory: frontend-admin - run: npm ci - - - name: Inject EAS project ID - working-directory: frontend-admin - run: | - jq '.expo.extra.eas.projectId = "${{ secrets.EXPO_PROJECT_ID }}"' app.json > app.tmp.json - mv app.tmp.json app.json - - - name: Build APK - working-directory: frontend-admin - env: - EAS_BUILD_NO_EXPO_GO_WARNING: true - run: eas build --platform android ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '--profile production' || '--profile preview' }} --non-interactive - - - name: Download APK - working-directory: frontend-admin - run: | - APK_URL=$(eas build:list --platform android --status finished --limit 1 --json --non-interactive | jq -r '.[0].artifacts.buildUrl') - curl -L -o admin-panel-prod.apk "$APK_URL" - - - name: Upload production APK artifact - uses: actions/upload-artifact@v4 - with: - name: admin-panel-android-prod-apk - path: frontend-admin/admin-panel-prod.apk - retention-days: 14 diff --git a/.github/workflows/frontend-client-build-local.yml b/.github/workflows/frontend-client-build-local.yml new file mode 100644 index 00000000..62645a72 --- /dev/null +++ b/.github/workflows/frontend-client-build-local.yml @@ -0,0 +1,158 @@ +name: Frontend Admin - EAS Build + +on: + push: + branches: [main, pre-prod] + paths: + - "mobile/**" + pull_request: + branches: [main, pre-prod] + paths: + - "mobile/**" + +jobs: + typecheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: mobile/package-lock.json + + - name: Install dependencies + working-directory: mobile + run: npm ci + + - name: Typecheck + working-directory: mobile + run: npx tsc --noEmit + + build-apk: + needs: typecheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: mobile/package-lock.json + + - 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 EAS CLI + run: npm install -g eas-cli + + - name: Install dependencies + working-directory: mobile + run: npm ci + + - name: Inject EAS project ID + working-directory: mobile + run: | + jq '.expo.extra.eas.projectId = "${{ secrets.EXPO_PROJECT_ID }}"' app.json > app.tmp.json + mv app.tmp.json app.json + + - name: Determine build profile & env + id: config + run: | + if [ "${{ github.ref_name }}" = "main" ] || [ "${{ github.base_ref }}" = "main" ]; then + echo "profile=production" >> $GITHUB_OUTPUT + echo "channel=production" >> $GITHUB_OUTPUT + echo "api_url=https://mln-uber.club" >> $GITHUB_OUTPUT + echo "apk_name=admin-panel-production-$(date +%Y%m%d-%H%M).apk" >> $GITHUB_OUTPUT + else + echo "profile=pre-prod" >> $GITHUB_OUTPUT + echo "channel=pre-prod" >> $GITHUB_OUTPUT + echo "api_url=https://5.181.0.112.nip.io" >> $GITHUB_OUTPUT + echo "apk_name=admin-panel-preview-$(date +%Y%m%d-%H%M).apk" >> $GITHUB_OUTPUT + fi + + - name: Build APK (local) + working-directory: mobile + env: + EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} + EXPO_PUBLIC_API_URL: ${{ steps.config.outputs.api_url }} + EAS_BUILD_NO_EXPO_GO_WARNING: true + run: eas build --platform android --profile ${{ steps.config.outputs.profile }} --local --non-interactive + + - name: Rename APK + working-directory: mobile + run: mv *.apk ${{ steps.config.outputs.apk_name }} + + - name: Upload APK to RustFS + working-directory: mobile + env: + AWS_ACCESS_KEY_ID: ${{ secrets.RUSTFS_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.RUSTFS_SECRET_KEY }} + AWS_DEFAULT_REGION: us-east-1 + run: | + aws s3 cp ${{ steps.config.outputs.apk_name }} \ + s3://apk-builds/${{ steps.config.outputs.profile }}/${{ steps.config.outputs.apk_name }} \ + --endpoint-url https://rustfs.uber-stup.club \ + --no-verify-ssl + + ota-update: + needs: build-apk + runs-on: ubuntu-latest + # Ne publie pas sur les PR, seulement sur les pushs + if: github.event_name == 'push' + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: mobile/package-lock.json + + - name: Install dependencies + working-directory: mobile + run: npm ci + + - name: Install EAS CLI + run: npm install -g eas-cli + + - name: Determine channel & env + id: config + run: | + if [ "${{ github.ref_name }}" = "main" ]; then + echo "channel=production" >> $GITHUB_OUTPUT + echo "api_url=https://mln-uber.club" >> $GITHUB_OUTPUT + echo "message=Production update $(date +%Y%m%d-%H%M)" >> $GITHUB_OUTPUT + else + echo "channel=pre-prod" >> $GITHUB_OUTPUT + echo "api_url=https://5.181.0.112.nip.io" >> $GITHUB_OUTPUT + echo "message=Preview update $(date +%Y%m%d-%H%M)" >> $GITHUB_OUTPUT + fi + + - name: Publish OTA update to Xavia + working-directory: mobile + env: + EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} + EXPO_PUBLIC_API_URL: ${{ steps.config.outputs.api_url }} + XAVIA_SERVER_URL: https://ota.uber-stup.club + run: | + npx expo export --platform android + curl -X POST "$XAVIA_SERVER_URL/api/updates" \ + -H "Authorization: Bearer ${{ secrets.XAVIA_API_KEY }}" \ + -H "Content-Type: application/json" \ + -d '{ + "channel": "${{ steps.config.outputs.channel }}", + "message": "${{ steps.config.outputs.message }}", + "platform": "android" + }' diff --git a/.github/workflows/frontend-client-build.yml b/.github/workflows/frontend-client-build.yml deleted file mode 100644 index 3bdeed9d..00000000 --- a/.github/workflows/frontend-client-build.yml +++ /dev/null @@ -1,86 +0,0 @@ -name: Frontend Client - EAS Build - -on: - push: - branches: [main, pre-prod] - paths: - - "mobile/**" - pull_request: - branches: [main, pre-prod] - paths: - - "mobile/**" - -jobs: - typecheck: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: npm - cache-dependency-path: mobile/package-lock.json - - - name: Install dependencies - working-directory: mobile - run: npm ci - - - name: Typecheck - working-directory: mobile - run: npx tsc --noEmit - - build-apk: - needs: typecheck - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: npm - cache-dependency-path: mobile/package-lock.json - - - name: Setup Expo & EAS CLI - uses: expo/expo-github-action@v8 - with: - eas-version: latest - token: ${{ secrets.EXPO_TOKEN }} - - - name: Install dependencies - working-directory: mobile - run: npm ci - - - name: Inject EAS project ID - working-directory: mobile - run: | - jq '.expo.extra.eas.projectId = "${{ secrets.EXPO_PROJECT_ID_CLIENT }}"' app.json > app.tmp.json - mv app.tmp.json app.json - - - name: Debug app.json - working-directory: mobile - run: cat app.json - - - name: Build APK - working-directory: mobile - env: - EAS_BUILD_NO_EXPO_GO_WARNING: true - run: eas build --platform android ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '--profile production' || '--profile preview' }} --non-interactive - - - name: Download production APK - working-directory: mobile - run: | - APK_URL=$(eas build:list --platform android --status finished --limit 1 --json --non-interactive | jq -r '.[0].artifacts.buildUrl') - curl -L -o client-panel-prod.apk "$APK_URL" - - - name: Upload production APK artifact - uses: actions/upload-artifact@v4 - with: - name: client-panel-android-prod-apk - path: mobile/client-panel-prod.apk - retention-days: 14 diff --git a/frontend-admin/eas.json b/frontend-admin/eas.json index f62e5b47..52006a70 100644 --- a/frontend-admin/eas.json +++ b/frontend-admin/eas.json @@ -11,21 +11,20 @@ "buildType": "apk", "gradleCommand": ":app:assembleDebug" }, - "ios": { - "simulator": true - }, "env": { - "EXPO_PUBLIC_API_URL": "https://5.181.0.112.nip.io" - } + "EXPO_PUBLIC_API_URL": "http://localhost:8080" + }, + "channel": "development" }, - "preview": { + "pre-prod": { "distribution": "internal", "android": { "buildType": "apk" }, "env": { "EXPO_PUBLIC_API_URL": "https://5.181.0.112.nip.io" - } + }, + "channel": "pre-prod" }, "production": { "distribution": "internal", @@ -35,7 +34,8 @@ }, "env": { "EXPO_PUBLIC_API_URL": "https://mln-uber.club" - } + }, + "channel": "production" } } } diff --git a/mobile/eas.json b/mobile/eas.json index 8de57c71..52006a70 100644 --- a/mobile/eas.json +++ b/mobile/eas.json @@ -11,15 +11,12 @@ "buildType": "apk", "gradleCommand": ":app:assembleDebug" }, - "ios": { - "simulator": true - }, "env": { - "EXPO_PUBLIC_API_URL": "https://5.181.0.112.nip.io" + "EXPO_PUBLIC_API_URL": "http://localhost:8080" }, "channel": "development" }, - "preview": { + "pre-prod": { "distribution": "internal", "android": { "buildType": "apk" @@ -27,7 +24,7 @@ "env": { "EXPO_PUBLIC_API_URL": "https://5.181.0.112.nip.io" }, - "channel": "preview" + "channel": "pre-prod" }, "production": { "distribution": "internal",