66# This workflow is used to trigger a build on EAS.
77# Can be triggered manually from the actions tab.
88
9- # This action accepts those inputs:
10- # `environment`, which is used to generate a build for a specific environment (development, staging, QA, production). We use staging by default.
11- # `android`, true by default, set to true if you don't want to trigger build for Android.
12- # `ios`, false by default, set to true if you want to trigger build for IOS.
13-
149# Before triggering the build, we run a pre-build script to generate the necessary native folders based on the APP_ENV.
1510# Based on the ANDROID and IOS inputs, we trigger the build for the corresponding platform with the corresponding flags.
1611
2823# - Go to Repository Settings > Secrets and variables > Actions > New repository secret
2924# - Name: NEW_VERSION_NUMBER_PAT
3025# - Value: The Personal Access Token you created
26+
3127name : ' EAS Build (Android & IOS) (EAS)'
3228
3329on :
3430 workflow_dispatch :
3531 inputs :
36- environment :
37- type : choice
38- description : ' Environment'
39- required : true
40- default : ' staging'
41- options :
42- - development
43- - staging
44- - qa
45- - production
32+ # environment:
33+ # type: choice
34+ # description: 'Environment'
35+ # required: true
36+ # default: 'staging'
37+ # options:
38+ # - development
39+ # - staging
40+ # - qa
41+ # - production
4642 new-version :
4743 type : string
48- description : ' New version (e.g. 1.0.0)'
49- android :
44+ description : ' New version (e.g. 1.0.0) (optional) '
45+ auto-submit :
5046 type : boolean
51- description : ' Build for Android'
52- required : true
53- default : true
54- ios :
55- type : boolean
56- description : ' Build for iOS'
57- required : true
47+ description : ' Auto-submit the build to the store'
48+ required : false
5849 default : true
5950
6051jobs :
9182 runs-on : ${{ matrix.os }}
9283 permissions :
9384 contents : write
94- environment : app- ${{ inputs.environment }}
85+ environment : ${{ github.ref_name == 'main' && 'production' || github.ref_name == 'staging' && 'staging' || github.ref_name == 'qa' && 'qa' || github.ref_name == 'development' && 'development' }}
9586 strategy :
9687 fail-fast : false
9788 matrix :
@@ -102,14 +93,28 @@ jobs:
10293 - platform : android
10394 os : ubuntu-latest
10495 steps :
96+ - name : Set environment variable
97+ run : |
98+ if [[ "${{ github.ref_name }}" == "main" ]]; then
99+ echo "ENV=production" >> $GITHUB_ENV
100+ elif [[ "${{ github.ref_name }}" == "staging" ]]; then
101+ echo "ENV=staging" >> $GITHUB_ENV
102+ elif [[ "${{ github.ref_name }}" == "qa" ]]; then
103+ echo "ENV=qa" >> $GITHUB_ENV
104+ elif [[ "${{ github.ref_name }}" == "development" ]]; then
105+ echo "ENV=development" >> $GITHUB_ENV
106+ else
107+ echo "Invalid branch: ${{ github.ref_name }}. You can only build for main, staging, qa or development branches."
108+ exit 1
109+ fi
105110 - name : Check if all required secrets exist
106111 run : |
107112 if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
108113 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"
109114 exit 1
110115 fi
111116 if [ -z "${{ secrets.NEW_VERSION_NUMBER_PAT }}" ]; then
112- echo "echo " NEW_VERSION_NUMBER_PAT secret not found. Please create a fine-grained Personal Access Token following the instructions in the workflow file.""
117+ echo "NEW_VERSION_NUMBER_PAT secret not found. Please create a fine-grained Personal Access Token following the instructions in the workflow file.""
113118 exit 1
114119 fi
115120
@@ -129,7 +134,7 @@ jobs:
129134 uses : ./.github/actions/setup-node-pnpm-install
130135
131136 - name : Create environment file
132- run : echo "${{ secrets.ENVIRONMENT_FILE }}" > .env.${{ inputs.environment }}
137+ run : echo "${{ secrets.ENVIRONMENT_FILE }}" > .env.${{ env.ENV }}
133138
134139 - name : Update version in package.json
135140 if : inputs.new-version
@@ -150,22 +155,38 @@ jobs:
150155 with :
151156 xcode-version : latest
152157
158+ - name : Set Up JDK
159+ uses : actions/setup-java@v3
160+ if : matrix.platform == 'android'
161+ with :
162+ distribution : ' zulu' # See 'Supported distributions' for available options
163+ java-version : ' 17'
164+
153165 - name : ⚙️ Run Prebuild
154- run : pnpm prebuild:${{ inputs.environment }}
166+ run : pnpm prebuild:${{ env.ENV }}
155167
156168 - name : 📱 Run Build for ${{ matrix.platform }}
157- run : pnpm build:${{ inputs.environment }}:${{ matrix.platform }} --non-interactive --no-wait --message "Build ${{ inputs.environment }} for ${{ matrix.platform }}" --local
158-
159- - name : 📦 Push changes to repository
160- if : inputs.new-version
161169 run : |
162- git push || echo "Skipping push: version was already updated."
163-
170+ pnpm build:${{ env.ENV }}:${{ matrix.platform }} --non-interactive --no-wait --message "Build ${{ env.ENV }} for ${{ matrix.platform }}" --local
171+ if [ "${{ matrix.platform }}" = "android" ]; then
172+ ls -1 "./*.aab" > path.txt
173+ elif [ "${{ matrix.platform }}" = "ios" ]; then
174+ ls -1 "./*.ipa" > path.txt
175+ fi
164176 - name : Upload ${{ matrix.platform }} Build
165177 uses : actions/upload-artifact@v4
166178 with :
167- name : ${{ matrix.platform }}-build-${{ inputs.environment }}
179+ name : ${{ matrix.platform }}-build-${{ env.ENV }}
168180 path : |
181+ *.apks
169182 *.apk
170183 *.aab
171- *.ipa
184+ *.ipa
185+
186+ - name : 📱 Submit ${{ matrix.platform }} app to the store
187+ run : pnpm submit:${{ env.ENV }}:mobile --platform=${{ matrix.platform }} --path=$(cat path.txt) --no-wait --non-interactive
188+
189+ - name : 📦 Push changes to repository
190+ if : inputs.new-version
191+ run : |
192+ git push || echo "Skipping push: version was already updated."
0 commit comments