Skip to content

Commit

Permalink
Merge pull request #936 from andrew-bierman/fix/android-build-2
Browse files Browse the repository at this point in the history
Fix config for android local build
  • Loading branch information
andrew-bierman authored May 16, 2024
2 parents 560aa1c + d6f9c01 commit 277e705
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 88 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/expo.build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env: # Define a shared environment variable for android and ios build.
MAPBOX_DOWNLOADS_TOKEN: ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }}
EXPO_PUBLIC_CLIENT_URL: ${{ secrets.EXPO_PUBLIC_CLIENT_URL }}
EXPO_PUBLIC_API_URL: ${{ secrets.EXPO_PUBLIC_API_URL }}
EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN: ${{ secrets.EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN }}

jobs:
build-android:
runs-on: ubuntu-latest
Expand All @@ -31,9 +37,9 @@ jobs:
- name: Run Local Build for Android
working-directory: ./apps/expo
run: |
eas build --non-interactive --platform android --local
eas build --profile preview --platform android --local --non-interactive
env:
MAPBOX_DOWNLOADS_TOKEN: ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }}
EXPO_PUBLIC_ANDROID_CLIENT_ID: ${{ secrets.EXPO_PUBLIC_ANDROID_CLIENT_ID }}

- name: Upload APK
uses: actions/upload-artifact@v3
Expand All @@ -60,12 +66,12 @@ jobs:
- name: Run Local Build for iOS
working-directory: ./apps/expo
run: |
eas build --non-interactive --platform ios --local
eas build --profile preview --platform ios --local --non-interactive
env:
MAPBOX_DOWNLOADS_TOKEN: ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }}
EXPO_PUBLIC_IOS_CLIENT_ID: ${{ secrets.EXPO_PUBLIC_IOS_CLIENT_ID }}

- name: Upload IPA
uses: actions/upload-artifact@v3
with:
name: ios-ipa
path: /home/runner/work/PackRat/PackRat/apps/expo/build-*.ipa
path: /home/runner/work/PackRat/PackRat/apps/expo/build-*.ipa
13 changes: 0 additions & 13 deletions apps/expo/app.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
import 'dotenv/config';

module.exports = ({ config }) => {
config.extra.NODE_ENV = process.env.NODE_ENV;
config.extra.CLIENT_URL = process.env.CLIENT_URL;
config.extra.MAPBOX_ACCESS_TOKEN = process.env.MAPBOX_ACCESS_TOKEN;
config.extra.API_URL = process.env.API_URL;

config.extra.EXPO_PUBLIC_NODE_ENV = process.env.EXPO_PUBLIC_NODE_ENV;
config.extra.EXPO_PUBLIC_CLIENT_URL = process.env.EXPO_PUBLIC_CLIENT_URL;
config.extra.EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN =
process.env.EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN;
config.extra.EXPO_PUBLIC_API_URL = process.env.EXPO_PUBLIC_API_URL;

return {
...config,
plugins: config.plugins.map((i) => {
Expand Down
28 changes: 7 additions & 21 deletions apps/expo/env.example
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
—————————Client Env ———————————
MONGODB_URI="Your mongodb URI"
CLIENT_URL="Your client url"
—————————EXPO CLIENT ENV ———————————
NODE_ENV='development'
API_URL='Your api url'
NPS_API = "Your api key"
GEOAPIFY_KEY = "Your api key"
GOOGLE_PLACES_API_KEY = 'Your api key'
MAPBOX_API_KEY = "Your api key, starts with pk..."
OPENWEATHER_KEY = "Your api key"
X_RAPIDAPI_KEY = "Your api key"
MAPBOX_ACCESS_TOKEN = "Your api key, starts with pk..."
EXPO_PUBLIC_CLIENT_URL="Your client url"
EXPO_PUBLIC_API_URL="Your api url"
EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN="Your api key, starts with pk..."
EXPO_PUBLIC_ANDROID_CLIENT_ID="962352557394-........................apps.googleusercontent.com"
EXPO_PUBLIC_IOS_CLIENT_ID="962352557394-........................apps.googleusercontent.com"
MAPBOX_DOWNLOADS_TOKEN="Your api key, starts with sk..."
WEB_CLIENT_ID="962352557394-..................apps.googleusercontent.com"
ANDROID_CLIENT_ID="962352557394-........................apps.googleusercontent.com"
IOS_CLIENT_ID="962352557394-........................apps.googleusercontent.com"
FIREBASE_API_KEY = 'Your api key'
FIREBASE_AUTH_DOMAIN = "Your auth domain"
FIREBASE_PROJECT_ID = "Your firebase project id"
FIREBASE_STORAGE_BUCKET = "Your firebase_storage_key_link"
FIREBASE_MESSAGING_SENDER_ID = "Your firebase_messaging_sender_ID"
FIREBASE_APP_ID = "Your firebase app id"
FIREBASE_MEASUREMENT_ID = "Your firebase_measurement_id"

8 changes: 8 additions & 0 deletions apps/next/env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
—————————NEXT CLIENT ENV———————————
NODE_ENV='development'
NEXT_PUBLIC_APP='next'
NEXT_PUBLIC_CLIENT_URL="Your client url"
NEXT_PUBLIC_API_URL="Your api url"
NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN="Your api key, starts with pk..."
NEXT_PUBLIC_WEB_CLIENT_ID="962352557394-..................apps.googleusercontent.com"

8 changes: 8 additions & 0 deletions apps/vite/env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
—————————VITE CLIENT ENV———————————
NODE_ENV='development'
VITE_PUBLIC_APP='vite'
VITE_PUBLIC_CLIENT_URL="Your client url"
VITE_PUBLIC_API_URL="Your api url"
VITE_PUBLIC_MAPBOX_ACCESS_TOKEN="Your api key, starts with pk..."
VITE_PUBLIC_WEB_CLIENT_ID="962352557394-..................apps.googleusercontent.com"

4 changes: 2 additions & 2 deletions packages/app/auth/hooks/useGoogleAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import * as Google from 'expo-auth-session/providers/google';

import { queryTrpc } from 'app/trpc';
import { useSessionSignIn } from './useSessionSignIn';
import { GOOGLE_ID, IOS_CLIENT_ID, ANDROID_CLIENT_ID } from '@packrat/config';
import { WEB_CLIENT_ID, IOS_CLIENT_ID, ANDROID_CLIENT_ID } from '@packrat/config';

const webClientId = String(GOOGLE_ID);
const webClientId = String(WEB_CLIENT_ID);
const iosClientId = String(IOS_CLIENT_ID);
const androidClientId = String(ANDROID_CLIENT_ID);

Expand Down
7 changes: 5 additions & 2 deletions packages/app/constants/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// export const api = "http://add your ip address";

import { API_URL } from '@packrat/config';

/**
* The api url.
* format: "{scheme}://{serverhost}:{port}/api"
* e.g: "http://localhost:4200/api"
*/
export const api = API_URL;
5 changes: 1 addition & 4 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
"name": "@packrat/config",
"version": "1.0.0",
"private": true,
"main": "src/index.js",
"dependencies": {
"react-native": "0.73.6"
}
"main": "src/index.js"
}
23 changes: 11 additions & 12 deletions packages/config/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Platform } from 'react-native';
import { viteSource } from './sources/vite';

/**
Expand All @@ -8,38 +7,38 @@ import { viteSource } from './sources/vite';

// Simplifying environment variable access using logical OR
const API_URL =
viteSource?.VITE_PUBLIC_API_URL ||
viteSource.VITE_PUBLIC_API_URL ||
process.env.NEXT_PUBLIC_API_URL ||
process.env.EXPO_PUBLIC_API_URL;
const GOOGLE_ID =
viteSource?.VITE_PUBLIC_GOOGLE_ID ||
process.env.NEXT_PUBLIC_GOOGLE_ID ||
process.env.EXPO_PUBLIC_GOOGLE_ID;
const WEB_CLIENT_ID =
viteSource.VITE_PUBLIC_WEB_CLIENT_ID ||
process.env.NEXT_PUBLIC_WEB_CLIENT_ID ||
process.env.EXPO_PUBLIC_WEB_CLIENT_ID;
const IOS_CLIENT_ID =
viteSource?.VITE_PUBLIC_IOS_CLIENT_ID ||
viteSource.VITE_PUBLIC_IOS_CLIENT_ID ||
process.env.NEXT_PUBLIC_IOS_CLIENT_ID ||
process.env.EXPO_PUBLIC_IOS_CLIENT_ID;
const ANDROID_CLIENT_ID =
viteSource?.VITE_PUBLIC_ANDROID_CLIENT_ID ||
viteSource.VITE_PUBLIC_ANDROID_CLIENT_ID ||
process.env.NEXT_PUBLIC_ANDROID_CLIENT_ID ||
process.env.EXPO_PUBLIC_ANDROID_CLIENT_ID;
const MAPBOX_ACCESS_TOKEN =
viteSource?.VITE_PUBLIC_MAPBOX_ACCESS_TOKEN ||
viteSource.VITE_PUBLIC_MAPBOX_ACCESS_TOKEN ||
process.env.NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN ||
process.env.EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN;
const APP =
viteSource?.VITE_PUBLIC_APP ||
viteSource.VITE_PUBLIC_APP ||
process.env.NEXT_PUBLIC_APP ||
process.env.EXPO_PUBLIC_APP;
const CLIENT_URL =
viteSource?.VITE_PUBLIC_CLIENT_URL ||
viteSource.VITE_PUBLIC_CLIENT_URL ||
process.env.NEXT_PUBLIC_CLIENT_URL ||
process.env.EXPO_PUBLIC_CLIENT_URL;
const NODE_ENV = process.env.NODE_ENV;

export {
API_URL,
GOOGLE_ID,
WEB_CLIENT_ID,
IOS_CLIENT_ID,
ANDROID_CLIENT_ID,
MAPBOX_ACCESS_TOKEN,
Expand Down
2 changes: 1 addition & 1 deletion packages/config/src/sources/vite/viteSource.native.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// DUMMY FILE. This is not actually used in the project. It is to fix Expo's build process.

export const viteSource = process.env,
export const viteSource = {};

4 changes: 1 addition & 3 deletions packages/crosspath/types/lib-interface.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { LinkComponent, Router, CreateParam } from './model';
export declare function Link(
props: Parameters<LinkComponent>,
): ReturnType<LinkComponent>;
export declare function Link(props: Parameters<LinkComponent>): ReturnType<LinkComponent>;
export declare const createParam: CreateParam;
export declare function useRouter(): Router;
41 changes: 18 additions & 23 deletions packages/crosspath/types/model/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
import { FC } from 'react';
import { LinkProps } from 'solito/link';
export interface CreateParamOptions {
initial?: string;
parse?: (param: string) => unknown;
stringify?: (param: unknown) => string;
initial?: string;
parse?: (param: string) => unknown;
stringify?: (param: unknown) => string;
}
export interface Router {
push: (url: URL) => void;
replace: (url: URL) => void;
back: () => void;
push: (url: URL) => void;
replace: (url: URL) => void;
back: () => void;
}
export type LinkComponent = FC<LinkProps>;
export type URL =
| string
| {
pathname?: string;
query?: Record<string, any>;
state?: Record<string, any>;
hash?: string;
as?: string | object;
};
export type URL = string | {
pathname?: string;
query?: Record<string, any>;
state?: Record<string, any>;
hash?: string;
as?: string | object;
};
export type CreateParam = <T>() => {
useParam: (
key: keyof T,
options?: CreateParamOptions,
) => [value: any, setValue: (value: any) => void];
useParams: (key: keyof T) => {
params: T;
setParams: (value: any) => void;
};
useParam: (key: keyof T, options?: CreateParamOptions) => [value: any, setValue: (value: any) => void];
useParams: (key: keyof T) => {
params: T;
setParams: (value: any) => void;
};
};
2 changes: 0 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5326,8 +5326,6 @@ __metadata:
"@packrat/config@workspace:packages/config":
version: 0.0.0-use.local
resolution: "@packrat/config@workspace:packages/config"
dependencies:
react-native: "npm:0.73.6"
languageName: unknown
linkType: soft

Expand Down

0 comments on commit 277e705

Please sign in to comment.