diff --git a/.env.default b/.env.default index a17bbc5..f026495 100644 --- a/.env.default +++ b/.env.default @@ -1,5 +1,5 @@ PROJECT=puzzlez -VERSION=$(grep -m 1 'version' ./package.json | grep -oP '"version"\s*:\s*"\K\d+\.\d+.\d+') +#VERSION=$(grep -m 1 'version' ./package.json | grep -oP '"version"\s*:\s*"\K\d+\.\d+.\d+') SDK_PATH=$HOME/sdk PUBLISH_PATH=$HOME/public/$PROJECT BUILD_PATH=./build @@ -8,7 +8,7 @@ KEY_STORE= KEY_PASS= # publish -REPO=https://git.shmyga.ru/api/packages/InfernalGames +PUBLISH_REPO=https://git.shmyga.ru/api/packages/InfernalGames PUBLISH_USER= PUBLISH_PASSWORD= diff --git a/.gitignore b/.gitignore index c502343..2c09620 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -/build/ +build/ target/ src-gen/ out/ @@ -10,8 +10,8 @@ out/ .idea/ .ideaDataSources/ config.json -/node_modules -/log -/ansible/*.retry +node_modules +log +ansible/*.retry .npmrc -.env \ No newline at end of file +.env diff --git a/.pm.toml b/.pm.toml new file mode 100644 index 0000000..2b902f9 --- /dev/null +++ b/.pm.toml @@ -0,0 +1,23 @@ +modules = ["."] + +[presets.docker] +variables.docker_target = "web" +variables.docker_name = "{{ project_name }}-web" + +[presets.docker.tasks.build.compose] +priority = 1 +variables.sdk_path = "{{ 'SDK_PATH' | env('$HOME/sdk') }}" +variables.publish_path = "{{ 'PUBLISH_PATH' | env('$HOME/public/' + project_name) }}" +variables.build_path = "{{ 'BUILD_PATH' | env('./build') }}" +variables.target_path = "{{ 'TARGET_PATH' | env('./target') }}" +commands = [ + "mkdir -p \"{{ sdk_path }}\" \"{{ publish_path }}\" \"{{ build_path }}\" \"{{ target_path }}\" \"src-gen\"", + "docker compose run --rm --user $(id -u):$(id -g) --build --remove-orphans builder", +] + +[presets.gitea] +variables.publish_artefacts.debian = "target/app/debian/{{ project_name }}_{{ project_version }}_all.deb" +variables.publish_artefacts.android = "target/app/android/{{ project_name }}_{{ project_version }}.apk" +variables.publish_artefacts.archive_linux = "target/app/archive/{{ project_name }}_{{ project_version }}_linux.tar.gz" +variables.publish_artefacts.archive_win = "target/app/archive/{{ project_name }}_{{ project_version }}_win.zip" +variables.publish_artefacts.installer = "target/app/installer/{{ project_name }}_{{ project_version }}.exe" diff --git a/Dockerfile b/Dockerfile index 375b361..dab8c4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ FROM ubuntu:noble AS base RUN apt update && apt install -y \ - nodejs \ - npm \ - openjdk-11-jre \ - protobuf-compiler \ - jq + nodejs \ + npm \ + openjdk-11-jre \ + protobuf-compiler \ + jq RUN node -v RUN npm -v @@ -12,16 +12,17 @@ FROM base AS builder ENV GRADLE_USER_HOME=/sdk/gradle WORKDIR /app COPY package.json package-lock.json ./ -RUN npm ci +RUN --mount=type=cache,target=/root/.npm \ + npm ci COPY gulpfile.js protohx.json ./ COPY tasks ./tasks COPY config.example.json ./config.example.json RUN --mount=type=secret,id=KEY_STORE \ - cat /run/secrets/KEY_STORE > ./key.jks + cat /run/secrets/KEY_STORE > ./key.jks RUN --mount=type=secret,id=KEY_PASS,env=KEY_PASS \ - jq --arg key_pass "$KEY_PASS" \ - '.SdkDir = "/sdk" | .PublishDir = "/app/publish" | .Key.store = "key.jks" | .Key.pass = $key_pass' \ - config.example.json > config.json + jq --arg key_pass "$KEY_PASS" \ + '.SdkDir = "/sdk" | .PublishDir = "/app/publish" | .Key.store = "key.jks" | .Key.pass = $key_pass' \ + config.example.json > config.json COPY src ./src COPY dependencies ./dependencies VOLUME ["/sdk", "/app/build", "/app/target", "/app/publish", "/app/src-gen"] diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg deleted file mode 100644 index e75f79b..0000000 --- a/ansible/ansible.cfg +++ /dev/null @@ -1,11 +0,0 @@ -[defaults] -hash_behaviour = merge -host_key_checking = False -#callback_whitelist = profile_tasks -display_skipped_hosts = False -stdout_callback = yaml -bin_ansible_callbacks = True - -[ssh_connection] -pipelining = True -ssh_args = -o ForwardAgent=yes diff --git a/ansible/deploy.yml b/ansible/deploy.yml deleted file mode 100644 index a153d32..0000000 --- a/ansible/deploy.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- hosts: all - vars: - ansible_user: "{{ deploy_user }}" - roles: - - ansible-deploy - - build - post_tasks: - - include_role: - name: ansible-deploy - tasks_from: complete.yml diff --git a/ansible/dev/inventory.yml b/ansible/dev/inventory.yml deleted file mode 100644 index 47e4ee3..0000000 --- a/ansible/dev/inventory.yml +++ /dev/null @@ -1,2 +0,0 @@ -all: - hosts: localhost diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml deleted file mode 100644 index 2ff7e21..0000000 --- a/ansible/group_vars/all.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -project_name: puzzlez -project_user: holop - -deploy_user: "{{ project_user }}" -deploy_project: "{{ project_name }}" -deploy_repo_url: "git@bitbucket.org:infernalgames/{{ project_name }}.git" -deploy_repo_version: master -deploy_npm: yes diff --git a/ansible/prod/inventory.yml b/ansible/prod/inventory.yml deleted file mode 100644 index 6e674a5..0000000 --- a/ansible/prod/inventory.yml +++ /dev/null @@ -1,4 +0,0 @@ -all: - hosts: shmyga.ru - vars: - config_src: "/home/holop/puzzlez/config.json" diff --git a/ansible/requirements.yml b/ansible/requirements.yml deleted file mode 100644 index 2248dad..0000000 --- a/ansible/requirements.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- name: ansible-deploy - src: git@bitbucket.org:shmyga/ansible-deploy.git - version: master - scm: git diff --git a/ansible/roles/build/defaults/main.yml b/ansible/roles/build/defaults/main.yml deleted file mode 100644 index e711e90..0000000 --- a/ansible/roles/build/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -config_src: "{{ deploy_release_dir }}/config.{{ inventory_hostname }}.json" -config_dest: "{{ deploy_release_dir }}/config.json" diff --git a/ansible/roles/build/tasks/main.yml b/ansible/roles/build/tasks/main.yml deleted file mode 100644 index 9e5d8d0..0000000 --- a/ansible/roles/build/tasks/main.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- name: "Copy config" - copy: - src: "{{ config_src }}" - dest: "{{ config_dest }}" - remote_src: true - -- name: "Gulp build" - command: "{{ deploy_release_dir }}/node_modules/.bin/gulp default" - args: - chdir: "{{ deploy_release_dir }}" diff --git a/config.example.json b/config.example.json index c8ef9fe..41316a7 100644 --- a/config.example.json +++ b/config.example.json @@ -1,7 +1,7 @@ { - "SdkDir": "C:\\sdk", + "SdkDir": "$HOME/sdk", "BuildDir": null, - "PublishDir": "", + "PublishDir": "$HOME/public/puzzlez", "PublishUrl": "https://shmyga.ru/repo/puzzlez", "Develop": false, "Key": { diff --git a/gulpfile.js b/gulpfile.js index f1b8298..3a6991b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,17 +5,20 @@ const packageInfo = require("./package.json"); const { System, Sdk, Haxe, Project } = require("gulp-haxetool"); const dateformat = require("dateformat"); const publish = require("./tasks/gulp-publish"); +const os = require("os"); + +const resolvePath = (path) => path.replace("$HOME", os.homedir()); if (packageInfo.haxe) { Haxe.VERSION = packageInfo.haxe; } if (Config.SdkDir) { - Sdk.dir = Config.SdkDir; + Sdk.dir = resolvePath(Config.SdkDir); } if (Config.BuildDir) { - Haxe.buildDir = Config.BuildDir; + Haxe.buildDir = resolvePath(Config.BuildDir); } exports.clean = function clean() { @@ -104,7 +107,7 @@ const server = new Project( module.exports.publish = publish( packageInfo.name, packageInfo.version, - Config.PublishDir, + resolvePath(Config.PublishDir), Config.PublishUrl, ); diff --git a/package.json b/package.json index b3b2c56..d6881e8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,10 @@ { "name": "puzzlez", "version": "0.6.1", - "private": true, + "scripts": { + "build": "gulp", + "dev": "gulp app:flash:test" + }, "devDependencies": { "dateformat": "^3.0.3", "fs-extra": "^10.0.0",