From fb84a8939e515635bd95002933d432f934eb14cf Mon Sep 17 00:00:00 2001 From: Mykhailo Danilenko Date: Tue, 29 Oct 2024 17:46:34 +0200 Subject: [PATCH 1/3] add build step for generating ios simulator .app file artifact --- .github/workflows/deploy-static-main.yml | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.github/workflows/deploy-static-main.yml b/.github/workflows/deploy-static-main.yml index 5b662f1..0283156 100644 --- a/.github/workflows/deploy-static-main.yml +++ b/.github/workflows/deploy-static-main.yml @@ -128,6 +128,46 @@ jobs: name: release apk path: "./OwnTube.tv/android/app/build/outputs/apk/release/app-release.apk" + build_ios_app: + needs: [code_quality, build_info] + runs-on: self-hosted + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node 20 + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Install Dependencies + run: cd OwnTube.tv/ && npm install + + - name: Expo Prebuild ios assets + run: cd OwnTube.tv/ && npx expo prebuild --clean --platform ios + + - name: Inject Build Info + run: | + # Overwrite build-info.json in source root dir + cat < ./OwnTube.tv/build-info.json + { + "GITHUB_ACTOR": "${{ needs.build_info.outputs.GITHUB_ACTOR }}", + "GITHUB_SHA_SHORT": "${{ needs.build_info.outputs.GITHUB_SHA_SHORT }}", + "COMMIT_URL": "${{ needs.build_info.outputs.COMMIT_URL }}", + "BUILD_TIMESTAMP": "${{ needs.build_info.outputs.BUILD_TIMESTAMP }}", + "WEB_URL": "${{ needs.build_info.outputs.WEB_URL }}" + } + EOF + + - name: "Build release .app for simulators by @${{ github.actor }}" + run: cd OwnTube.tv/ios/ && xcodebuild -workspace ./OwnTubetv.xcworkspace -scheme OwnTubetv -configuration Release -sdk iphonesimulator -derivedDataPath ./build-simulator + + - name: Upload .app artifact + uses: actions/upload-artifact@v4 + with: + name: ios-simulator-app.app + path: "./OwnTube.tv/ios/build-simulator/Build/Products/Release-iphonesimulator/OwnTubetv.app" + deploy_web: needs: [code_quality, build_info] runs-on: ubuntu-latest From 215a19807bd2c625e406079e8ebfd626fd5dc124 Mon Sep 17 00:00:00 2001 From: Mykhailo Danilenko Date: Thu, 31 Oct 2024 12:16:11 +0200 Subject: [PATCH 2/3] allow customization from env file --- .github/workflows/deploy-static-main.yml | 85 +++++++++++++++++-- OwnTube.tv/.env.example | 8 ++ OwnTube.tv/app.config.ts | 53 ++++++++++++ OwnTube.tv/app.json | 57 ------------- OwnTube.tv/app/(home)/channel-playlist.tsx | 3 +- OwnTube.tv/app/(home)/history.tsx | 3 +- OwnTube.tv/app/(home)/home.tsx | 8 +- OwnTube.tv/app/(home)/index.tsx | 7 +- OwnTube.tv/app/(home)/playlist.tsx | 3 +- OwnTube.tv/app/(home)/playlists.tsx | 6 +- .../components/modals/Settings.tsx | 3 +- OwnTube.tv/locales/en.json | 6 +- OwnTube.tv/locales/ru.json | 6 +- OwnTube.tv/locales/uk.json | 6 +- .../screens/LandingScreen/LandingScreen.tsx | 3 +- OwnTube.tv/types.ts | 13 --- 16 files changed, 165 insertions(+), 105 deletions(-) create mode 100644 OwnTube.tv/.env.example create mode 100644 OwnTube.tv/app.config.ts delete mode 100644 OwnTube.tv/app.json diff --git a/.github/workflows/deploy-static-main.yml b/.github/workflows/deploy-static-main.yml index 0283156..7ce9745 100644 --- a/.github/workflows/deploy-static-main.yml +++ b/.github/workflows/deploy-static-main.yml @@ -56,8 +56,42 @@ jobs: WEB_URL="https://${{ github.repository_owner }}.github.io/$REPO_NAME" echo "WEB_URL=$WEB_URL" && echo "WEB_URL=$WEB_URL" >> "$GITHUB_OUTPUT" + customizations_setup: + runs-on: ubuntu-latest + environment: owntube + outputs: + CUSTOMIZATIONS_ENV_CONTENT: ${{ steps.read_customization_file.outputs.CUSTOMIZATIONS_ENV_CONTENT }} + steps: + - name: Check for Customization Variables + id: check_customizations + run: | + if [[ -n ${{ vars.CLIENT_CUSTOMIZATIONS_REPO }} && -n ${{ vars.CLIENT_CUSTOMIZATIONS_FILE }} ]]; then + echo "should_run_customizations=true" >> $GITHUB_OUTPUT + else + echo "should_run_customizations=false" >> $GITHUB_OUTPUT + fi + + - name: Clone customizations repository + if: steps.check_customizations.outputs.should_run_customizations == 'true' + run: | + git clone "${{ vars.CLIENT_CUSTOMIZATIONS_REPO }}" customizations-repo + + - name: Find and read the customization file + id: read_customization_file + if: steps.check_customizations.outputs.should_run_customizations == 'true' + run: | + CUSTOMIZATION_FILE_PATH="customizations-repo/${{ vars.CLIENT_CUSTOMIZATIONS_FILE }}" + if [[ -f "$CUSTOMIZATION_FILE_PATH" ]]; then + echo "$(cat "$CUSTOMIZATION_FILE_PATH")" + echo 'CUSTOMIZATIONS_ENV_CONTENT<> $GITHUB_OUTPUT + printf "%s\n" $(cat "$CUSTOMIZATION_FILE_PATH") >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + else + exit 1 + fi + code_quality: - needs: build_info + needs: [customizations_setup, build_info] runs-on: ubuntu-latest steps: - name: Checkout @@ -76,7 +110,7 @@ jobs: run: cd OwnTube.tv/ && npm run test build_android_apk: - needs: [code_quality, build_info] + needs: [code_quality, build_info, customizations_setup] runs-on: ubuntu-latest steps: - name: Checkout @@ -90,6 +124,11 @@ jobs: - name: Install Dependencies run: cd OwnTube.tv/ && npm install + - name: Create .env File + if: ${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT != '' }} + run: | + echo "${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT }}" > ./OwnTube.tv/.env + - name: Expo Prebuild android assets run: cd OwnTube.tv/ && npx expo prebuild --clean --platform android @@ -119,7 +158,7 @@ jobs: } EOF - - name: "Build release .apk by @${{ github.actor }}" + - name: Build release .apk by @${{ github.actor }} run: cd OwnTube.tv/android/ && ./gradlew assembleRelease - name: Upload .apk artifact @@ -129,8 +168,10 @@ jobs: path: "./OwnTube.tv/android/app/build/outputs/apk/release/app-release.apk" build_ios_app: - needs: [code_quality, build_info] + needs: [code_quality, build_info, customizations_setup] runs-on: self-hosted + outputs: + ARTIFACT_PATH: ${{ steps.find_app.outputs.ARTIFACT_PATH }} steps: - name: Checkout uses: actions/checkout@v4 @@ -143,6 +184,11 @@ jobs: - name: Install Dependencies run: cd OwnTube.tv/ && npm install + - name: Create .env File + if: ${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT != '' }} + run: | + echo "${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT }}" > ./OwnTube.tv/.env + - name: Expo Prebuild ios assets run: cd OwnTube.tv/ && npx expo prebuild --clean --platform ios @@ -159,17 +205,34 @@ jobs: } EOF - - name: "Build release .app for simulators by @${{ github.actor }}" - run: cd OwnTube.tv/ios/ && xcodebuild -workspace ./OwnTubetv.xcworkspace -scheme OwnTubetv -configuration Release -sdk iphonesimulator -derivedDataPath ./build-simulator + - name: Build release .app for simulators by @${{ github.actor }} + run: | + cd OwnTube.tv/ios/ && + WORKSPACE_FILE=$(find . -maxdepth 1 -name "*.xcworkspace") + SCHEME=$(xcodebuild -list | sed -n '/Schemes:/,$p' | tail -n +2 | head -n 1 | xargs) + + if [[ -n "$WORKSPACE_FILE" && -n "$SCHEME" ]]; then + echo "Running xcodebuild with workspace $WORKSPACE_FILE and scheme $SCHEME" + xcodebuild -workspace "$WORKSPACE_FILE" -scheme "$SCHEME" -configuration Release -sdk iphonesimulator -derivedDataPath ./build-simulator + else + echo "Error: No .xcworkspace or file found." + exit 1 + fi + + - name: Find .app artifact path + id: find_app + run: | + ARTIFACT_PATH=$(find ./OwnTube.tv/ios/build-simulator/Build/Products/Release-iphonesimulator -maxdepth 1 -name "*.app" | head -n 1) + echo "ARTIFACT_PATH=$ARTIFACT_PATH" >> $GITHUB_OUTPUT - name: Upload .app artifact uses: actions/upload-artifact@v4 with: name: ios-simulator-app.app - path: "./OwnTube.tv/ios/build-simulator/Build/Products/Release-iphonesimulator/OwnTubetv.app" + path: "${{ steps.find_app.outputs.ARTIFACT_PATH }}" deploy_web: - needs: [code_quality, build_info] + needs: [code_quality, build_info, customizations_setup] runs-on: ubuntu-latest environment: name: github-pages @@ -183,6 +246,10 @@ jobs: node-version: 20.x - name: Install Dependencies run: cd OwnTube.tv/ && npm install + - name: Create .env File + if: ${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT != '' }} + run: | + echo "${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT }}" > ./OwnTube.tv/.env - name: Inject Build Info run: | # Overwrite build-info.json in source root dir @@ -195,7 +262,7 @@ jobs: "WEB_URL": "${{ needs.build_info.outputs.WEB_URL }}" } EOF - - name: "Build Web App by @${{ github.actor }}" + - name: Build Web App by @${{ github.actor }} run: cd OwnTube.tv/ && cat build-info.json && npx expo export --platform web - name: Setup Pages uses: actions/configure-pages@v4 diff --git a/OwnTube.tv/.env.example b/OwnTube.tv/.env.example new file mode 100644 index 0000000..a86ab28 --- /dev/null +++ b/OwnTube.tv/.env.example @@ -0,0 +1,8 @@ +EXPO_PUBLIC_APP_NAME=CustomTube +EXPO_PUBLIC_APP_SLUG=CustomTube +EXPO_PUBLIC_FAVICON_URL=https://cdn-icons-png.flaticon.com/512/1170/1170688.png +EXPO_PUBLIC_ICON=https://cdn-icons-png.flaticon.com/512/1170/1170688.png +EXPO_PUBLIC_IOS_BUNDLE_IDENTIFIER=com.customtube.owntube +EXPO_PUBLIC_ANDROID_PACKAGE=com.customtube.owntube +EXPO_PUBLIC_SPLASH_BG_COLOR='#FFFFFF' +EXPO_PUBLIC_SPLASH_IMAGE=https://cdn-icons-png.flaticon.com/512/1170/1170688.png diff --git a/OwnTube.tv/app.config.ts b/OwnTube.tv/app.config.ts new file mode 100644 index 0000000..b58561e --- /dev/null +++ b/OwnTube.tv/app.config.ts @@ -0,0 +1,53 @@ +export default { + slug: process.env.EXPO_PUBLIC_APP_SLUG || "OwnTube.tv", + name: process.env.EXPO_PUBLIC_APP_NAME || "OwnTube.tv", + icon: process.env.EXPO_PUBLIC_ICON || "./assets/icon.png", + scheme: "owntube", + version: process.env.EXPO_PUBLIC_APP_VERSION || "1.0.0", + assetBundlePatterns: ["**/*"], + userInterfaceStyle: process.env.EXPO_PUBLIC_USER_INTERFACE_STYLE || "light", + splash: { + image: process.env.EXPO_PUBLIC_SPLASH_IMAGE || "./assets/splash.png", + resizeMode: "contain", + backgroundColor: process.env.EXPO_PUBLIC_SPLASH_BG_COLOR || "#F95F1E", + }, + ios: { + supportsTablet: true, + bundleIdentifier: process.env.EXPO_PUBLIC_IOS_BUNDLE_IDENTIFIER || "com.owntubetv.owntube", + }, + experiments: { + baseUrl: process.env.EXPO_PUBLIC_BASE_URL || "/web-client", + }, + android: { + adaptiveIcon: { + foregroundImage: + process.env.EXPO_PUBLIC_ANDROID_ADAPTIVE_ICON_FOREGROUND || "./assets/adaptive-icon-foreground.png", + monochromeImage: + process.env.EXPO_PUBLIC_ANDROID_ADAPTIVE_ICON_MONOCHROME || "./assets/adaptive-icon-foreground.png", + backgroundColor: process.env.EXPO_PUBLIC_ANDROID_ADAPTIVE_ICON_BG_COLOR || "#F95F1E", + }, + package: process.env.EXPO_PUBLIC_ANDROID_PACKAGE || "com.owntubetv.owntube", + }, + web: { + output: "static", + bundler: "metro", + favicon: process.env.EXPO_PUBLIC_FAVICON_URL || "./assets/favicon.png", + }, + plugins: [ + "expo-router", + [ + "expo-font", + { + fonts: ["assets/fonts/icomoon.ttf"], + }, + ], + "expo-localization", + [ + "expo-screen-orientation", + { + initialOrientation: "DEFAULT", + }, + ], + "expo-asset", + ], +}; diff --git a/OwnTube.tv/app.json b/OwnTube.tv/app.json deleted file mode 100644 index a09f9eb..0000000 --- a/OwnTube.tv/app.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "expo": { - "name": "OwnTube.tv", - "slug": "OwnTube.tv", - "scheme": "owntube", - "version": "1.0.0", - "icon": "./assets/icon.png", - "userInterfaceStyle": "light", - "splash": { - "image": "./assets/splash.png", - "resizeMode": "contain", - "backgroundColor": "#F95F1E" - }, - "assetBundlePatterns": [ - "**/*" - ], - "experiments": { - "baseUrl": "/web-client" - }, - "ios": { - "supportsTablet": true, - "bundleIdentifier": "com.owntubetv.owntube" - }, - "android": { - "adaptiveIcon": { - "foregroundImage": "./assets/adaptive-icon-foreground.png", - "monochromeImage": "./assets/adaptive-icon-foreground.png", - "backgroundColor": "#F95F1E" - }, - "package": "com.owntubetv.owntube" - }, - "web": { - "output": "static", - "bundler": "metro", - "favicon": "assets/favicon.png" - }, - "plugins": [ - "expo-router", - [ - "expo-font", - { - "fonts": [ - "assets/fonts/icomoon.ttf" - ] - } - ], - "expo-localization", - [ - "expo-screen-orientation", - { - "initialOrientation": "DEFAULT" - } - ], - "expo-asset" - ] - } -} diff --git a/OwnTube.tv/app/(home)/channel-playlist.tsx b/OwnTube.tv/app/(home)/channel-playlist.tsx index 50e1b28..8d7fe83 100644 --- a/OwnTube.tv/app/(home)/channel-playlist.tsx +++ b/OwnTube.tv/app/(home)/channel-playlist.tsx @@ -2,6 +2,7 @@ import { useTranslation } from "react-i18next"; import { Platform } from "react-native"; import Head from "expo-router/head"; import { Playlist } from "../../screens"; +import Constants from "expo-constants"; export default function channelPlaylist() { const { t } = useTranslation(); @@ -13,7 +14,7 @@ export default function channelPlaylist() { web: ( {t("playlist")} - + ), })} diff --git a/OwnTube.tv/app/(home)/history.tsx b/OwnTube.tv/app/(home)/history.tsx index 3deb613..b4d076b 100644 --- a/OwnTube.tv/app/(home)/history.tsx +++ b/OwnTube.tv/app/(home)/history.tsx @@ -2,6 +2,7 @@ import { Platform } from "react-native"; import Head from "expo-router/head"; import { ViewHistory } from "../../components"; import { useTranslation } from "react-i18next"; +import Constants from "expo-constants"; export default function history() { const { t } = useTranslation(); @@ -12,7 +13,7 @@ export default function history() { web: ( {t("viewHistory")} - + ), })} diff --git a/OwnTube.tv/app/(home)/home.tsx b/OwnTube.tv/app/(home)/home.tsx index 491da2d..e5e753b 100644 --- a/OwnTube.tv/app/(home)/home.tsx +++ b/OwnTube.tv/app/(home)/home.tsx @@ -7,10 +7,9 @@ import { RootStackParams } from "../_layout"; import { useInstanceConfig, useRecentInstances } from "../../hooks"; import { Platform } from "react-native"; import Head from "expo-router/head"; -import { useTranslation } from "react-i18next"; +import Constants from "expo-constants"; export default function home() { - const { t } = useTranslation(); const { backend } = useLocalSearchParams(); const { recentInstances, addRecentInstance } = useRecentInstances(); const { currentInstanceConfig } = useInstanceConfig(); @@ -36,9 +35,10 @@ export default function home() { web: ( - {currentInstanceConfig?.customizations?.pageTitle ?? `${t("appName")}${backend ? "@" + backend : ""}`} + {currentInstanceConfig?.customizations?.pageTitle ?? + `${backend ? backend + " @" : ""} ${Constants.expoConfig?.name}`} - + ), })} diff --git a/OwnTube.tv/app/(home)/index.tsx b/OwnTube.tv/app/(home)/index.tsx index 939ffe8..4f8408f 100644 --- a/OwnTube.tv/app/(home)/index.tsx +++ b/OwnTube.tv/app/(home)/index.tsx @@ -6,12 +6,11 @@ import { useCallback, useState } from "react"; import Head from "expo-router/head"; import { LandingScreen } from "../../screens"; import { Platform } from "react-native"; -import { useTranslation } from "react-i18next"; +import Constants from "expo-constants"; export default function index() { const router = useRouter(); const [isGettingStoredBackend, setIsGettingStoredBackend] = useState(true); - const { t } = useTranslation(); const getSourceAndRedirect = async () => { const source = await readFromAsyncStorage(STORAGE.DATASOURCE); @@ -38,8 +37,8 @@ export default function index() { default: null, web: ( - {t("appName")} - + {Constants.expoConfig?.name} + ), })} diff --git a/OwnTube.tv/app/(home)/playlist.tsx b/OwnTube.tv/app/(home)/playlist.tsx index 15886df..f368447 100644 --- a/OwnTube.tv/app/(home)/playlist.tsx +++ b/OwnTube.tv/app/(home)/playlist.tsx @@ -2,6 +2,7 @@ import { useTranslation } from "react-i18next"; import { Platform } from "react-native"; import Head from "expo-router/head"; import { Playlist } from "../../screens"; +import Constants from "expo-constants"; export default function playlists() { const { t } = useTranslation(); @@ -13,7 +14,7 @@ export default function playlists() { web: ( {t("playlist")} - + ), })} diff --git a/OwnTube.tv/app/(home)/playlists.tsx b/OwnTube.tv/app/(home)/playlists.tsx index 22e32aa..f11569d 100644 --- a/OwnTube.tv/app/(home)/playlists.tsx +++ b/OwnTube.tv/app/(home)/playlists.tsx @@ -2,6 +2,7 @@ import { useTranslation } from "react-i18next"; import { Platform } from "react-native"; import Head from "expo-router/head"; import { Playlists } from "../../screens"; +import Constants from "expo-constants"; export default function playlists() { const { t } = useTranslation(); @@ -13,7 +14,10 @@ export default function playlists() { web: ( {t("playlistsPageTitle")} - + ), })} diff --git a/OwnTube.tv/components/VideoControlsOverlay/components/modals/Settings.tsx b/OwnTube.tv/components/VideoControlsOverlay/components/modals/Settings.tsx index 12e4b8a..2f8b5ba 100644 --- a/OwnTube.tv/components/VideoControlsOverlay/components/modals/Settings.tsx +++ b/OwnTube.tv/components/VideoControlsOverlay/components/modals/Settings.tsx @@ -17,6 +17,7 @@ import { STORAGE } from "../../../../types"; import { useQueryClient } from "@tanstack/react-query"; import { useMemo } from "react"; import { PeertubeInstance } from "../../../../api/models"; +import Constants from "expo-constants"; interface SettingsProps { onClose: () => void; @@ -74,7 +75,7 @@ export const Settings = ({ onClose }: SettingsProps) => { - {t("leaveInstanceDescription")} + {t("leaveInstanceDescription", { appName: Constants.expoConfig?.name })} diff --git a/OwnTube.tv/locales/en.json b/OwnTube.tv/locales/en.json index 1a0a645..4fb30b0 100644 --- a/OwnTube.tv/locales/en.json +++ b/OwnTube.tv/locales/en.json @@ -1,6 +1,4 @@ { - "appName": "OwnTube.tv", - "htmlPageTitle": "OwnTube.tv homepage", "continueWatching": "Continue where you left off", "settingsPageTitle": "Settings", "settingsPageDescription": "Settings", @@ -62,7 +60,7 @@ "copy": "Copy", "linkCopied": "Link copied!", "startAt": "Start at", - "welcomeText": "Welcome to OwnTube!", + "welcomeText": "Welcome to {{appName}}!", "welcomeDescriptionText": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut laoreet, nisl dignissim gravida placerat, nunc nibh lacinia tortor faucibus ipsum.", "exploreVideoSites": "Explore video sites", "views": "{{count}} views", @@ -81,7 +79,7 @@ "visitChannel": "Visit channel", "viewAll": "View all", "leaveInstance": "Leave {{instance}}", - "leaveInstanceDescription": "Leave the current site and return to OwnTubes site overview page", + "leaveInstanceDescription": "Leave the current site and return to {{appName}} site overview page", "playlistsPageTitle": "Playlists", "currentBuild": "Current build:", "cancel": "Cancel", diff --git a/OwnTube.tv/locales/ru.json b/OwnTube.tv/locales/ru.json index 66c63fc..3bbef35 100644 --- a/OwnTube.tv/locales/ru.json +++ b/OwnTube.tv/locales/ru.json @@ -1,6 +1,4 @@ { - "appName": "OwnTube.tv", - "htmlPageTitle": "Главная страница OwnTube.tv", "continueWatching": "Продолжить просмотр", "settingsPageTitle": "Настройки", "settingsPageDescription": "Настройки", @@ -62,7 +60,7 @@ "copy": "Копировать", "linkCopied": "Скопировано!", "startAt": "Начать с", - "welcomeText": "Добро пожаловать на OwnTube!", + "welcomeText": "Добро пожаловать на {{appName}}!", "welcomeDescriptionText": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut laoreet, nisl dignissim gravida placerat, nunc nibh lacinia tortor faucibus ipsum.", "exploreVideoSites": "Просмотреть видео-сайты", "views": "{{count}} просмотров", @@ -81,7 +79,7 @@ "visitChannel": "Посетить канал", "viewAll": "Просмотреть все", "leaveInstance": "Покинуть {{instance}}", - "leaveInstanceDescription": "Покинуть текущий сайт и вернуться к странице обзора сайтов OwnTube", + "leaveInstanceDescription": "Покинуть текущий сайт и вернуться к странице обзора сайтов {{appName}}", "playlist": "Плейлист", "viewFullPlaylist": "Просмотреть плейлист полностью", "playlistsPageTitle": "Плейлисты", diff --git a/OwnTube.tv/locales/uk.json b/OwnTube.tv/locales/uk.json index cad284c..90d31f5 100644 --- a/OwnTube.tv/locales/uk.json +++ b/OwnTube.tv/locales/uk.json @@ -1,6 +1,4 @@ { - "appName": "OwnTube.tv", - "htmlPageTitle": "Головна сторінка OwnTube.tv", "continueWatching": "Продовжити перегляд", "settingsPageTitle": "Налаштування", "settingsPageDescription": "Налаштування", @@ -62,7 +60,7 @@ "copy": "Копіювати", "linkCopied": "Скопійовано!", "startAt": "Почати з", - "welcomeText": "Ласкаво просимо до OwnTube!", + "welcomeText": "Ласкаво просимо на {{appName}}!", "welcomeDescriptionText": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut laoreet, nisl dignissim gravida placerat, nunc nibh lacinia tortor faucibus ipsum.", "exploreVideoSites": "Переглянути відео-сайти", "views": "{{count}} переглядів", @@ -81,7 +79,7 @@ "visitChannel": "Відвідати канал", "viewAll": "Переглянути все", "leaveInstance": "Покинути {{instance}}", - "leaveInstanceDescription": "Покинути поточний сайт і повернутись до сторінки огляду сайтів OwnTube", + "leaveInstanceDescription": "Покинути поточний сайт і повернутись до сторінки огляду сайтів {{appName}}", "playlist": "Плейліст", "viewFullPlaylist": "Переглянути плейліст повністю", "playlistsPageTitle": "Плейлісти", diff --git a/OwnTube.tv/screens/LandingScreen/LandingScreen.tsx b/OwnTube.tv/screens/LandingScreen/LandingScreen.tsx index b4c087e..fbbb0f7 100644 --- a/OwnTube.tv/screens/LandingScreen/LandingScreen.tsx +++ b/OwnTube.tv/screens/LandingScreen/LandingScreen.tsx @@ -20,6 +20,7 @@ import ComboBoxInput from "../../components/ComboBoxInput"; import Toast from "react-native-toast-message"; import { OwnTubeError } from "../../api/models"; import { ROUTES } from "../../types"; +import Constants from "expo-constants"; export const LandingScreen = () => { const { colors } = useTheme(); @@ -91,7 +92,7 @@ export const LandingScreen = () => { fontSize={isDesktop ? "sizeXXL" : "sizeXL"} color={colors.theme900} > - {t("welcomeText")} + {t("welcomeText", { appName: Constants.expoConfig?.name })} Date: Mon, 4 Nov 2024 17:50:05 +0200 Subject: [PATCH 3/3] customization for ios runner --- .github/workflows/build_android_apk.yml | 62 +++++++ .github/workflows/build_ios_app.yml | 69 ++++++++ .github/workflows/deploy-static-main.yml | 203 +++++------------------ .github/workflows/deploy_web.yml | 55 ++++++ 4 files changed, 226 insertions(+), 163 deletions(-) create mode 100644 .github/workflows/build_android_apk.yml create mode 100644 .github/workflows/build_ios_app.yml create mode 100644 .github/workflows/deploy_web.yml diff --git a/.github/workflows/build_android_apk.yml b/.github/workflows/build_android_apk.yml new file mode 100644 index 0000000..c96ef57 --- /dev/null +++ b/.github/workflows/build_android_apk.yml @@ -0,0 +1,62 @@ +name: Build Android .APK + +on: + workflow_call: + inputs: + customizations_env_content: + required: false + type: string + build_info: + required: true + type: string + +jobs: + build_android_apk: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node 20 + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Install Dependencies + run: cd OwnTube.tv/ && npm install + + - name: Create .env File + if: ${{ inputs.customizations_env_content != '' }} + run: | + echo "${{ inputs.customizations_env_content }}" > ./OwnTube.tv/.env + + - name: Expo Prebuild Android Assets + run: cd OwnTube.tv/ && npx expo prebuild --clean --platform android + + - name: Set Up JDK + uses: actions/setup-java@v4 + with: + distribution: "zulu" + java-version: "17" + cache: "gradle" + + - name: Validate Gradle Wrapper + uses: gradle/actions/wrapper-validation@v3 + + - name: Change Wrapper Permissions + run: cd OwnTube.tv/android/ && chmod +x ./gradlew + + - name: Inject Build Info + run: | + cat > ./OwnTube.tv/build-info.json << 'EOF' + ${{ inputs.build_info }} + EOF + + - name: Build Release APK by @${{ github.actor }} + run: cd OwnTube.tv/android/ && ./gradlew assembleRelease + + - name: Upload APK Artifact + uses: actions/upload-artifact@v4 + with: + name: release apk + path: "./OwnTube.tv/android/app/build/outputs/apk/release/app-release.apk" diff --git a/.github/workflows/build_ios_app.yml b/.github/workflows/build_ios_app.yml new file mode 100644 index 0000000..0e603db --- /dev/null +++ b/.github/workflows/build_ios_app.yml @@ -0,0 +1,69 @@ +name: Build iOS .App + +on: + workflow_call: + inputs: + runner-label: + type: string + default: "macos-latest" + customizations_env_content: + required: false + type: string + build_info: + required: true + type: string + +jobs: + build_ios_app: + runs-on: ${{ inputs.runner-label }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node 20 + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Install Dependencies + run: cd OwnTube.tv/ && npm install + + - name: Create .env File + if: ${{ inputs.customizations_env_content != '' }} + run: | + echo "${{ inputs.customizations_env_content }}" > ./OwnTube.tv/.env + + - name: Expo Prebuild iOS assets + run: cd OwnTube.tv/ && npx expo prebuild --clean --platform ios + + - name: Inject Build Info + run: | + cat > ./OwnTube.tv/build-info.json << 'EOF' + ${{ inputs.build_info }} + EOF + + - name: Build release .app for simulators by @${{ github.actor }} + run: | + cd OwnTube.tv/ios/ && + WORKSPACE_FILE=$(find . -maxdepth 1 -name "*.xcworkspace") + SCHEME=$(xcodebuild -list | sed -n '/Schemes:/,$p' | tail -n +2 | head -n 1 | xargs) + + if [[ -n "$WORKSPACE_FILE" && -n "$SCHEME" ]]; then + echo "Running xcodebuild with workspace $WORKSPACE_FILE and scheme $SCHEME" + xcodebuild -workspace "$WORKSPACE_FILE" -scheme "$SCHEME" -configuration Release -sdk iphonesimulator -derivedDataPath ./build-simulator + else + echo "Error: No .xcworkspace or scheme file found." + exit 1 + fi + + - name: Find .app artifact path + id: find_app + run: | + IOS_APP_ARTIFACT_PATH=$(find ./OwnTube.tv/ios/build-simulator/Build/Products/Release-iphonesimulator -maxdepth 1 -name "*.app" | head -n 1) + echo "IOS_APP_ARTIFACT_PATH=$IOS_APP_ARTIFACT_PATH" >> $GITHUB_OUTPUT + + - name: Upload .app artifact + uses: actions/upload-artifact@v4 + with: + name: ios-simulator-app.app + path: "${{ steps.find_app.outputs.IOS_APP_ARTIFACT_PATH }}" diff --git a/.github/workflows/deploy-static-main.yml b/.github/workflows/deploy-static-main.yml index 7ce9745..f5be496 100644 --- a/.github/workflows/deploy-static-main.yml +++ b/.github/workflows/deploy-static-main.yml @@ -21,14 +21,22 @@ concurrency: cancel-in-progress: false jobs: + choose_macos_runner: + runs-on: ubuntu-latest + environment: owntube + outputs: + runner-label: ${{ steps.set-macos-runner.outputs.runner-label }} + + steps: + - name: Set macos runner + id: set-macos-runner + run: | + echo "runner-label=${{ vars.PREFERRED_MACOS_RUNNER || 'macos-latest' }}" >> $GITHUB_OUTPUT + build_info: runs-on: ubuntu-latest outputs: - GITHUB_ACTOR: ${{ steps.create.outputs.GITHUB_ACTOR }} - GITHUB_SHA_SHORT: ${{ steps.create.outputs.GITHUB_SHA_SHORT }} - COMMIT_URL: ${{ steps.create.outputs.COMMIT_URL }} - BUILD_TIMESTAMP: ${{ steps.create.outputs.BUILD_TIMESTAMP }} - WEB_URL: ${{ steps.create.outputs.WEB_URL }} + BUILD_INFO: ${{ steps.write.outputs.BUILD_INFO }} steps: - id: create name: "@${{ github.actor }} initiated GitHub Pages deployment, prepare build info" @@ -56,6 +64,19 @@ jobs: WEB_URL="https://${{ github.repository_owner }}.github.io/$REPO_NAME" echo "WEB_URL=$WEB_URL" && echo "WEB_URL=$WEB_URL" >> "$GITHUB_OUTPUT" + - id: write + run: | + echo "BUILD_INFO<> $GITHUB_OUTPUT + echo "{ + \"GITHUB_ACTOR\": \"${{ steps.create.outputs.GITHUB_ACTOR }}\", + \"GITHUB_SHA_SHORT\": \"${{ steps.create.outputs.GITHUB_SHA_SHORT }}\", + \"COMMIT_URL\": \"${{ steps.create.outputs.COMMIT_URL }}\", + \"BUILD_TIMESTAMP\": \"${{ steps.create.outputs.BUILD_TIMESTAMP }}\", + \"WEB_URL\": \"${{ steps.create.outputs.WEB_URL }}\" + } + " >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + customizations_setup: runs-on: ubuntu-latest environment: owntube @@ -111,166 +132,22 @@ jobs: build_android_apk: needs: [code_quality, build_info, customizations_setup] - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Node 20 - uses: actions/setup-node@v4 - with: - node-version: 20.x - - - name: Install Dependencies - run: cd OwnTube.tv/ && npm install - - - name: Create .env File - if: ${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT != '' }} - run: | - echo "${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT }}" > ./OwnTube.tv/.env - - - name: Expo Prebuild android assets - run: cd OwnTube.tv/ && npx expo prebuild --clean --platform android - - - name: Set Up JDK - uses: actions/setup-java@v4 - with: - distribution: "zulu" - java-version: "17" - cache: "gradle" - - - name: Validate Gradle wrapper - uses: gradle/actions/wrapper-validation@v3 - - - name: Change wrapper permissions - run: cd OwnTube.tv/android/ && chmod +x ./gradlew - - - name: Inject Build Info - run: | - # Overwrite build-info.json in source root dir - cat < ./OwnTube.tv/build-info.json - { - "GITHUB_ACTOR": "${{ needs.build_info.outputs.GITHUB_ACTOR }}", - "GITHUB_SHA_SHORT": "${{ needs.build_info.outputs.GITHUB_SHA_SHORT }}", - "COMMIT_URL": "${{ needs.build_info.outputs.COMMIT_URL }}", - "BUILD_TIMESTAMP": "${{ needs.build_info.outputs.BUILD_TIMESTAMP }}", - "WEB_URL": "${{ needs.build_info.outputs.WEB_URL }}" - } - EOF - - - name: Build release .apk by @${{ github.actor }} - run: cd OwnTube.tv/android/ && ./gradlew assembleRelease - - - name: Upload .apk artifact - uses: actions/upload-artifact@v4 - with: - name: release apk - path: "./OwnTube.tv/android/app/build/outputs/apk/release/app-release.apk" + uses: ./.github/workflows/build_android_apk.yml + with: + customizations_env_content: ${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT }} + build_info: ${{ needs.build_info.outputs.BUILD_INFO }} build_ios_app: - needs: [code_quality, build_info, customizations_setup] - runs-on: self-hosted - outputs: - ARTIFACT_PATH: ${{ steps.find_app.outputs.ARTIFACT_PATH }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Node 20 - uses: actions/setup-node@v4 - with: - node-version: 20.x - - - name: Install Dependencies - run: cd OwnTube.tv/ && npm install - - - name: Create .env File - if: ${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT != '' }} - run: | - echo "${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT }}" > ./OwnTube.tv/.env - - - name: Expo Prebuild ios assets - run: cd OwnTube.tv/ && npx expo prebuild --clean --platform ios - - - name: Inject Build Info - run: | - # Overwrite build-info.json in source root dir - cat < ./OwnTube.tv/build-info.json - { - "GITHUB_ACTOR": "${{ needs.build_info.outputs.GITHUB_ACTOR }}", - "GITHUB_SHA_SHORT": "${{ needs.build_info.outputs.GITHUB_SHA_SHORT }}", - "COMMIT_URL": "${{ needs.build_info.outputs.COMMIT_URL }}", - "BUILD_TIMESTAMP": "${{ needs.build_info.outputs.BUILD_TIMESTAMP }}", - "WEB_URL": "${{ needs.build_info.outputs.WEB_URL }}" - } - EOF - - - name: Build release .app for simulators by @${{ github.actor }} - run: | - cd OwnTube.tv/ios/ && - WORKSPACE_FILE=$(find . -maxdepth 1 -name "*.xcworkspace") - SCHEME=$(xcodebuild -list | sed -n '/Schemes:/,$p' | tail -n +2 | head -n 1 | xargs) - - if [[ -n "$WORKSPACE_FILE" && -n "$SCHEME" ]]; then - echo "Running xcodebuild with workspace $WORKSPACE_FILE and scheme $SCHEME" - xcodebuild -workspace "$WORKSPACE_FILE" -scheme "$SCHEME" -configuration Release -sdk iphonesimulator -derivedDataPath ./build-simulator - else - echo "Error: No .xcworkspace or file found." - exit 1 - fi - - - name: Find .app artifact path - id: find_app - run: | - ARTIFACT_PATH=$(find ./OwnTube.tv/ios/build-simulator/Build/Products/Release-iphonesimulator -maxdepth 1 -name "*.app" | head -n 1) - echo "ARTIFACT_PATH=$ARTIFACT_PATH" >> $GITHUB_OUTPUT - - - name: Upload .app artifact - uses: actions/upload-artifact@v4 - with: - name: ios-simulator-app.app - path: "${{ steps.find_app.outputs.ARTIFACT_PATH }}" + needs: [build_info, customizations_setup, code_quality, choose_macos_runner] + uses: ./.github/workflows/build_ios_app.yml + with: + runner-label: ${{ needs.choose_macos_runner.outputs.runner-label }} + customizations_env_content: ${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT }} + build_info: ${{ needs.build_info.outputs.BUILD_INFO }} deploy_web: needs: [code_quality, build_info, customizations_setup] - runs-on: ubuntu-latest - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Node 20 - uses: actions/setup-node@v4 - with: - node-version: 20.x - - name: Install Dependencies - run: cd OwnTube.tv/ && npm install - - name: Create .env File - if: ${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT != '' }} - run: | - echo "${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT }}" > ./OwnTube.tv/.env - - name: Inject Build Info - run: | - # Overwrite build-info.json in source root dir - cat < ./OwnTube.tv/build-info.json - { - "GITHUB_ACTOR": "${{ needs.build_info.outputs.GITHUB_ACTOR }}", - "GITHUB_SHA_SHORT": "${{ needs.build_info.outputs.GITHUB_SHA_SHORT }}", - "COMMIT_URL": "${{ needs.build_info.outputs.COMMIT_URL }}", - "BUILD_TIMESTAMP": "${{ needs.build_info.outputs.BUILD_TIMESTAMP }}", - "WEB_URL": "${{ needs.build_info.outputs.WEB_URL }}" - } - EOF - - name: Build Web App by @${{ github.actor }} - run: cd OwnTube.tv/ && cat build-info.json && npx expo export --platform web - - name: Setup Pages - uses: actions/configure-pages@v4 - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - # Upload Expo build output - path: "./OwnTube.tv/dist/" - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + uses: ./.github/workflows/deploy_web.yml + with: + customizations_env_content: ${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT }} + build_info: ${{ needs.build_info.outputs.BUILD_INFO }} diff --git a/.github/workflows/deploy_web.yml b/.github/workflows/deploy_web.yml new file mode 100644 index 0000000..f57fe09 --- /dev/null +++ b/.github/workflows/deploy_web.yml @@ -0,0 +1,55 @@ +name: Deploy Web App + +on: + workflow_call: + inputs: + customizations_env_content: + required: false + type: string + build_info: + required: true + type: string + +jobs: + deploy_web: + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node 20 + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Install Dependencies + run: cd OwnTube.tv/ && npm install + + - name: Create .env File + if: ${{ inputs.customizations_env_content != '' }} + run: | + echo "${{ inputs.customizations_env_content }}" > ./OwnTube.tv/.env + + - name: Inject Build Info + run: | + cat > ./OwnTube.tv/build-info.json << 'EOF' + ${{ inputs.build_info }} + EOF + + - name: Build Web App by @${{ github.actor }} + run: cd OwnTube.tv/ && cat build-info.json && npx expo export --platform web + + - name: Setup Pages + uses: actions/configure-pages@v4 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: "./OwnTube.tv/dist/" + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4