Skip to content

Commit

Permalink
ci: Added pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
gergof committed Sep 5, 2022
1 parent 0d72906 commit 6940946
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
variables:
TEST_IMAGE: "node:14-alpine"
BUILD_IMAGE: "gitlab.paymoapp.com:5555/envscripts/img-ubuntu-base"

# Mixins
.only_any_v_tags:
only:
- /^v[0-9]+\.[0-9]+\.[0-9]+/
except:
- branches

.only_release_v_tags:
only:
- /^v[0-9]+\.[0-9]+\.[0-9]+$/
except:
- branches

.job_test:
image: $TEST_IMAGE
stage: test
rules:
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_TAG
before_script:
- npm ci --ignore-scripts

stages:
- test
- build-addon
- publish

# Test stage
lint:
extends:
- .job_test
script:
- npm run lint

typecheck:
extends:
- .job_test
script:
- npm run typecheck

# Build-addon stage
build-addon-windows:
extends:
- .only_any_v_tags
stage: build-addon
tags:
- win
before_script:
- npm config set msvs_version 2022
- npm ci --ignore-scripts
script:
- npm run build:gyp
- npm run publish:bindings
needs:
- lint
- typecheck

# Publish stage
build-library:
extends:
- .only_any_v_tags
image: $BUILD_IMAGE
stage: publish
before_script:
- npm ci --ignore-scripts
script:
- npm run build:ts
- npm set //registry.npmjs.org/:_authToken $NPM_TOKEN
- npm publish --access public
- LAST_RELEASE="$(git describe --abbrev=0 --tags ${CI_COMMIT_TAG}^)"
- CHANGELOG="$(git diff -U0 $LAST_RELEASE $CI_COMMIT_TAG CHANGELOG.md | grep -E "^\+" | grep -vE "^\+\+\+" | grep -vE "^\+#+ \[" | sed "s/^\+//")"
- >
curl -sSL -X POST -H "JOB-TOKEN: $CI_JOB_TOKEN" -H "Content-type: application/json" -d "{ \"name\": $(echo $CI_COMMIT_TAG | jq -Ra .), \"tag_name\": $(echo $CI_COMMIT_TAG | jq -Ra .), \"description\": $(echo "$CHANGELOG" | jq -Rsa .) }" ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/releases
artifacts:
paths:
- dist
expire_in: 12h
needs:
- lint
- typecheck

0 comments on commit 6940946

Please sign in to comment.