From 9eec3d64177d3146888293bd56f67d2977de6dff Mon Sep 17 00:00:00 2001 From: Christophe Chaudier <christophe@lydra.fr> Date: Thu, 13 Apr 2023 15:34:38 +0200 Subject: [PATCH] ci: publish on gitlab registry --- .gitlab-ci.yml | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..9691d46 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,43 @@ +--- +image: node:lts-slim + +stages: + - test + - build + - deploy + +variables: + - NPM_ORGANIZATION: lydra + +cache: + key: ${CI_COMMIT_REF_SLUG} + paths: + - node_modules/ + +before_script: + - npm ci + +build: + stage: build + script: + - npm run build + artifacts: + paths: + - dist + +publish_gitlab_registry: + stage: deploy + needs: + - job: build + artifacts: true + dependencies: + - build + script: + - npm config set ${NPM_ORGANIZATION}:registry ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/npm/ + - npm config set -- '${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/npm/:_authToken' "${CI_JOB_TOKEN}" + - npm config set -- '${CI_API_V4_URL}/packages/npm/:_authToken' "${CI_JOB_TOKEN}" + - npm publish + + # Nous conseillons de ne pas trigger la publication a chaque CI, ici la règle demande si le tag existe, restreignant ainsi la publication au tag + rules: + - if: $CI_COMMIT_TAG -- GitLab