From 844a3f6e675023d53dcdd1eb7413ea181cb27a0d Mon Sep 17 00:00:00 2001
From: Louis Capitanchik <contact@louiscap.co>
Date: Sun, 31 Jul 2022 17:50:27 +0100
Subject: [PATCH] Add gitlab build; deploy pages, build all on trunk

---
 .gitlab-ci.yml | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)
 create mode 100644 .gitlab-ci.yml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..7ab614c
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,75 @@
+image: "r.lcr.gr/microhacks/bevy-builder:latest"
+
+variables:
+  BINARY_NAME: game
+
+.cache_directive: &cache_directive
+  before_script:
+    - export CARGO_HOME="${CI_PROJECT_DIR}/.cargo"
+    - export PATH="${CI_PROJECT_DIR}/.cargo/bin:$PATH"
+  cache:
+    key: build-cache-key
+    paths:
+      - .cargo/registry/cache
+      - .cargo/registry/index
+      - .cargo/git/db
+      - .cargo/bin/
+      - target/
+
+stages:
+  - build
+  - package
+
+build-windows:
+  stage: build
+  <<: *cache_directive
+  script:
+    - cargo build --release -p game_core --target x86_64-pc-windows-gnu
+  only:
+    - trunk
+
+build-linux:
+  stage: build
+  <<: *cache_directive
+  script:
+    - cargo build --release -p game_core --target x86_64-unknown-linux-gnu
+  only:
+    - trunk
+
+build-web:
+  stage: build
+  <<: *cache_directive
+  script:
+    - cargo build --release -p game_core --target x86_64-unknown-linux-gnu
+  only:
+    - trunk
+
+package-all:
+  stage: package
+  <<: *cache_directive
+  script:
+    - mkdir -p dist/
+    - cp -r assets dist/assets
+    - cp target/x86_64-unknown-linux-gnu/release/game_core "dist/$BINARY_NAME"
+    - cp target/x86_64-pc-windows-gnu/release/game_core.exe "dist/$BINARY_NAME.exe"
+    - cd "${CI_PROJECT_DIR}/dist && zip -r "windows.zip" "./${BINARY_NAME}.exe" ./assets
+    - cd "${CI_PROJECT_DIR}/dist && zip -r "linux.zip" "./${BINARY_NAME}" ./assets
+    - cd "${CI_PROJECT_DIR}/game_core/dist && zip -r "../../dist/web.zip" "./*"
+  artifacts:
+    paths:
+      - dist/web.zip
+      - dist/windows.zip
+      - dist/linux.zip
+  only:
+    - trunk
+
+pages:
+  stage: package
+  script:
+    - mkdir -p public/
+    - cp -r game_core/dist/* public/
+  artifacts:
+    paths:
+      - public
+  only:
+    - trunk
\ No newline at end of file
-- 
GitLab