From b2cd7e66ce38bc1cab6ba9999407102605d1da03 Mon Sep 17 00:00:00 2001 From: Neshura Date: Mon, 19 Jun 2023 17:53:03 +0000 Subject: [PATCH] Add CI pipeline --- .gitlab-ci.yml | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..715a556 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,57 @@ +image: 3.10.8-slim-buster + +.deploy: + rules: + # Regex magic copied from Neshura/page-test, only deploys on x.y.z or higher (x.y) Tags + - if: $CI_COMMIT_TAG =~ /^((([\d])+\.){1,2}[\d]+)\s*$/ && $CI_COMMIT_TAG + +stages: + - build + - release + +## Docker steps + +build: + image: rust:bullseye + stage: build + + variables: + IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH + CACHING: + + script: + - echo "Compiling the code..." + - cargo build -r + - echo "Compile complete." + + after_script: + - echo JOB_ID=$CI_JOB_ID >> job.env + - mkdir ./artifacts + - cp /builds/Neshura/ascendance-of-a-bookworm-bot/target/release/ascendance-of-a-bookworm-bot ./artifacts/ + + artifacts: + paths: + - ./artifacts/ + reports: + dotenv: job.env + + rules: + - !reference [.deploy, rules] + +Tag Release: + needs: + - job: build + artifacts: true + stage: release + image: registry.gitlab.com/gitlab-org/release-cli:latest + rules: + - !reference [.deploy, rules] + script: + - echo "running Release Job, attaching Artifact from Job $JOB_ID" + release: + tag_name: '$CI_COMMIT_TAG' + description: '$CI_COMMIT_TAG' + assets: + links: + - name: "ascendance-of-a-bookworm-bot.zip" + url: "https://gitlab.neshweb.net/Neshura/ascendance-of-a-bookworm-bot/-/jobs/$JOB_ID/artifacts/download"