diff --git a/.github/workflows/build-game-client.yml b/.github/workflows/build-game-client.yml new file mode 100644 index 0000000..dc34095 --- /dev/null +++ b/.github/workflows/build-game-client.yml @@ -0,0 +1,65 @@ +name: "Build CosmicKube game client" +on: + push: + branches: + - main + pull_request: + branches: + - main + +env: + GODOT_VERSION: 4.2.1 + EXPORT_NAME: CosmicKube + PROJECT_PATH: game-source + +jobs: + export-web: + name: "Export for Web" + runs-on: ubuntu-20.04 + container: + image: barichello/godot-ci:4.2.1 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + lfs: true + - name: Setup + run: | + mkdir -v -p ~/.local/share/godot/export_templates/ + mv /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable + - name: Web Build + run: | + mkdir -v -p build/web + cd $PROJECT_PATH + godot --headless --verbose --export-release "Web" ../build/web/index.html 2>&1 | tee output.txt + echo Reading build logs... + if search="$(cat output.txt | grep 'ERROR: Project export')" + then + echo "Build failed!" + exit 1 + else + echo "Build succeeded!" + exit 0 + fi ; + - name: Create staticwebapp.config.json + run: | + cd build/web + echo "${{ vars.STATIC_WEB_APP_CONFIG }}" > staticwebapp.config.json + ls + - name: Upload Artifact + uses: actions/upload-artifact@v1 + with: + name: web + path: build/web + + - name: Publish to Azure Static Web Apps + id: publishto + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for GitHub integrations (i.e. PR comments) + action: "upload" + ###### Repository/Build Configurations ###### + app_location: "build/web" + skip_app_build: true + ###### End of Repository/Build Configurations ###### \ No newline at end of file diff --git a/.github/workflows/test-jenkinsfile.yml.noworky b/.github/workflows/test-jenkinsfile.yml.noworky new file mode 100644 index 0000000..31712e7 --- /dev/null +++ b/.github/workflows/test-jenkinsfile.yml.noworky @@ -0,0 +1,18 @@ +name: "Test Jenkinsfile" +on: push + +env: + GODOT_VERSION: 4.2.1 + EXPORT_NAME: CosmicKube + PROJECT_PATH: game-source + +jobs: + test-jenkins: + name: "Test Jenkinsfile" + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@master + - name: jenkinsfile-runner-prepackaged + uses: jenkinsci/jenkinsfile-runner-github-actions/jenkinsfile-runner-prepackaged@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 51f57d7..5076dab 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,24 +1,38 @@ pipeline { - agent any + agent { + docker { + image 'barichello/godot-ci:4.2.1' + + } } + environment { + GODOT_VERSION = '4.2.1' + EXPORT_NAME = 'CosmicKube' + PROJECT_PATH = 'game-source' + } stages { - stage('Hello world') { + stage('Setup') { steps { - sh 'echo pee pee' + sh '''mkdir -v -p ~/.local/share/godot/export_templates/ + mv /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable + ''' + } + } + stage('Web Build') { + steps { + sh '''mkdir -v -p build/web + cd $PROJECT_PATH + godot --headless --verbose --export-release "Web" ../build/web/index.html 2>&1 | tee output.txt + echo Reading build logs... + if search="$(cat output.txt | grep 'ERROR: Project export')" + then + echo "Build failed!" + exit 1 + else + echo "Build succeeded!" + exit 0 + fi ;''' } } - - // stage('Push image') { - // steps { - // sh 'docker push localhost:5000/ttt' - // } - // } - // - // stage('Package') { - // steps { - // sh 'helm install ttt ttt | true' - // sh 'helm upgrade ttt ttt' - // } - // } } -} +} \ No newline at end of file diff --git a/client.Dockerfile b/client.Dockerfile new file mode 100644 index 0000000..61f558e --- /dev/null +++ b/client.Dockerfile @@ -0,0 +1,58 @@ +FROM ubuntu:jammy +LABEL author="https://github.com/aBARICHELLO/godot-ci/graphs/contributors" + +USER root +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + git \ + git-lfs \ + unzip \ + wget \ + zip \ + adb \ + openjdk-17-jdk-headless \ + rsync \ + && rm -rf /var/lib/apt/lists/* + +ARG GODOT_VERSION="4.2.1" +ARG RELEASE_NAME="stable" +ARG SUBDIR="" +ARG GODOT_TEST_ARGS="" +ARG GODOT_PLATFORM="linux.x86_64" + +RUN wget https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}${SUBDIR}/Godot_v${GODOT_VERSION}-${RELEASE_NAME}_${GODOT_PLATFORM}.zip \ + && wget https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}${SUBDIR}/Godot_v${GODOT_VERSION}-${RELEASE_NAME}_export_templates.tpz \ + && mkdir ~/.cache \ + && mkdir -p ~/.config/godot \ + && mkdir -p ~/.local/share/godot/export_templates/${GODOT_VERSION}.${RELEASE_NAME} \ + && unzip Godot_v${GODOT_VERSION}-${RELEASE_NAME}_${GODOT_PLATFORM}.zip \ + && mv Godot_v${GODOT_VERSION}-${RELEASE_NAME}_${GODOT_PLATFORM} /usr/local/bin/godot \ + && unzip Godot_v${GODOT_VERSION}-${RELEASE_NAME}_export_templates.tpz \ + && mv templates/* ~/.local/share/godot/export_templates/${GODOT_VERSION}.${RELEASE_NAME} \ + && rm -f Godot_v${GODOT_VERSION}-${RELEASE_NAME}_export_templates.tpz Godot_v${GODOT_VERSION}-${RELEASE_NAME}_${GODOT_PLATFORM}.zip + +# Download and setup android-sdk +ENV ANDROID_HOME="/usr/lib/android-sdk" +RUN wget https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip \ + && unzip commandlinetools-linux-*_latest.zip -d cmdline-tools \ + && mv cmdline-tools $ANDROID_HOME/ \ + && rm -f commandlinetools-linux-*_latest.zip + +ENV PATH="${ANDROID_HOME}/cmdline-tools/cmdline-tools/bin:${PATH}" + +RUN yes | sdkmanager --licenses \ + && sdkmanager "platform-tools" "build-tools;33.0.2" "platforms;android-33" "cmdline-tools;latest" "cmake;3.22.1" "ndk;25.2.9519653" + +# Adding android keystore and settings +RUN keytool -keyalg RSA -genkeypair -alias androiddebugkey -keypass android -keystore debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999 \ + && mv debug.keystore /root/debug.keystore + +RUN godot -v -e --quit --headless ${GODOT_TEST_ARGS} +RUN echo 'export/android/android_sdk_path = "/usr/lib/android-sdk"' >> ~/.config/godot/editor_settings-4.tres +RUN echo 'export/android/debug_keystore = "/root/debug.keystore"' >> ~/.config/godot/editor_settings-4.tres +RUN echo 'export/android/debug_keystore_user = "androiddebugkey"' >> ~/.config/godot/editor_settings-4.tres +RUN echo 'export/android/debug_keystore_pass = "android"' >> ~/.config/godot/editor_settings-4.tres +RUN echo 'export/android/force_system_user = false' >> ~/.config/godot/editor_settings-4.tres +RUN echo 'export/android/timestamping_authority_url = ""' >> ~/.config/godot/editor_settings-4.tres +RUN echo 'export/android/shutdown_adb_on_exit = true' >> ~/.config/godot/editor_settings-4.tres \ No newline at end of file diff --git a/game-source/export_presets.cfg b/game-source/export_presets.cfg new file mode 100644 index 0000000..0078c93 --- /dev/null +++ b/game-source/export_presets.cfg @@ -0,0 +1,37 @@ +[preset.0] + +name="Web" +platform="Web" +runnable=true +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false + +[preset.0.options] + +custom_template/debug="" +custom_template/release="" +variant/extensions_support=false +vram_texture_compression/for_desktop=true +vram_texture_compression/for_mobile=true +html/export_icon=true +html/custom_html_shell="" +html/head_include="" +html/canvas_resize_policy=2 +html/focus_canvas_on_start=true +html/experimental_virtual_keyboard=false +progressive_web_app/enabled=false +progressive_web_app/offline_page="" +progressive_web_app/display=1 +progressive_web_app/orientation=0 +progressive_web_app/icon_144x144="" +progressive_web_app/icon_180x180="" +progressive_web_app/icon_512x512="" +progressive_web_app/background_color=Color(0, 0, 0, 1) diff --git a/game-source/project.godot b/game-source/project.godot index f937ed2..d64f5ba 100644 --- a/game-source/project.godot +++ b/game-source/project.godot @@ -19,3 +19,4 @@ config/icon="res://icon.svg" renderer/rendering_method="gl_compatibility" renderer/rendering_method.mobile="gl_compatibility" +textures/vram_compression/import_etc2_astc=true diff --git a/plugins.txt b/plugins.txt new file mode 100644 index 0000000..e69de29