Skip to content

feat: disable OTA builds, trigger release (#60) #96

feat: disable OTA builds, trigger release (#60)

feat: disable OTA builds, trigger release (#60) #96

Workflow file for this run

name: EAS Build
on:
push:
branches:
- main
- 'hotfix/*'
- 'feature/*'
paths-ignore:
- '**.md'
workflow_dispatch:
inputs:
debug-mode:
description: 'Run in debug mode (skips EAS builds)'
type: boolean
default: false
jobs:
determine-release-type:
runs-on: ubuntu-latest
outputs:
release-version: ${{ steps.read-version.outputs.release-version }}
steps:
- uses: actions/checkout@v4
- name: Read version from package.json
id: read-version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "release-version=$VERSION" >> $GITHUB_OUTPUT
eas-build:
needs: determine-release-type
if: >-
github.ref == 'refs/heads/main' ||
(startsWith(github.ref, 'refs/heads/hotfix/') && contains(github.event.head_commit.message, '[build]')) ||
(startsWith(github.ref, 'refs/heads/feature/') && contains(github.event.head_commit.message, '[build]'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: yarn
- name: Setup Expo and EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EAS_TOKEN }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Determine build profile
run: |
VERSION=${{ needs.determine-release-type.outputs.release-version }}
echo "App version: $VERSION"
if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then
# Check if this is a release-please commit
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
IS_RELEASE_PLEASE=false
if [[ "$COMMIT_MESSAGE" == *"chore(main): release"* || "$COMMIT_MESSAGE" == *"chore: release"* ]]; then
echo "Release-please commit detected: $COMMIT_MESSAGE"
IS_RELEASE_PLEASE=true
else
echo "Not a release-please commit, skipping build/update"
echo "RUN_BUILD=false" >> $GITHUB_ENV
exit 0
fi
# If it is a release-please commit, continue with version check
if [[ "$IS_RELEASE_PLEASE" == "true" ]]; then
if [[ "$VERSION" =~ ^[0-9]+\.0\.0$ || "$VERSION" =~ ^[0-9]+\.[0-9]+\.0$ ]]; then
echo "Major or minor version bump detected - running production build"
echo "EAS_BUILD_PROFILE=production" >> $GITHUB_ENV
echo "RUN_BUILD=true" >> $GITHUB_ENV
else
echo "Patch version detected - running update instead of build"
echo "RUN_BUILD=false" >> $GITHUB_ENV
fi
fi
else
echo "EAS_BUILD_PROFILE=development" >> $GITHUB_ENV
echo "RUN_BUILD=true" >> $GITHUB_ENV
fi
- name: Run EAS Build or Publish
run: |
if [[ "${{ github.event.inputs.debug-mode }}" == "true" ]]; then
echo "DEBUG_MODE=true" >> $GITHUB_ENV
echo "EAS_BUILD_PROFILE=debug" >> $GITHUB_ENV
echo "RUN_BUILD=true" >> $GITHUB_ENV
echo "Skipping EAS build (debug mode)"
elif [[ "$RUN_BUILD" == "true" ]]; then
echo "Triggering EAS build with profile: $EAS_BUILD_PROFILE"
eas build --platform all --profile $EAS_BUILD_PROFILE --non-interactive
else
echo "OTA update disabled, skipping EAS build"
fi
# COMMIT_MESSAGE=$(git log -1 --pretty=%B | head -n 1)
# eas update --channel production --message "${COMMIT_MESSAGE}" --non-interactive
- name: Install QR Code Generator
if: ${{ env.RUN_BUILD == 'true' }}
run: npm install qrcode
- name: Fetch EAS Build URLs and generate QR codes
if: ${{ env.RUN_BUILD == 'true' }}
id: get-urls
run: |
if [[ "$DEBUG_MODE" == "true" ]]; then
echo "Using sample build URLs for testing"
ANDROID_URL=https://expo.dev/artifacts/eas/4jL44bjvpdC9oXxyZL7JQ4.apk
IOS_URL=https://expo.dev/artifacts/eas/c7svE9G9ZJZ23iU3FbrhmF.ipa
else
BUILD_JSON=$(eas build:list --status finished --limit 5 --json --non-interactive)
echo "$BUILD_JSON" > builds.json
ANDROID_URL=$(jq -r '.[] | select(.platform=="ANDROID") | .artifacts.buildUrl' builds.json | head -n 1)
IOS_URL=$(jq -r '.[] | select(.platform=="IOS") | .artifacts.buildUrl' builds.json | head -n 1)
fi
echo "ANDROID_URL=$ANDROID_URL" >> $GITHUB_ENV
echo "IOS_URL=$IOS_URL" >> $GITHUB_ENV
# Print URLs for debugging
echo "Android URL: $ANDROID_URL"
echo "iOS URL: $IOS_URL"
mkdir -p qrcodes
node <<EOF
const QRCode = require('qrcode');
const fs = require('fs');
// Pass URLs directly as arguments rather than accessing environment
const androidUrl = "$ANDROID_URL";
const iosUrl = "$IOS_URL";
async function generateQRCode() {
try {
if (androidUrl && androidUrl.trim() !== '' && androidUrl !== 'null') {
await QRCode.toFile('qrcodes/android.png', androidUrl);
console.log('Android QR code generated successfully');
} else {
console.log('Skipping Android QR code generation - no valid URL');
}
if (iosUrl && iosUrl.trim() !== '' && iosUrl !== 'null') {
await QRCode.toFile('qrcodes/ios.png', iosUrl);
console.log('iOS QR code generated successfully');
} else {
console.log('Skipping iOS QR code generation - no valid URL');
}
} catch (error) {
console.error('Error generating QR code:', error);
process.exit(1);
}
}
generateQRCode();
EOF
- name: Check for valid build URLs
if: ${{ env.RUN_BUILD == 'true' }}
id: check-urls
run: |
if [[ -z "$ANDROID_URL" && -z "$IOS_URL" ]]; then
echo "No build URLs found, skipping Slack notification"
echo "SKIP_SLACK=true" >> $GITHUB_ENV
else
echo "Valid build URLs found, proceeding with Slack notification"
echo "SKIP_SLACK=false" >> $GITHUB_ENV
# Check for QR code files
if [[ ! -f "qrcodes/android.png" && ! -z "$ANDROID_URL" ]]; then
echo "Warning: Android URL exists but QR code was not generated"
fi
if [[ ! -f "qrcodes/ios.png" && ! -z "$IOS_URL" ]]; then
echo "Warning: iOS URL exists but QR code was not generated"
fi
fi
- name: Check for QR code files
if: ${{ env.RUN_BUILD == 'true' && env.SKIP_SLACK != 'true' }}
id: check-qr-files
run: |
if [[ -f "qrcodes/android.png" && ! -z "$ANDROID_URL" ]]; then
echo "ANDROID_QR_EXISTS=true" >> $GITHUB_ENV
else
echo "ANDROID_QR_EXISTS=false" >> $GITHUB_ENV
fi
if [[ -f "qrcodes/ios.png" && ! -z "$IOS_URL" ]]; then
echo "IOS_QR_EXISTS=true" >> $GITHUB_ENV
else
echo "IOS_QR_EXISTS=false" >> $GITHUB_ENV
fi
- name: Send Build Header to Slack
if: ${{ env.RUN_BUILD == 'true' && env.SKIP_SLACK != 'true' }}
id: slack_header
uses: slackapi/slack-github-action@v2.0.0
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: C08QF24E2EB
text: "*New Gather Build Complete*"
blocks:
- type: header
text:
type: plain_text
text: "New Gather Build Complete"
- type: section
text:
type: mrkdwn
text: "*Version:* ${{ needs.determine-release-type.outputs.release-version }}\n*Profile:* ${{ env.EAS_BUILD_PROFILE }}\n*Commit:* ${{ github.event.head_commit.message || 'No commit message available' }}"
# Android message
- name: Send Android build info
if: ${{ env.RUN_BUILD == 'true' && env.SKIP_SLACK != 'true' && env.ANDROID_URL != '' }}
uses: slackapi/slack-github-action@v2.0.0
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: C08QF24E2EB
thread_ts: "${{ steps.slack_header.outputs.ts }}"
text: "*Android:* <${{ env.ANDROID_URL }}|Download APK>"
# Android QR code
- name: Upload Android QR code
if: ${{ env.RUN_BUILD == 'true' && env.SKIP_SLACK != 'true' && env.ANDROID_URL != '' && env.ANDROID_QR_EXISTS == 'true' }}
uses: slackapi/slack-github-action@v2.0.0
with:
method: files.uploadV2
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel_id: C08QF24E2EB
thread_ts: "${{ steps.slack_header.outputs.ts }}"
file: "./qrcodes/android.png"
filename: "android-qr.png"
# iOS message
- name: Send iOS build info
if: ${{ env.RUN_BUILD == 'true' && env.SKIP_SLACK != 'true' && env.IOS_URL != '' }}
uses: slackapi/slack-github-action@v2.0.0
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: C08QF24E2EB
thread_ts: "${{ steps.slack_header.outputs.ts }}"
text: "*iOS:* <${{ env.IOS_URL }}|Download IPA>"
# iOS QR code
- name: Upload iOS QR code
if: ${{ env.RUN_BUILD == 'true' && env.SKIP_SLACK != 'true' && env.IOS_URL != '' && env.IOS_QR_EXISTS == 'true' }}
uses: slackapi/slack-github-action@v2.0.0
with:
method: files.uploadV2
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel_id: C08QF24E2EB
thread_ts: "${{ steps.slack_header.outputs.ts }}"
file: "./qrcodes/ios.png"
filename: "ios-qr.png"