Skip to content

Build App

Build App #98

Workflow file for this run

# References:
# https://github.com/thomasread99/expo-workflows/
name: Build App
on:
workflow_dispatch:
inputs:
ref:
type: string
description: 'Ref to Build'
required: true
pr:
type: string
description: 'PR Number to report the status'
required: false
submit:
type: boolean
description: 'Submit?'
required: false
release:
type: boolean
description: 'Release?'
required: false
id:
type: string
description: 'Workflow Run ID'
required: false
jobs:
id:
name: Workflow Run ID
runs-on: ubuntu-latest
steps:
- name: ${{github.event.inputs.id}}
run: echo run identifier ${{ inputs.id }}
build-android:
runs-on: ubuntu-latest
outputs:
build_success: ${{ steps.build.outcome == 'success' }}
steps:
- name: Setup repo
uses: actions/checkout@v4
with:
token: ${{ secrets.USTHING_GITHUB_TOKEN }}
ref: ${{ inputs.ref }}
repository: USThing/USThingApp
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup Corepack
run: |
corepack enable
corepack install
- name: Setup Yarn Cache
uses: actions/setup-node@v4
with:
cache: yarn
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: microsoft
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Setup Expo and EAS
uses: expo/expo-github-action@v8
with:
token: ${{ secrets.EXPO_TOKEN }}
expo-version: latest
eas-version: latest
- name: Install Dependencies
run: yarn
- name: Build
id: build
run: eas build --profile production --platform android --local --non-interactive --output=${{ github.workspace }}/usthing-preview.aab
# https://docs.expo.dev/submit/ios/#submitting-your-app-using-ci
- name: Submit to Google Play
if: ${{ inputs.submit == true }}
continue-on-error: ${{ inputs.release == false }}
run: eas submit --profile production --platform android --non-interactive --path ${{ github.workspace }}/usthing-preview.aab
- name: Result
id: result
if: ${{ always() }}
run: |
echo "build_success=${{ steps.build.outcome == 'success' }}" >> "$GITHUB_OUTPUT"
build-ios:
runs-on: macos-latest
outputs:
build_success: ${{ steps.build.outcome == 'success' }}
steps:
- name: Setup repo
uses: actions/checkout@v4
with:
token: ${{ secrets.USTHING_GITHUB_TOKEN }}
ref: ${{ inputs.ref }}
repository: USThing/USThingApp
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup Corepack
run: |
corepack enable
corepack install
- name: Setup Yarn Cache
uses: actions/setup-node@v4
with:
cache: yarn
- name: Setup Expo
uses: expo/expo-github-action@v8
with:
expo-version: latest
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Install Dependencies
run: yarn
- name: Build iOS App
id: build
run: eas build --profile production --platform ios --local --non-interactive --output ${{ github.workspace }}/usthing-preview.ipa
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: preview
path: ${{ github.workspace }}/usthing-preview.ipa
# https://docs.expo.dev/submit/ios/#submitting-your-app-using-ci
- name: Submit to TestFlight
if: ${{ inputs.submit == true }}
continue-on-error: ${{ inputs.release == false }}
run: eas submit --profile production --platform ios --non-interactive --path ${{ github.workspace }}/usthing-preview.ipa
- name: Result
id: result
if: ${{ always() }}
run: |
echo "build_success=${{ steps.build.outcome == 'success' }}" >> "$GITHUB_OUTPUT"
build-android-apk:
runs-on: ubuntu-latest
outputs:
build_success: ${{ steps.build.outcome == 'success' }}
steps:
- name: Setup repo
uses: actions/checkout@v4
with:
token: ${{ secrets.USTHING_GITHUB_TOKEN }}
ref: ${{ inputs.ref }}
repository: USThing/USThingApp
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup Corepack
run: |
corepack enable
corepack install
- name: Setup Yarn Cache
uses: actions/setup-node@v4
with:
cache: yarn
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: microsoft
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Setup Expo and EAS
uses: expo/expo-github-action@v8
with:
token: ${{ secrets.EXPO_TOKEN }}
expo-version: latest
eas-version: latest
- name: Install Dependencies
run: yarn
- name: Build
id: build
run: eas build --profile production:apk --platform android --local --non-interactive --output=${{ github.workspace }}/usthing.apk
- name: Setup jq
uses: dcarbone/install-jq-action@v2
- name: Submit to Production Server
if: ${{ inputs.release == true }}
run: |
curl -X 'POST' \
'https://static.api.usthing.xyz/v1/apk/latest' \
-H 'Authorization: Bearer ${{ secrets.ANDROID_APK_RELEASE_KEY }}' \
-H 'Content-Type: multipart/form-data' \
-F 'apk=@${{ github.workspace }}/usthing.apk'
- name: Submit Version to Production Server
if: ${{ inputs.release == true }}
run: |
curl -X 'POST' \
'https://static.api.usthing.xyz/v1/apk/latest/version' \
-H 'Authorization: Bearer ${{ secrets.ANDROID_APK_RELEASE_KEY }}' \
-H 'Content-Type: application/json' \
--data '$(jq '.expo.version' app.json)'
- name: Result
id: result
if: ${{ always() }}
run: |
echo "build_success=${{ steps.build.outcome == 'success' }}" >> "$GITHUB_OUTPUT"
report-status:
runs-on: ubuntu-latest
needs:
- build-android
- build-ios
- build-android-apk
if: ${{ always() && inputs.pr }}
steps:
- name: Setup repo
uses: actions/checkout@v4
with:
token: ${{ secrets.USTHING_GITHUB_TOKEN }}
ref: ${{ inputs.ref }}
repository: USThing/USThingApp
- name: Commit SHA
id: commit_sha
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Report Status
uses: actions/github-script@v7
env:
PR_NUMBER: ${{ inputs.pr }}
COMMIT_SHA: ${{ steps.commit_sha.outputs.sha }}
BUILD_ANDROID: ${{ needs.build-android.outputs.build_success }}
BUILD_IOS: ${{ needs.build-ios.outputs.build_success }}
BUILD_ANDROID_APK: ${{ needs.build-android-apk.outputs.build_success }}
with:
github-token: ${{ secrets.USTHING_GITHUB_TOKEN }}
script: |
const { PR_NUMBER, COMMIT_SHA } = process.env;
const { BUILD_ANDROID, BUILD_IOS, BUILD_ANDROID_APK } = process.env;
github.rest.issues.createComment({
issue_number: PR_NUMBER,
owner: "USThing",
repo: "USThingApp",
body:
"###### *This is a build status report generated by CI.*\n\n" +
`#### Build Status of Commit ${COMMIT_SHA}\n\n` +
`- Android: ${BUILD_ANDROID === "true" ? "🟢" : "🔴"}\n` +
`- iOS: ${BUILD_IOS === "true" ? "🟢" : "🔴"}\n` +
`- Android APK: ${BUILD_ANDROID_APK === "true" ? "🟢" : "🔴"}\n` +
`\n` +
`Please check the run at ` +
`https://github.com/USThing/USThingAppBuilder/actions/runs/${{ github.run_id }} ` +
`for more details.`
})