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 "BITDRIFT_API_KEY=${{ secrets.BITDRIFT_API_KEY }}" >> .env
68 echo "$json" > google-services.json
69
70 - name: 🏗️ EAS Build
71 run: yarn use-build-number-with-bump eas build -p android --profile ${{ inputs.profile || 'testflight-android' }} --local --output build.aab --non-interactive
72
73 - name: ✍️ Rename Testflight bundle
74 if: ${{ inputs.profile != 'production' }}
75 run: mv build.aab build.apk
76
77 - name: ⏰ Get a timestamp
78 id: timestamp
79 uses: nanzm/get-time-action@master
80 with:
81 format: 'MM-DD-HH-mm-ss'
82
83 - name: 🚀 Upload Production Artifact
84 id: upload-artifact-production
85 if: ${{ inputs.profile == 'production' }}
86 uses: actions/upload-artifact@v4
87 with:
88 retention-days: 30
89 compression-level: 6
90 name: build-${{ steps.timestamp.outputs.time }}.aab
91 path: build.aab
92
93 - name: 🚀 Upload Testflight Artifact
94 id: upload-artifact-testflight
95 if: ${{ inputs.profile != 'production' }}
96 uses: actions/upload-artifact@v4
97 with:
98 retention-days: 30
99 compression-level: 6
100 name: build-${{ steps.timestamp.outputs.time }}.apk
101 path: build.apk
102
103 - name: 📚 Get version from package.json
104 id: get-build-info
105 run: bash scripts/setGitHubOutput.sh
106
107 - name: 🔔 Notify Slack of Production Build
108 if: ${{ inputs.profile == 'production' }}
109 uses: slackapi/slack-github-action@v1.25.0
110 with:
111 payload: |
112 {
113 "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 }}```"
114 }
115 env:
116 SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLIENT_ALERT_WEBHOOK }}
117 SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
118
119 - name: 🔔 Notify Slack of Testflight Build
120 if: ${{ inputs.profile != 'production' }}
121 uses: slackapi/slack-github-action@v1.25.0
122 with:
123 payload: |
124 {
125 "text": "Android build is ready for testing. Download the artifact here: ${{ steps.upload-artifact-testflight.outputs.artifact-url }}"
126 }
127 env:
128 SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLIENT_ALERT_WEBHOOK }}
129 SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
130
131 - name: 🏗️ Build Production APK
132 if: ${{ inputs.profile == 'production' }}
133 run: yarn use-build-number-with-bump eas build -p android --profile production-apk --local --output build.apk --non-interactive
134
135 - name: 🚀 Upload Production APK Artifact
136 id: upload-artifact-production-apk
137 if: ${{ inputs.profile == 'production' }}
138 uses: actions/upload-artifact@v4
139 with:
140 retention-days: 30
141 compression-level: 6
142 name: build-${{ steps.timestamp.outputs.time }}.apk
143 path: build.apk
144
145 - name: 🔔 Notify Slack of Production APK Build
146 if: ${{ inputs.profile == 'production' }}
147 uses: slackapi/slack-github-action@v1.25.0
148 with:
149 payload: |
150 {
151 "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 }}```"
152 }
153 env:
154 SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLIENT_ALERT_WEBHOOK }}
155 SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
156
157 - name: ⬇️ Restore Cache
158 id: get-base-commit
159 uses: actions/cache@v4
160 if: ${{ inputs.profile == 'testflight' }}
161 with:
162 path: most-recent-testflight-commit.txt
163 key: most-recent-testflight-commit
164
165 - name: ✏️ Write commit hash to cache
166 if: ${{ inputs.profile == 'testflight' }}
167 run: echo ${{ github.sha }} > most-recent-testflight-commit.txt