Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup ios builds, setup basic customizations #205

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/build_android_apk.yml
Original file line number Diff line number Diff line change
@@ -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"
69 changes: 69 additions & 0 deletions .github/workflows/build_ios_app.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
174 changes: 79 additions & 95 deletions .github/workflows/deploy-static-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -56,8 +64,55 @@ 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<<EOF" >> $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
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<<EOF' >> $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
Expand All @@ -76,94 +131,23 @@ jobs:
run: cd OwnTube.tv/ && npm run test

build_android_apk:
needs: [code_quality, build_info]
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: 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 <<EOF > ./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"
needs: [code_quality, build_info, customizations_setup]
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: [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]
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: Inject Build Info
run: |
# Overwrite build-info.json in source root dir
cat <<EOF > ./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
needs: [code_quality, build_info, customizations_setup]
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 }}
55 changes: 55 additions & 0 deletions .github/workflows/deploy_web.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions OwnTube.tv/.env.example
Original file line number Diff line number Diff line change
@@ -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
Loading