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-04 00:14:44 +02:00
outputs :
2024-04-04 03:04:48 +02:00
fingerprint-is-different : ${{ steps.fingerprint-debug.outputs.fingerprint-is-different }}
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 :
fetch-depth : 100
- 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
# This should get the current production release's commit's hash to see if the update is compatible
- name : 🕵️ Get the base commit
id : base-commit
run : |
if [ -z "${{ inputs.channel == 'production' }}" ]; then
echo base-commit=$(git show-ref -s ${{ inputs.runtimeVersion }}) >> "$GITHUB_OUTPUT"
else
echo base-commit=$(git log -n 1 --skip 1 main --pretty=format:'%H') >> "$GITHUB_OUTPUT"
fi
- name : ✓ Make sure we found a base commit
run : |
if [ -z "${{ steps.base-commit.outputs.base-commit }}" ]; then
echo "Could not find a base commit for this release. Exiting."
exit 1
fi
2024-03-19 19:18:22 +01:00
- name : 🔧 Setup Node
uses : actions/setup-node@v4
with :
node-version-file : .nvmrc
cache : yarn
- name : ⚙️ Install Dependencies
run : yarn install
2024-04-04 00:14:44 +02:00
# Run the fingerprint
- name : 📷 Check fingerprint
id : fingerprint
uses : expo/expo-github-action/fingerprint@main
with :
previous-git-commit : ${{ steps.base-commit.outputs.base-commit }}
2024-04-04 05:59:33 +02:00
args :
2024-04-04 00:14:44 +02:00
- name : 👀 Debug fingerprint
2024-04-04 03:04:48 +02:00
id : fingerprint-debug
2024-04-04 00:14:44 +02:00
run : |
echo "previousGitCommit=${{ steps.fingerprint.outputs.previous-git-commit }} currentGitCommit=${{ steps.fingerprint.outputs.current-git-commit }}"
echo "isPreviousFingerprintEmpty=${{ steps.fingerprint.outputs.previous-fingerprint == '' }}"
2024-04-04 03:04:48 +02:00
2024-04-04 05:59:33 +02:00
fingerprintDiff="${{ steps.fingerprint.outputs.fingerprint-diff }}"
if [[ $fingerprintDiff =~ "bareRncliAutolinking" || $fingerprintDiff =~ "expoAutolinkingAndroid" || $fingerprintDiff =~ "expoAutolinkingIos" ]]; then
2024-04-04 03:04:48 +02:00
echo fingerprint-is-different="true" >> "$GITHUB_OUTPUT"
else
echo fingerprint-is-different="false" >> "$GITHUB_OUTPUT"
fi
2024-04-04 00:14:44 +02:00
- name : 🔨 Setup EAS
uses : expo/expo-github-action@v8
2024-04-04 05:59:33 +02:00
if : ${{ steps.fingerprint-debug.outputs.fingerprint-is-different == 'false'}}
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-04-04 05:59:33 +02:00
if : ${{ steps.fingerprint-debug.outputs.fingerprint-is-different == 'false'}}
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-04-04 05:59:33 +02:00
if : ${{ steps.fingerprint-debug.outputs.fingerprint-is-different == 'false'}}
2024-04-04 00:14:44 +02:00
uses : dcarbone/install-jq-action@v2
2024-03-19 19:18:22 +01:00
- name : 🔤 Compile Translations
2024-04-04 05:59:33 +02:00
if : ${{ steps.fingerprint-debug.outputs.fingerprint-is-different == 'false'}}
2024-03-19 19:18:22 +01:00
run : yarn intl:build
- name : ✏️ Write environment variables
2024-04-04 05:59:33 +02:00
if : ${{ steps.fingerprint-debug.outputs.fingerprint-is-different == 'false'}}
2024-03-19 19:18:22 +01:00
run : |
export json='${{ secrets.GOOGLE_SERVICES_TOKEN }}'
echo "${{ secrets.ENV_TOKEN }}" > .env
echo "$json" > google-services.json
- name : 🏗️ Create Bundle
2024-04-04 05:59:33 +02:00
if : ${{ steps.fingerprint-debug.outputs.fingerprint-is-different == 'false'}}
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-04-04 05:59:33 +02:00
if : ${{ steps.fingerprint-debug.outputs.fingerprint-is-different == 'false'}}
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-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
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-04-04 03:04:48 +02:00
if : ${{ inputs.channel != 'production' && needs.bundleDeploy.outputs.fingerprint-is-different == 'true' }}
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
- 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
- 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
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
buildIfNecessaryAndroid :
name : Build and Submit Android
runs-on : ubuntu-latest
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-04-04 03:04:48 +02:00
if : ${{ inputs.channel != 'production' && needs.bundleDeploy.outputs.fingerprint-is-different == 'true' }}
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
- 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
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