Skip to content
Snippets Groups Projects
Commit 52e19665 authored by Martin Hamerník's avatar Martin Hamerník
Browse files

Resolve "Add CI"

parent b50baa15
No related branches found
No related tags found
No related merge requests found
image: angulardeploy
variables:
PYTHON_TAG: py3
ABI_TAG: none
PLATFORM_TAG: any
PACKAGE_EXTENSION: whl
DEBIAN_PACKAGE_EXTENSION: deb
LANG: C.UTF-8
LC_ALL: C.UTF-8
LANG: C.UTF-8
LC_ALL: C.UTF-8
stages:
# - unitTests #TODO, Not implemented yet
# - integrationTests #TODO, Not implemented yet
- buildAngular
- editVersion
- buildDebian
- deployDebian
- deployAngular
# - unitTests
# - integrationTests
- buildAngular
- deployAngular
before_script:
# Get version.
# Variable CI_COMMIT_TAG is set only when tag was pushed.
- export VERSION=$(if [[ "$CI_COMMIT_TAG" == "" ]]; then echo $(dpkg-parsechangelog --show-field version); else echo $CI_COMMIT_TAG | cut -c 2-; fi)
- echo $VERSION
# Get machine distribution
- export DEBIAN_DISTRIBUTION=$(cat /etc/os-release | grep VERSION | grep -Po "(?<=\().*(?=\))")
- echo $DEBIAN_DISTRIBUTION
# Get debian package filename
- export DEBIAN_PACKAGE=$(dpkg-parsechangelog --show-field source)_${VERSION}_$(dpkg --print-architecture).$DEBIAN_PACKAGE_EXTENSION
- echo $DEBIAN_PACKAGE
# Set additional Apt repository
- echo "$APT_SOURCE_LIST" > /etc/apt/sources.list.d/kypo.list
# Install Angular dependencies
# Get version.
# Variable CI_COMMIT_TAG is set only when tag was pushed.
- export VERSION=$(if [[ "$CI_COMMIT_TAG" == "" ]]; then echo "GitLab tag is missing!"; else echo $CI_COMMIT_TAG | cut -c 2-; fi)
- echo $VERSION
- cp $NPMRC_PULL ~/.npmrc
- npm install
#TODO, not implemented yet
#unitTests:
# stage: unitTests
# script:
......@@ -43,7 +27,7 @@ before_script:
# - branches
# - tags
#TODO, not implemented yet
# TODO: Not yet implemented
#integrationTests:
# stage: integrationTests
# script:
......@@ -54,68 +38,31 @@ before_script:
# - tags
buildAngular:
stage: buildAngular
script:
- cp /usr/local/npmrc ~/.npmrc
- npm install
- ng build --configuration=production
only:
- triggers
- branches
- tags
artifacts:
paths:
- ./dist
expire_in: 1 hour
stage: buildAngular
script:
- ng build
only:
- triggers
- branches
- tags
editVersion:
stage: editVersion
script:
- export GIT_SSH_COMMAND='ssh -i ~/.ssh/kyposervicekey'
- ssh -o "StrictHostKeyChecking no" git@gitlab.ics.muni.cz && sleep 1
- git clone git@gitlab.ics.muni.cz:kypo2/frontend-new/kypo2-trainings-visualization-overview.git
- cd $CI_PROJECT_NAME
- git config --global user.name "KYPO CI" && git config --global user.email "kyposervice@ics.muni.cz"
# sed -i -e 's/ "version":.*/ "version": "'$VERSION'",/' projects/user-and-group-management/package.json'
# The command above is not a friend with YAML. Run it in a script as a workaround.
- bash /usr/local/changeVersion.sh $VERSION kypo2-trainings-visualization-overview-lib
- git commit -am "Update project package.json version based on GitLab tag. Done by CI" && sleep 1
- git push
only:
- tags
buildDebian:
image: gitbuildpackage
stage: buildDebian
script:
# --distribution $DEBIAN_DISTRIBUTION
- gbp dch --debian-tag="v%(version)s" --new-version $VERSION --distribution stable --force-distribution --release --spawn-editor none --id-length 8 --ignore-branch --git-log="--merges --grep=into[[:space:]]'master'"
# -uc do not sign .changes file, -us do not sign source package (see dpkg-buildpackage)
# -i -I exclude .git directory (see dpkg-source)
- gbp buildpackage --git-ignore-new --git-ignore-branch --git-builder=debuild -rfakeroot -us -uc -i -I
- cp ../$DEBIAN_PACKAGE .
only:
- triggers
- branches
- tags
artifacts:
paths:
- ./*.$DEBIAN_PACKAGE_EXTENSION
expire_in: 1 hour
deployDebian:
stage: deployDebian
script:
- 'curl -u $APT_USER:$APT_PASSWORD -X POST -H "Content-Type: multipart/form-data" --data-binary "@$DEBIAN_PACKAGE" "$APT_UPLOAD_URL"'
- '$TRIGGER_PIPELINE'
only:
- tags
deployAngular:
stage: deployAngular
script:
- git checkout master && git pull
- cp /usr/local/npmrc ~/.npmrc
- 'npm install && npm run lib-build && cd dist/kypo2-trainings-visualization-overview-lib/ && npm publish --registry=http://kypo-storage.ics.muni.cz:8081/repository/npm-hosted'
only:
- tags
editVersionAndDeploy:
stage: deployAngular
script:
- export GIT_SSH_COMMAND='ssh -i ~/.ssh/kyposervicekey'
- ssh -o "StrictHostKeyChecking no" git@gitlab.ics.muni.cz && sleep 1
- git clone git@gitlab.ics.muni.cz:kypo-crp/frontend-angular/components/kypo2-trainings-visualization-overview.git
- cd $CI_PROJECT_NAME
- git config --global user.name "KYPO CI" && git config --global user.email "kyposervice@ics.muni.cz"
# sed -i -e 's/ "version":.*/ "version": "'$VERSION'",/' projects/user-and-group-management/package.json'
# The command above is not a friend with YAML. Run it in a script as a workaround.
- bash /usr/local/changeVersion.sh $VERSION kypo2-trainings-visualization-overview-lib
- git commit -am "Update project package.json version based on GitLab tag. Done by CI" && sleep 1
- git push
- sleep 5
- cp $NPMRC_PULL ~/.npmrc
- 'npm run build-and-pack'
- cp $NPMRC_PUSH ~/.npmrc
- 'cd dist/kypo2-trainings-visualization-overview-lib && npm publish'
only:
- tags
This diff is collapsed.
......@@ -8,13 +8,12 @@
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"lib-build": "ng build --prod kypo2-trainings-visualization-overview-lib && cp ./projects/kypo2-trainings-visualization-overview-lib/src/lib/styles.css ./dist/kypo2-trainings-visualization-overview-lib",
"build-and-pack": "ng build --prod kypo2-trainings-visualization-overview-lib && cp ./projects/kypo2-trainings-visualization-overview-lib/src/lib/styles.css ./dist/kypo2-trainings-visualization-overview-lib",
"lib-copy": "cp -a ./dist/kypo2-trainings-visualization-overview-lib/. ../kypo2-trainings-visualization-overview-package/",
"cp": "rm -rf ../kypo2-visualization-dashboard/node_modules/kypo2-trainings-visualization-overview-lib/* && cp -a ./dist/kypo2-trainings-visualization-overview-lib/. ../kypo2-visualization-dashboard/node_modules/kypo2-trainings-visualization-overview-lib",
"lib-push": "mkdir -p ../kypo2-trainings-visualization-overview-package && cd ../kypo2-trainings-visualization-overview-package && git add . && git commit -m 'Update according to master branch' && git push",
"lib-build-and-push": "npm run lib-build && npm run lib-copy && npm run lib-push",
"push": "git push && npm run lib-build-and-push",
"publish": "npm run lib-build && cd dist/kypo2-trainings-visualization-overview-lib/. && npm publish --registry=http://kypo-storage.ics.muni.cz:8081/repository/npm-hosted"
"push": "git push && npm run lib-build-and-push"
},
"private": true,
"dependencies": {
......@@ -28,11 +27,11 @@
"@angular/platform-browser": "^9.0.0",
"@angular/platform-browser-dynamic": "^9.0.0",
"@angular/router": "^9.0.0",
"angular-oauth2-oidc": "8.0.4",
"angular-oauth2-oidc": "9.2.2",
"core-js": "^2.6.9",
"d3": "^5.15.0",
"csirt-mu-d3-service": "9.0.0",
"kypo2-auth": "9.0.0",
"kypo2-auth": "9.1.0",
"rxjs": "^6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment