@sudosf/npm-publish-sandbox 3.10.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/.gitlab-ci.yml +79 -0
  2. package/index.js +5 -0
  3. package/package.json +10 -0
package/.gitlab-ci.yml ADDED
@@ -0,0 +1,79 @@
1
+ include:
2
+ - template: Jobs/SAST.gitlab-ci.yml
3
+ - template: Jobs/Dependency-Scanning.v2.gitlab-ci.yml
4
+ - template: Jobs/Code-Quality.gitlab-ci.yml
5
+ - template: Jobs/Secret-Detection.gitlab-ci.yml
6
+
7
+ variables:
8
+ KIBANA_VERSION: 9.1.7
9
+ KIBANA_IMAGE_TAG: "9.1.9"
10
+
11
+ stages:
12
+ - test
13
+ - yarn_steps
14
+ - deploy
15
+
16
+ artifactory-push:
17
+ stage: deploy
18
+ rules:
19
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
20
+ when: never
21
+ - if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "stable" || $CI_COMMIT_BRANCH == "qa" || $CI_COMMIT_BRANCH == "staging"
22
+ when: always
23
+ - if: $CI_COMMIT_BRANCH =~ /^hotfix\/(master|qa|staging|stable)-/
24
+ when: always
25
+ - when: never
26
+ script:
27
+ - npm config set registry https://artifactory.orbit.prod.vodacom.co.za/artifactory/api/npm/vod-npm/
28
+ - npm config set //artifactory.orbit.prod.vodacom.co.za/artifactory/api/npm/vod-npm/:_auth $(echo -n $ARTIFACTORY_USERNAME:$ARTIFACTORY_PASSWORD | base64)
29
+ - |
30
+ BASE_NAME=$(node -p "require('./package.json').name")
31
+ VERSION=$(node -p "require('./package.json').version")
32
+ TAG="v$VERSION"
33
+
34
+ echo "Base package name: $BASE_NAME"
35
+ echo "Version: $VERSION"
36
+
37
+ # Determine environment from branch
38
+ if [[ $CI_COMMIT_BRANCH == "stable" || $CI_COMMIT_BRANCH =~ ^hotfix/stable- ]]; then
39
+ ENV="stable"
40
+ elif [[ $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH =~ ^hotfix/master- ]]; then
41
+ ENV="dev"
42
+ elif [[ $CI_COMMIT_BRANCH == "qa" || $CI_COMMIT_BRANCH =~ ^hotfix/qa- ]]; then
43
+ ENV="qa"
44
+ elif [[ $CI_COMMIT_BRANCH == "staging" || $CI_COMMIT_BRANCH =~ ^hotfix/staging- ]]; then
45
+ ENV="staging"
46
+ fi
47
+
48
+ echo "Publishing to $ENV environment"
49
+
50
+ # Configure git for tagging
51
+ git config --global --add safe.directory $CI_PROJECT_DIR
52
+ git remote set-url origin "https://oauth2:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
53
+
54
+ # Create generic version tag only for stable releases
55
+ if [[ "$ENV" == "stable" ]]; then
56
+ if ! git rev-parse "$TAG" >/dev/null 2>&1; then
57
+ git tag "$TAG"
58
+ git push origin "$TAG"
59
+ fi
60
+ fi
61
+
62
+ # Create/update environment-specific tag
63
+ git tag -f "$TAG-$ENV"
64
+ git push origin "$TAG-$ENV" --force
65
+
66
+ # Publish to npm with mutable environment dist-tag
67
+ npm publish --tag "$ENV"
68
+
69
+ # Extract major version for major-version-specific dist-tags
70
+ MAJOR_VERSION=$(echo "$VERSION" | grep -o '^[0-9]*')
71
+
72
+ # Add immutable version-specific dist-tag
73
+ npm dist-tag add "$BASE_NAME@$VERSION" "$VERSION-$ENV"
74
+
75
+ # Add major-version-specific dist-tags
76
+ npm dist-tag add "$BASE_NAME@$VERSION" "$ENV-$MAJOR_VERSION"
77
+ npm dist-tag add "$BASE_NAME@$VERSION" "$VERSION-$ENV-$MAJOR_VERSION"
78
+
79
+ echo "Published $BASE_NAME@$VERSION with tags @$ENV, @$VERSION-$ENV, @$ENV-$MAJOR_VERSION, @$VERSION-$ENV-$MAJOR_VERSION"
package/index.js ADDED
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ hello: () => 'Hello from npm-publish-sandbox'
5
+ };
package/package.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@sudosf/npm-publish-sandbox",
3
+ "version": "3.10.6",
4
+ "description": "Sandbox package for testing npm publish to Artifactory",
5
+ "main": "index.js",
6
+ "license": "MIT",
7
+ "publishConfig": {
8
+ "registry": "https://registry.npmjs.org/"
9
+ }
10
+ }