diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..121bb460 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +.git/ +.dart_tool/ +android/ +build/ +docs/ +ios/ +linux/ +localization/ +macos/ +node_modules/ +shaders/ +snap/ +windows/ diff --git a/.gitbook.yaml b/.gitbook.yaml deleted file mode 100644 index 6c5133ed..00000000 --- a/.gitbook.yaml +++ /dev/null @@ -1,5 +0,0 @@ -root: ./docs - -​structure: - readme: README.md - summary: SUMMARY.md​ diff --git a/.github/actions/prepare_for_deployment/action.yml b/.github/actions/prepare_for_deployment/action.yml index 93e31ab2..a9a00494 100644 --- a/.github/actions/prepare_for_deployment/action.yml +++ b/.github/actions/prepare_for_deployment/action.yml @@ -11,6 +11,14 @@ inputs: description: 'App Store Connect API Key' required: false default: '' + ghcr-actor: + description: 'GitHub Container Registry Actor' + required: false + default: '' + ghcr-token: + description: 'GitHub Container Registry Token' + required: false + default: '' google-play-key: description: 'Google Play Store API Key' required: false @@ -52,6 +60,18 @@ runs: with: xcode-version: latest-stable + - name: Set up Docker Buildx + if: ${{ inputs.channel == 'docker' }} + uses: docker/setup-buildx-action@v1 + + - name: Setup GitHub Package Registry + if: ${{ inputs.channel == 'docker' }} + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ inputs.ghcr-actor }} + password: ${{ inputs.ghcr-token }} + - name: Setup Secret Keys shell: bash run: | diff --git a/.github/workflows/build_web.yml b/.github/workflows/build_web.yml index e7b4f477..bbc6a1af 100644 --- a/.github/workflows/build_web.yml +++ b/.github/workflows/build_web.yml @@ -6,14 +6,17 @@ on: build-number: required: true type: string + flavor: + required: true + type: string secrets: FIREBASE_TOKEN: required: true jobs: - build-canvaskit: - name: CanvasKit + build-hosted: + name: Hosted runs-on: ubuntu-latest steps: - name: Setup Environment @@ -28,5 +31,55 @@ jobs: - name: Upload Artifact uses: actions/upload-artifact@v3 with: - name: web-canvaskit + name: web-hosted path: ${{ github.workspace }}/build/web + + build-archive: + name: Archive + runs-on: ubuntu-latest + steps: + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master + with: + platform: web + + - name: Build LunaSea + run: npm run build:web + + - name: Create Archive + uses: thedoctor0/zip-release@0.6.2 + with: + type: zip + filename: output/lunasea-web-canvaskit.zip + directory: ${{ github.workspace }}/build/web + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: web-archive + path: ${{ github.workspace }}/output + + build-docker: + name: Docker + runs-on: ubuntu-latest + steps: + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master + with: + platform: web + + - name: Build LunaSea + uses: docker/build-push-action@v2 + with: + context: . + outputs: type=docker,dest=${{ github.workspace}}/output/lunasea-web-docker.tar + tags: | + ghcr.io/jagandeepbrar/lunasea:latest + ghcr.io/jagandeepbrar/lunasea:${{ inputs.flavor }} + ghcr.io/jagandeepbrar/lunasea:${{ github.sha }} + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: web-docker + path: ${{ github.workspace }}/output diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1d94e8e1..2c2bbdb7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -183,6 +183,32 @@ jobs: APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} run: bundle exec fastlane deploy_appstore groups:${{ inputs.flavor }} pkg:${{ github.workspace }}/output/lunasea-macos-amd64.pkg + web-docker: + name: Docker + if: ${{ inputs.enable-web == 'true' }} + runs-on: ubuntu-latest + steps: + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_deployment@master + with: + channel: docker + ghcr-actor: ${{ github.actor }} + ghcr-token: ${{ github.token }} + + - name: Download Docker Image + uses: actions/download-artifact@v3 + with: + name: web-docker + path: ${{ github.workspace }}/output + + - name: Load Docker Image + run: | + docker load --input ${{ github.workspace}}/output/lunasea-web-docker.tar + docker image ls -a + + - name: Deploy to GitHub Container Registry + run: docker image push --all-tags ghcr.io/jagandeepbrar/lunasea + web-netlify: name: Netlify if: ${{ inputs.enable-web == 'true' }} @@ -196,7 +222,7 @@ jobs: - name: Download Web Package uses: actions/download-artifact@v3 with: - name: web-canvaskit + name: web-hosted path: ${{ github.workspace }}/output - name: Determine Release Channel @@ -278,6 +304,13 @@ jobs: name: windows-app-package path: ${{ github.workspace }}/output + - name: Download Web Archive + if: ${{ inputs.enable-web == 'true' }} + uses: actions/download-artifact@v3 + with: + name: web-archive + path: ${{ github.workspace }}/output + - name: Download Windows MSIX Installer if: ${{ inputs.enable-windows == 'true' }} uses: actions/download-artifact@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 67d18cd7..7234a4fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -99,6 +99,7 @@ jobs: uses: JagandeepBrar/LunaSea/.github/workflows/build_web.yml@master with: build-number: ${{ needs.prepare.outputs.build-number }} + flavor: ${{ github.event.inputs.flavor || 'edge' }} secrets: FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..3a112fbd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +# Build +FROM debian:latest as build + +ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:$PATH" +RUN apt-get update +RUN apt-get install -y curl git wget unzip +RUN apt-get clean + +RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter +RUN flutter channel stable +RUN flutter upgrade + +RUN mkdir /lunasea/ +COPY . /lunasea/ +WORKDIR /lunasea/ +RUN flutter build web + +# Runtime +FROM nginx:alpine +LABEL org.opencontainers.image.source="https://github.com/JagandeepBrar/LunaSea" +COPY --from=build /lunasea/build/web /usr/share/nginx/html diff --git a/lib/core/extensions/string.dart b/lib/core/extensions/string.dart index defbdfaa..6c41cf32 100644 --- a/lib/core/extensions/string.dart +++ b/lib/core/extensions/string.dart @@ -29,6 +29,17 @@ extension StringExtension on String { return split.join(_wordDelimiter); } + + Future copyToClipboard({ + bool showSnackBar = true, + }) async { + await Clipboard.setData(ClipboardData(text: this)); + if (showSnackBar) + showLunaSuccessSnackBar( + title: 'Copied', + message: 'Copied content to the clipboard', + ); + } } extension StringLinksExtension on String { @@ -90,15 +101,4 @@ extension StringLinksExtension on String { /// Attach this string as a series ID to TVMaze and attempt to launch it as a URL. Future lunaOpenTVMaze() async => await _openLink('https://www.tvmaze.com/shows/$this'); - - Future copyToClipboard({ - bool showSnackBar = true, - }) async { - await Clipboard.setData(ClipboardData(text: this)); - if (showSnackBar) - showLunaSuccessSnackBar( - title: 'Copied', - message: 'Copied content to the clipboard', - ); - } }