Skip to content

Commit

Permalink
Fix build device type (#23)
Browse files Browse the repository at this point in the history
* fix(apps/web): inject `DEVICE` dynamically when building for different
platform

* fix(actions/desktop-release): downgrade ubuntu to from latest to 20
  • Loading branch information
GervinFung authored Apr 14, 2024
1 parent f2892f4 commit 42d179d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/desktop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
threads: [4]

config:
- os: ubuntu-latest
- os: ubuntu-20.04
arch: x86_64

- os: macos-latest
Expand Down
4 changes: 2 additions & 2 deletions apps/mobile/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ sync-android:
clean-android:
cd android && ./gradlew clean

build-production-android: build-executable-production build
build-production-android: build-executable-production sync-android build
cd android && ./gradlew assembleRelease

build-development-android: build-executable-development build
build-development-android: build-executable-development sync-android build
cd android && ./gradlew assembleDebug

# format
Expand Down
3 changes: 3 additions & 0 deletions apps/web/next/desktop.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const config = {
images: {
unoptimized: true,
},
env: {
DEVICE: 'desktop',
},
};

export default config;
3 changes: 3 additions & 0 deletions apps/web/next/mobile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const config = {
images: {
unoptimized: true,
},
env: {
DEVICE: 'mobile',
},
};

export default config;
10 changes: 9 additions & 1 deletion apps/web/src/web/components/pages/index/native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ import type { ClassificationProps } from '../../../../../pages/classifications/[
import type { SubshellProps } from '../../../../../pages/subshells/[subshell]';

const NativeIndex = (props: ClassificationProps & SubshellProps) => {
return <Index {...props} type="desktop" />;
const device = process.env.DEVICE;

if (device === 'mobile') {
return <Index {...props} type="mobile" />;
} else if (device === 'desktop') {
return <Index {...props} type="desktop" />;
}

throw new Error(`Unknown device: ${device}`);
};

export default NativeIndex;

0 comments on commit 42d179d

Please sign in to comment.