diff --git a/.github/actions/compile-i18n/action.yml b/.github/actions/compile-i18n/action.yml new file mode 100644 index 0000000000..9324ff17bf --- /dev/null +++ b/.github/actions/compile-i18n/action.yml @@ -0,0 +1,15 @@ +--- +name: Compile translations +description: Compile i18n translations and fail on compilation errors. + +runs: + using: composite + steps: + - name: 🔤 Compile translations + shell: bash + run: pnpm intl:build 2>&1 | tee i18n.log + + - name: Check for i18n compilation errors + shell: bash + run: if grep -q "invalid syntax" "i18n.log"; then echo "\n\nFound compilation + errors!\n\n" && exit 1; else echo "\n\nNo compilation errors!\n\n"; fi diff --git a/.github/actions/setup-expo-project/action.yml b/.github/actions/setup-expo-project/action.yml new file mode 100644 index 0000000000..1369ba0cb6 --- /dev/null +++ b/.github/actions/setup-expo-project/action.yml @@ -0,0 +1,47 @@ +--- +name: Setup Expo Project +description: Install dependencies and set up the Expo/EAS CLI for a build. Does not check out the repo. + +inputs: + expo-token: + description: Expo token (EXPO_TOKEN secret) + required: true + eas-version: + description: EAS CLI version to install + required: false + default: '19.0.5' + +runs: + using: composite + steps: + - name: Check for EXPO_TOKEN + shell: bash + env: + EXPO_TOKEN: ${{ inputs.expo-token }} + run: > + if [ -z "$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 + + - uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 + + - name: 🔧 Setup Node + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 + with: + node-version-file: package.json + cache: pnpm + + - name: 🪛 Setup jq + uses: dcarbone/install-jq-action@4fcb5062d7ce9bc4382d1a352d19ba3ba2c317c1 # v4.0.1 + + - name: ⚙️ Install dependencies + shell: bash + run: pnpm install --frozen-lockfile + + - name: 🔨 Setup Expo CLI + uses: expo/expo-github-action@eab7a230208c952974db8c3245cfd78402c7b385 # 9.0.0 + with: + eas-version: ${{ inputs.eas-version }} + packager: 'pnpm --allow-build=dtrace-provider' + token: ${{ inputs.expo-token }} diff --git a/.github/actions/write-env/action.yml b/.github/actions/write-env/action.yml new file mode 100644 index 0000000000..7cb3464188 --- /dev/null +++ b/.github/actions/write-env/action.yml @@ -0,0 +1,63 @@ +--- +name: Write Environment Variables +description: Write the .env file and google-services.json used by the build. + +inputs: + env-token: + description: Base .env contents (ENV_TOKEN secret) + required: true + sentry-dsn: + description: Sentry DSN (SENTRY_DSN secret) + required: true + bitdrift-api-key: + description: Bitdrift API key (BITDRIFT_API_KEY secret) + required: true + gcp-project-id: + description: GCP project ID (EXPO_PUBLIC_GCP_PROJECT_ID secret) + required: true + google-services-token: + description: google-services.json contents (GOOGLE_SERVICES_TOKEN secret) + required: true + expo-public-env: + description: > + EXPO_PUBLIC_ENV value. Only set for OTA deploys where eas.json isn't used; + for regular builds this is normally handled in eas.json. + required: false + default: '' + +outputs: + release-version: + description: Version from package.json + value: ${{ steps.env.outputs.release-version }} + bundle-identifier: + description: git SHA of HEAD + value: ${{ steps.env.outputs.bundle-identifier }} + +runs: + using: composite + steps: + - name: ✏️ Write environment variables + id: env + shell: bash + env: + ENV_TOKEN: ${{ inputs.env-token }} + SENTRY_DSN: ${{ inputs.sentry-dsn }} + BITDRIFT_API_KEY: ${{ inputs.bitdrift-api-key }} + GCP_PROJECT_ID: ${{ inputs.gcp-project-id }} + GOOGLE_SERVICES_TOKEN: ${{ inputs.google-services-token }} + EXPO_PUBLIC_ENV: ${{ inputs.expo-public-env }} + run: | + echo "$ENV_TOKEN" > .env + # EXPO_PUBLIC_ENV is normally handled in eas.json; only written here for OTA deploys. + if [ -n "$EXPO_PUBLIC_ENV" ]; then + echo "EXPO_PUBLIC_ENV=$EXPO_PUBLIC_ENV" >> .env + fi + echo "EXPO_PUBLIC_RELEASE_VERSION=$(jq -r '.version' package.json)" >> .env + echo "release-version=$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT + echo "EXPO_PUBLIC_BUNDLE_IDENTIFIER=$(git rev-parse HEAD)" >> .env + echo "bundle-identifier=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + echo "EXPO_PUBLIC_BUNDLE_DATE=$(date -u +"%y%m%d%H")" >> .env + echo "EXPO_PUBLIC_SENTRY_DSN=$SENTRY_DSN" >> .env + echo "EXPO_PUBLIC_BITDRIFT_API_KEY=$BITDRIFT_API_KEY" >> .env + echo "EXPO_PUBLIC_GCP_PROJECT_ID=$GCP_PROJECT_ID" >> .env + echo "$GOOGLE_SERVICES_TOKEN" > google-services.json