mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1---
2name: Build and Submit Android
3
4on:
5 workflow_dispatch:
6 inputs:
7 profile:
8 type: choice
9 description: Build profile to use
10 options:
11 - testflight-android
12 - production
13
14jobs:
15 build:
16 name: Build and Submit Android
17 runs-on: ubuntu-latest
18 steps:
19 - name: Check for EXPO_TOKEN
20 run: >
21 if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
22 echo "You must provide an EXPO_TOKEN secret linked to this project's Expo account in this repo's secrets. Learn more: https://docs.expo.dev/eas-update/github-actions"
23 exit 1
24 fi
25
26 - name: ⬇️ Checkout
27 uses: actions/checkout@v4
28 with:
29 fetch-depth: 5
30
31 - name: 🔧 Setup Node
32 uses: actions/setup-node@v4
33 with:
34 node-version-file: .nvmrc
35 cache: yarn
36
37 - name: 🪛 Setup jq
38 uses: dcarbone/install-jq-action@v2
39
40 - name: 🔨 Setup EAS
41 uses: expo/expo-github-action@v8
42 with:
43 expo-version: latest
44 eas-version: latest
45 token: ${{ secrets.EXPO_TOKEN }}
46
47 - name: ⛏️ Setup EAS local builds
48 run: yarn global add eas-cli-local-build-plugin
49
50 - uses: actions/setup-java@v4
51 with:
52 distribution: 'temurin'
53 java-version: '17'
54
55 - name: ⚙️ Install dependencies
56 run: yarn install
57
58 - name: 🔤 Compile translations
59 run: yarn intl:build
60
61 - name: ✏️ Write environment variables
62 run: |
63 export json='${{ secrets.GOOGLE_SERVICES_TOKEN }}'
64 echo "${{ secrets.ENV_TOKEN }}" > .env
65 echo "EXPO_PUBLIC_BUNDLE_IDENTIFIER=$(git rev-parse --short HEAD)" >> .env
66 echo "EXPO_PUBLIC_BUNDLE_DATE=$(date -u +"%y%m%d%H")" >> .env
67 echo "$json" > google-services.json
68
69 - name: 🏗️ EAS Build
70 run: yarn use-build-number-with-bump eas build -p android --profile ${{ inputs.profile || 'testflight-android' }} --local --output build.aab --non-interactive
71
72 - name: ✍️ Rename Testflight bundle
73 if: ${{ inputs.profile != 'production' }}
74 run: mv build.aab build.apk
75
76 - name: ⏰ Get a timestamp
77 id: timestamp
78 uses: nanzm/get-time-action@master
79 with:
80 format: 'MM-DD-HH-mm-ss'
81
82 - name: 🚀 Upload Production Artifact
83 id: upload-artifact-production
84 if: ${{ inputs.profile == 'production' }}
85 uses: actions/upload-artifact@v4
86 with:
87 retention-days: 30
88 compression-level: 6
89 name: build-${{ steps.timestamp.outputs.time }}.aab
90 path: build.aab
91
92 - name: 🚀 Upload Testflight Artifact
93 id: upload-artifact-testflight
94 if: ${{ inputs.profile != 'production' }}
95 uses: actions/upload-artifact@v4
96 with:
97 retention-days: 30
98 compression-level: 6
99 name: build-${{ steps.timestamp.outputs.time }}.apk
100 path: build.apk
101
102 - name: 📚 Get version from package.json
103 id: get-build-info
104 run: bash scripts/setGitHubOutput.sh
105
106 - name: 🔔 Notify Slack of Production Build
107 if: ${{ inputs.profile == 'production' }}
108 uses: slackapi/slack-github-action@v1.25.0
109 with:
110 payload: |
111 {
112 "text": "Android production build for Google Play Store submission is ready!\n```Artifact: ${{ steps.upload-artifact-production.outputs.artifact-url }}\nVersion Number: ${{ steps.get-build-info.outputs.PACKAGE_VERSION }}\nBuild Number: ${{ steps.get-build-info.outputs.BSKY_ANDROID_VERSION_CODE }}```"
113 }
114 env:
115 SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLIENT_ALERT_WEBHOOK }}
116 SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
117
118 - name: 🔔 Notify Slack of Testflight Build
119 if: ${{ inputs.profile != 'production' }}
120 uses: slackapi/slack-github-action@v1.25.0
121 with:
122 payload: |
123 {
124 "text": "Android build is ready for testing. Download the artifact here: ${{ steps.upload-artifact-testflight.outputs.artifact-url }}"
125 }
126 env:
127 SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLIENT_ALERT_WEBHOOK }}
128 SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
129
130 - name: 🏗️ Build Production APK
131 if: ${{ inputs.profile == 'production' }}
132 run: yarn use-build-number-with-bump eas build -p android --profile production-apk --local --output build.apk --non-interactive
133
134 - name: 🚀 Upload Production APK Artifact
135 id: upload-artifact-production-apk
136 if: ${{ inputs.profile == 'production' }}
137 uses: actions/upload-artifact@v4
138 with:
139 retention-days: 30
140 compression-level: 6
141 name: build-${{ steps.timestamp.outputs.time }}.apk
142 path: build.apk
143
144 - name: 🔔 Notify Slack of Production APK Build
145 if: ${{ inputs.profile == 'production' }}
146 uses: slackapi/slack-github-action@v1.25.0
147 with:
148 payload: |
149 {
150 "text": "Android production build for GitHub/Obtanium is ready!\n```Artifact: ${{ steps.upload-artifact-production-apk.outputs.artifact-url }}\nVersion Number: ${{ steps.get-build-info.outputs.PACKAGE_VERSION }}\nBuild Number: ${{ steps.get-build-info.outputs.BSKY_ANDROID_VERSION_CODE }}```"
151 }
152 env:
153 SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLIENT_ALERT_WEBHOOK }}
154 SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
155
156 - name: ⬇️ Restore Cache
157 id: get-base-commit
158 uses: actions/cache@v4
159 if: ${{ inputs.profile == 'testflight' }}
160 with:
161 path: most-recent-testflight-commit.txt
162 key: most-recent-testflight-commit
163
164 - name: ✏️ Write commit hash to cache
165 if: ${{ inputs.profile == 'testflight' }}
166 run: echo ${{ github.sha }} > most-recent-testflight-commit.txt