diff --git a/.env.default b/.env.default new file mode 100644 index 0000000..b588452 --- /dev/null +++ b/.env.default @@ -0,0 +1,10 @@ +PROJECT=tankz +SDK_PATH=$HOME/sdk +PUBLISH_PATH=$HOME/public/$PROJECT +BUILD_PATH=./build +TARGET_PATH=./target +KEY_STORE= +KEY_PASS= +REPO=https://git.shmyga.ru/api/packages/InfernalGames +PUBLISH_USER= +PUBLISH_PASSWORD= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6ca9a0b..bd851f2 100755 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ config.json /log /ansible/*.retry .npmrc +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1d68059 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM ubuntu:noble AS base +RUN apt update && apt install -y \ + nodejs \ + npm \ + openjdk-11-jre \ + protobuf-compiler \ + jq +RUN node -v +RUN npm -v + +FROM base AS builder +ENV GRADLE_USER_HOME=/sdk/gradle +WORKDIR /app +COPY package.json package-lock.json ./ +RUN 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 +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 +COPY src ./src +#COPY dependencies ./dependencies +VOLUME ["/sdk", "/app/build", "/app/target", "/app/publish", "/app/src-gen"] +CMD ["npx", "gulp", "default"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..8f6a94b --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Tankz + +## Play + +https://shmyga.ru/tankz/html5/index.html + +## Packages + +https://git.shmyga.ru/InfernalGames/-/packages/generic/tankz diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..20c3a6a --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,22 @@ +name: $PROJECT +services: + builder: + container_name: $PROJECT-builder + image: infernal-games/$PROJECT-builder + build: + context: . + secrets: + - KEY_STORE + - KEY_PASS + volumes: + - ${SDK_PATH}:/sdk + - ${BUILD_PATH}:/app/build + - ${TARGET_PATH}:/app/target + - ${PUBLISH_PATH}:/app/publish + - ./src-gen:/app/src-gen + +secrets: + KEY_STORE: + file: $KEY_STORE + KEY_PASS: + environment: KEY_PASS diff --git a/gulpfile.js b/gulpfile.js index c7b6193..293fbef 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -23,12 +23,25 @@ exports.clean = function clean() { return gulp.src('target/*', {read: false}).pipe(gulpClean()); }; -exports.generate = function generate() { - return new Haxe().haxelib(['run', 'protohx', 'generate', 'protohx.json']).then(({stdout}) => { - if (stdout.indexOf('FAIL') > -1) { - throw stdout; +exports.setup = function setup() { + const builder = Project.Builder.new( + client.config, + Project.Platform.ANDROID, + client.buildSystem, + ); + return builder.prepare(); +}; + +exports.generate = function generate() { + return exports.setup().then(() => + new Haxe() + .haxelib(["run", "protohx", "generate", "protohx.json"]) + .then(({ stdout }) => { + if (stdout.indexOf("FAIL") > -1) { + throw stdout; } - }); + }), + ); }; /** diff --git a/scripts/build b/scripts/build new file mode 100755 index 0000000..bb4faf4 --- /dev/null +++ b/scripts/build @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -e +cd "$(dirname $(dirname "$0"))" || exit + +source .env +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 \ No newline at end of file diff --git a/scripts/publish b/scripts/publish new file mode 100755 index 0000000..3c578b1 --- /dev/null +++ b/scripts/publish @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +set -e +cd "$(dirname $(dirname "$0"))" || exit +source .env + +VERSION=$(grep -m 1 'version' ./package.json | grep -oP '"version"\s*:\s*"\K\d+\.\d+\.\d+') + +curl --user "${PUBLISH_USER}:${PUBLISH_PASSWORD}" -X DELETE \ + "${REPO}/generic/${PROJECT}/${VERSION}" + +PACKAGES=( + "android/${PROJECT}_${VERSION}.apk" + "debian/${PROJECT}_${VERSION}_all.deb" + "archive/${PROJECT}_${VERSION}_linux.tar.gz" +) + +for PACKAGE in "${PACKAGES[@]}" +do + PACKAGE_NAME=$(basename "$PACKAGE") + echo "publish: $PACKAGE" + curl --user "${PUBLISH_USER}:${PUBLISH_PASSWORD}" \ + --upload-file "${PUBLISH_PATH}/${PACKAGE}" \ + "${REPO}/generic/${PROJECT}/${VERSION}/${PACKAGE_NAME}" + + if [[ "$PACKAGE" == *.deb ]]; then + curl --user "${PUBLISH_USER}:${PUBLISH_PASSWORD}" -X DELETE \ + "${REPO}/debian/pool/noble/main/${PROJECT}/${VERSION}/all" + curl --user "${PUBLISH_USER}:${PUBLISH_PASSWORD}" \ + --upload-file "${PUBLISH_PATH}/${PACKAGE}" \ + "${REPO}/debian/pool/noble/main/upload" + fi +done \ No newline at end of file