From 7b08f20bd0afba687b88f090ddfaae98d4653198 Mon Sep 17 00:00:00 2001 From: Jim Hamill Date: Sun, 16 Feb 2025 03:55:24 +0000 Subject: [PATCH] Test Lerna Deploy --- .gitlab-ci.yml | 36 +++++++++++++++++++++++++----------- lerna.json | 20 ++++++++++++++++++-- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 57eb62d..4363a63 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,23 +20,37 @@ before_script: - npm run build test: - stage: test - script: - - npm run test - - npm run madge + stage: test + script: + # Run tests + - npm run test + # Ensure no circular dependencies + - npm run madge publish:development: + stage: publish # Configure what tag to use for this publication. variables: NPM_TAG: 'development' + GITLAB_USER_EMAIL: 'ci@stack.xo.cash' + GITLAB_USER_NAME: 'CI - Stack' script: - # set our npm token and then use lerna to publish all packages that are not marked as "private". - - npm config set //registry.npmjs.org/:_authToken ${NPM_AUTH_TOKEN} - # Publish Primitives - # NOTE: The "sed" command will append the JOB_ID version to the current package.json. - # TODO: Simplify this in future or use Lerna's "publish" command. - - (cd ./packages/primitives && sed -i -r "/version/s/([0-9\.]+)/\1-${NPM_TAG}.${CI_JOB_ID}/g" package.json && npm publish --access public --tag ${NPM_TAG}) - - (cd ./packages/stack && sed -i -r "/version/s/([0-9\.]+)/\1-${NPM_TAG}.${CI_JOB_ID}/g" package.json && npm publish --access public --tag ${NPM_TAG}) + # Setup git config + - git config --global user.email "${GITLAB_USER_EMAIL}" + - git config --global user.name "${GITLAB_USER_NAME}" + + # Configure git to push with CI token + - git remote set-url origin "https://oauth2:${CI_JOB_TOKEN}@gitlab.com/${CI_PROJECT_PATH}.git" + + # Setup npm authentication + - | + echo "@${CI_PROJECT_ROOT_NAMESPACE}:registry=https://gitlab.com/api/v4/packages/npm/" > .npmrc + echo "//gitlab.com/api/v4/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc + echo "//gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc + + # Skip git checks when versioning and publishing + - npx lerna version patch --yes --force-publish --no-git-checks + - npx lerna publish from-git --yes --no-git-checks only: - development diff --git a/lerna.json b/lerna.json index 5fb2380..d384d15 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,21 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "packages": ["packages/*"], - "version": "0.0.1" + "version": "0.0.1", + "packages": [ + "packages/*" + ], + "npmClient": "npm", + "command": { + "version": { + "allowBranch": [ + "development" + ], + "exact": true, + "message": "chore: increment patch version to %v" + }, + "publish": { + "registry": "https://gitlab.com/api/v4/packages/npm/", + "exact": true + } + } }