2024-03-19 19:18:22 +01:00
---
name : Bundle and Deploy EAS Update
on :
2024-04-04 01:00:52 +02:00
push :
branches :
- main
2024-03-19 19:18:22 +01:00
workflow_dispatch :
inputs :
2024-04-04 00:14:44 +02:00
channel :
type : choice
description : Deployment channel to use
options :
- testflight
- production
2024-03-19 19:18:22 +01:00
runtimeVersion :
type : string
description : Runtime version (in x.x.x format) that this update is for
required : true
jobs :
bundleDeploy :
name : Bundle and Deploy EAS Update
runs-on : ubuntu-latest
2024-04-08 17:54:50 +02:00
concurrency :
group : ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}-deploy
2024-05-07 22:08:44 +02:00
cancel-in-progress : true
2024-04-04 00:14:44 +02:00
outputs :
2024-05-29 01:38:24 +02:00
changes-detected : ${{ steps.fingerprint.outputs.includes-changes }}
2024-04-04 03:04:48 +02:00
2024-03-19 19:18:22 +01:00
steps :
2024-04-04 00:14:44 +02:00
- name : Check for EXPO_TOKEN
run : >
if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
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"
exit 1
fi
# Validate the version if one is supplied. This should generally happen if the update is for a production client
2024-03-19 19:18:22 +01:00
- name : 🧐 Validate version
2024-04-04 00:14:44 +02:00
if : ${{ inputs.runtimeVersion }}
2024-03-19 19:18:22 +01:00
run : |
2024-04-04 00:14:44 +02:00
if [ -z "${{ inputs.runtimeVersion }}" ]; then
[ [ "${{ inputs.runtimeVersion }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && echo "Version is valid" || exit 1
fi
2024-03-19 19:18:22 +01:00
- name : ⬇️ Checkout
uses : actions/checkout@v4
2024-04-04 00:14:44 +02:00
with :
2024-04-05 17:27:22 +02:00
fetch-depth : 0
2024-04-04 00:14:44 +02:00
- name : ⬇️ Fetch commits from base branch
2024-04-04 01:27:17 +02:00
if : ${{ github.ref != 'refs/heads/main' }}
2024-04-04 00:14:44 +02:00
run : git fetch origin main:main --depth 100
2024-03-19 19:18:22 +01:00
- name : 🔧 Setup Node
uses : actions/setup-node@v4
with :
node-version-file : .nvmrc
cache : yarn
2024-05-29 01:38:24 +02:00
- name : 📷 Check fingerprint and install dependencies
2024-04-04 00:14:44 +02:00
id : fingerprint
2024-05-29 01:38:24 +02:00
uses : bluesky-social/github-actions/fingerprint-native@main
2024-04-04 00:14:44 +02:00
with :
2024-05-29 01:38:24 +02:00
profile : ${{ inputs.channel || 'testflight' }}
previous-commit-tag : ${{ inputs.runtimeVersion }}
2024-04-04 00:14:44 +02:00
2024-04-05 08:15:59 +02:00
- name : Lint check
run : yarn lint
- name : Prettier check
run : yarn prettier --check .
- name : Check & compile i18n
run : yarn intl:build
- name : Type check
run : yarn typecheck
2024-04-04 00:14:44 +02:00
- name : 🔨 Setup EAS
uses : expo/expo-github-action@v8
2024-05-29 01:38:24 +02:00
if : ${{ !steps.fingerprint.outputs.includes-changes }}
2024-04-04 00:14:44 +02:00
with :
expo-version : latest
eas-version : latest
token : ${{ secrets.EXPO_TOKEN }}
2024-03-19 19:18:22 +01:00
- name : ⛏️ Setup Expo
2024-05-29 01:38:24 +02:00
if : ${{ !steps.fingerprint.outputs.includes-changes }}
2024-03-19 19:18:22 +01:00
run : yarn global add eas-cli-local-build-plugin
2024-04-04 00:14:44 +02:00
- name : 🪛 Setup jq
2024-05-29 01:38:24 +02:00
if : ${{ !steps.fingerprint.outputs.includes-changes }}
2024-04-04 00:14:44 +02:00
uses : dcarbone/install-jq-action@v2
2024-03-19 19:18:22 +01:00
- name : ✏️ Write environment variables
2024-05-29 01:38:24 +02:00
if : ${{ !steps.fingerprint.outputs.includes-changes }}
2024-03-19 19:18:22 +01:00
run : |
export json='${{ secrets.GOOGLE_SERVICES_TOKEN }}'
echo "${{ secrets.ENV_TOKEN }}" > .env
2024-05-05 01:33:10 +02:00
echo "EXPO_PUBLIC_BUNDLE_IDENTIFIER=$(git rev-parse --short HEAD)" >> .env
echo "EXPO_PUBLIC_BUNDLE_DATE=$(date -u +"%y%m%d%H")" >> .env
2024-03-19 19:18:22 +01:00
echo "$json" > google-services.json
- name : 🏗️ Create Bundle
2024-05-29 01:38:24 +02:00
if : ${{ !steps.fingerprint.outputs.includes-changes }}
2024-04-04 00:14:44 +02:00
run : EXPO_PUBLIC_ENV="${{ inputs.channel || 'testflight' }}" yarn export
2024-03-19 19:18:22 +01:00
- name : 📦 Package Bundle and 🚀 Deploy
2024-05-29 01:38:24 +02:00
if : ${{ !steps.fingerprint.outputs.includes-changes }}
2024-04-04 00:14:44 +02:00
run : yarn use-build-number bash scripts/bundleUpdate.sh
2024-03-19 19:18:22 +01:00
env :
DENIS_API_KEY : ${{ secrets.DENIS_API_KEY }}
2024-04-04 00:14:44 +02:00
RUNTIME_VERSION : ${{ inputs.runtimeVersion }}
CHANNEL_NAME : ${{ inputs.channel || 'testflight' }}
2024-05-29 01:38:24 +02:00
- name : ⬇️ Restore Cache
id : get-base-commit
uses : actions/cache@v4
if : ${{ !steps.fingerprint.outputs.includes-changes }}
with :
path : most-recent-testflight-commit.txt
key : most-recent-testflight-commit
- name : ✏️ Write commit hash to cache
if : ${{ !steps.fingerprint.outputs.includes-changes }}
run : echo ${{ github.sha }} > most-recent-testflight-commit.txt
2024-04-04 03:04:48 +02:00
2024-04-04 00:14:44 +02:00
# GitHub actions are horrible so let's just copy paste this in
buildIfNecessaryIOS :
name : Build and Submit iOS
runs-on : macos-14
2024-04-08 17:54:50 +02:00
concurrency :
group : ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}-build-ios
2024-05-29 01:38:24 +02:00
cancel-in-progress : true
2024-04-04 00:14:44 +02:00
needs : [ bundleDeploy]
# Gotta check if its NOT '[]' because any md5 hash in the outputs is detected as a possible secret and won't be
# available here
2024-05-29 01:38:24 +02:00
if : ${{ inputs.channel != 'production' && needs.bundleDeploy.outputs.changes-detected }}
2024-04-04 00:14:44 +02:00
steps :
- name : Check for EXPO_TOKEN
run : >
if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
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"
exit 1
fi
- name : ⬇️ Checkout
uses : actions/checkout@v4
2024-05-07 05:13:12 +02:00
with :
fetch-depth : 5
2024-04-04 00:14:44 +02:00
- name : 🔧 Setup Node
uses : actions/setup-node@v4
with :
node-version-file : .nvmrc
cache : yarn
- name : 🔨 Setup EAS
uses : expo/expo-github-action@v8
with :
expo-version : latest
eas-version : latest
token : ${{ secrets.EXPO_TOKEN }}
- name : ⛏️ Setup EAS local builds
run : yarn global add eas-cli-local-build-plugin
- name : ⚙️ Install dependencies
run : yarn install
2024-05-29 10:50:06 +02:00
- uses : maxim-lobanov/setup-xcode@v1
with :
xcode-version : '15.3'
2024-04-04 00:14:44 +02:00
- name : ☕️ Setup Cocoapods
uses : maxim-lobanov/setup-cocoapods@v1
with :
version : 1.14 .3
- name : 💾 Cache Pods
uses : actions/cache@v3
id : pods-cache
with :
path : ./ios/Pods
# We'll use the yarn.lock for our hash since we don't yet have a Podfile.lock. Pod versions will not
# change unless the yarn version changes as well.
key : ${{ runner.os }}-pods-${{ hashFiles('yarn.lock') }}
- name : 🔤 Compile translations
run : yarn intl:build
- name : ✏️ Write environment variables
run : |
echo "${{ secrets.ENV_TOKEN }}" > .env
2024-05-05 01:33:10 +02:00
echo "EXPO_PUBLIC_BUNDLE_IDENTIFIER=$(git rev-parse --short HEAD)" >> .env
echo "EXPO_PUBLIC_BUNDLE_DATE=$(date -u +"%y%m%d%H")" >> .env
2024-04-04 00:14:44 +02:00
echo "${{ secrets.GOOGLE_SERVICES_TOKEN }}" > google-services.json
- name : 🏗️ EAS Build
run : yarn use-build-number-with-bump eas build -p ios --profile testflight --local --output build.ipa --non-interactive
- name : 🚀 Deploy
run : eas submit -p ios --non-interactive --path build.ipa
2024-05-29 01:38:24 +02:00
- name : ⬇️ Restore Cache
id : get-base-commit
uses : actions/cache@v4
if : ${{ inputs.channel == 'testflight' }}
with :
path : most-recent-testflight-commit.txt
key : most-recent-testflight-commit
- name : ✏️ Write commit hash to cache
if : ${{ inputs.channel == 'testflight' }}
run : echo ${{ github.sha }} > most-recent-testflight-commit.txt
2024-04-04 00:14:44 +02:00
buildIfNecessaryAndroid :
name : Build and Submit Android
runs-on : ubuntu-latest
2024-04-08 17:54:50 +02:00
concurrency :
group : ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}-build-android
cancel-in-progress : false
2024-04-04 00:14:44 +02:00
needs : [ bundleDeploy ]
# Gotta check if its NOT '[]' because any md5 hash in the outputs is detected as a possible secret and won't be
# available here
2024-05-29 01:38:24 +02:00
if : ${{ inputs.channel != 'production' && needs.bundleDeploy.outputs.changes-detected }}
2024-04-04 00:14:44 +02:00
steps :
- name : Check for EXPO_TOKEN
run : >
if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
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"
exit 1
fi
- name : ⬇️ Checkout
uses : actions/checkout@v4
2024-05-07 05:13:12 +02:00
with :
fetch-depth : 5
2024-04-04 00:14:44 +02:00
- name : 🔧 Setup Node
uses : actions/setup-node@v4
with :
node-version-file : .nvmrc
cache : yarn
- name : 🔨 Setup EAS
uses : expo/expo-github-action@v8
with :
expo-version : latest
eas-version : latest
token : ${{ secrets.EXPO_TOKEN }}
- name : ⛏️ Setup EAS local builds
run : yarn global add eas-cli-local-build-plugin
- uses : actions/setup-java@v4
with :
distribution : 'temurin'
java-version : '17'
- name : ⚙️ Install dependencies
run : yarn install
- name : 🔤 Compile translations
run : yarn intl:build
- name : ✏️ Write environment variables
run : |
export json='${{ secrets.GOOGLE_SERVICES_TOKEN }}'
echo "${{ secrets.ENV_TOKEN }}" > .env
2024-05-05 01:33:10 +02:00
echo "EXPO_PUBLIC_BUNDLE_IDENTIFIER=$(git rev-parse --short HEAD)" >> .env
echo "EXPO_PUBLIC_BUNDLE_DATE=$(date -u +"%y%m%d%H")" >> .env
2024-04-04 00:14:44 +02:00
echo "$json" > google-services.json
- name : 🏗️ EAS Build
run : yarn use-build-number-with-bump eas build -p android --profile testflight-android --local --output build.apk --non-interactive
- name : ⏰ Get a timestamp
id : timestamp
uses : nanzm/get-time-action@master
with :
format : 'MM-DD-HH-mm-ss'
- name : 🚀 Upload Artifact
id : upload-artifact
uses : actions/upload-artifact@v4
with :
retention-days : 30
compression-level : 0
name : build-${{ steps.timestamp.outputs.time }}.apk
path : build.apk
- name : 🔔 Notify Slack
uses : slackapi/slack-github-action@v1.25.0
with :
payload : |
{
"text": "Android build is ready for testing. Download the artifact here: ${{ steps.upload-artifact.outputs.artifact-url }}"
}
env :
SLACK_WEBHOOK_URL : ${{ secrets.SLACK_CLIENT_ALERT_WEBHOOK }}
SLACK_WEBHOOK_TYPE : INCOMING_WEBHOOK
2024-05-29 01:38:24 +02:00
- name : ⬇️ Restore Cache
id : get-base-commit
uses : actions/cache@v4
2024-05-29 11:56:36 +02:00
if : ${{ inputs.channel != 'testflight' && inputs.channel != 'production' }}
2024-05-29 01:38:24 +02:00
with :
path : most-recent-testflight-commit.txt
key : most-recent-testflight-commit
- name : ✏️ Write commit hash to cache
2024-05-29 11:56:36 +02:00
if : ${{ inputs.channel != 'testflight' && inputs.channel != 'production' }}
2024-05-29 01:38:24 +02:00
run : echo ${{ github.sha }} > most-recent-testflight-commit.txt