build & publish npm package for VIC after ci

This commit is contained in:
Deng, Qian 2017-11-22 20:01:00 +08:00
parent 53dbe7408f
commit f55c0f03b5
5 changed files with 68 additions and 2 deletions

View File

@ -29,6 +29,8 @@ pipeline:
GS_PRIVATE_KEY: ${GS_PRIVATE_KEY}
DOMAIN: ${CI_DOMAIN}
MAIL_PWD: ${MAIL_PWD}
NPM_USERNAME: ${NPM_USERNAME}
NPM_PASSWORD: ${NPM_PASSWORD}
commands:
- tests/integration.sh
when:

View File

@ -1 +1 @@
eyJhbGciOiJIUzI1NiJ9.IyBIYXJib3IgZHJvbmUuCi0tLQp3b3Jrc3BhY2U6CiAgYmFzZTogL2Ryb25lCiAgcGF0aDogc3JjL2dpdGh1Yi5jb20vdm13YXJlL2hhcmJvcgoKcGlwZWxpbmU6CiAgY2xvbmU6CiAgICBpbWFnZTogcGx1Z2lucy9naXQKICAgIHRhZ3M6IHRydWUKICAgIHJlY3Vyc2l2ZTogZmFsc2UKCiAgaW50ZWdyYXRpb24tdGVzdC1vbi1wcjoKICAgIGltYWdlOiB2bXdhcmUvaGFyYm9yLWUyZS1lbmdpbmU6MS4zOAogICAgcHVsbDogdHJ1ZQogICAgcHJpdmlsZWdlZDogdHJ1ZQogICAgZW52aXJvbm1lbnQ6CiAgICAgIEJJTjogYmluCiAgICAgIEdPUEFUSDogL2Ryb25lCiAgICAgIFNIRUxMOiAvYmluL2Jhc2gKICAgICAgTE9HX1RFTVBfRElSOiBpbnN0YWxsLWxvZ3MKICAgICAgR0lUSFVCX0FVVE9NQVRJT05fQVBJX0tFWTogICR7R0lUSFVCX0FVVE9NQVRJT05fQVBJX0tFWX0KICAgICAgRFJPTkVfU0VSVkVSOiAgJHtEUk9ORV9TRVJWRVJ9CiAgICAgIERST05FX1RPS0VOOiAgJHtEUk9ORV9UT0tFTl9JTlRFfQogICAgICBIQVJCT1JfQURNSU46ICR7SEFSQk9SX0FETUlOfQogICAgICBIQVJCT1JfUEFTU1dPUkQ6ICR7SEFSQk9SX1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3RhdHVzOiBzdWNjZXNzCgogIHB1Ymxpc2gtZ2NzLWxhdGVzdDoKICAgIGltYWdlOiBtYXBsYWluL2Ryb25lLWdjczpsYXRlc3QKICAgIHB1bGw6IHRydWUKICAgIHNvdXJjZTogbGF0ZXN0CiAgICB0YXJnZXQ6IGhhcmJvci1jaS1waXBlbGluZS1zdG9yZS9sYXRlc3QKICAgIGFjbDoKICAgICAgLSBhbGxVc2VyczpSRUFERVIKICAgIGNhY2hlX2NvbnRyb2w6IHB1YmxpYyxtYXgtYWdlPTM2MDAKICAgIHdoZW46CiAgICAgIHJlcG86IHZtd2FyZS9oYXJib3IKICAgICAgZXZlbnQ6IFsgcHVzaCwgdGFnIF0KICAgICAgYnJhbmNoOiBbIG1hc3RlciwgcmVsZWFzZS0qLCByZWZzL3RhZ3MvKiBdCiAgICAgIHN0YXR1czogc3VjY2VzcwoKICB0cmlnZ2VyOgogICAgaW1hZ2U6IHBsdWdpbnMvZG93bnN0cmVhbQogICAgc2VydmVyOiBodHRwczovL2NpLnZjbmEuaW8KICAgIHRva2VuOiAke0RPV05TVFJFQU1fVE9LRU59CiAgICBmb3JrOiB0cnVlCiAgICByZXBvc2l0b3JpZXM6CiAgICAgICAtIHZtd2FyZS92aWMtcHJvZHVjdAogICAgd2hlbjoKICAgICAgcmVwbzogdm13YXJlL2hhcmJvcgogICAgICBldmVudDogWyBwdXNoLCB0YWcgXQogICAgICBicmFuY2g6IFsgbWFzdGVyLCByZWxlYXNlLSosIHJlZnMvdGFncy8qIF0KICAgICAgc3RhdHVzOiBzdWNjZXNzCg.WZENHL4ARxyncecQbzpapzF_oP1ilisVdbaHxEkdK1Y

View File

@ -31,6 +31,7 @@ upload_build=false
nightly_run=false
upload_latest_build=false
latest_build_file='latest.build'
publish_npm=true
harbor_logs_bucket="harbor-ci-logs"
harbor_builds_bucket="harbor-builds"
@ -137,7 +138,13 @@ if [ $upload_latest_build == true ] && [ $rc -eq 0 ]; then
fi
fi
## --------------------------------------------- Tear Down -------------------------------------------------------
## ------------------------------------- Build & Publish NPM Package for VIC ------------------------------------
if [ $publish_npm == true ] && [ $rc -eq 0 ] && [[ $DRONE_BUILD_EVENT == "push" || $DRONE_BUILD_EVENT == "tag" ]]; then
echo "build & publish package harbor-ui-vic to npm repo."
./tools/ui_lib/build_ui_lib_4_vic.sh
fi
## ------------------------------------------------ Tear Down ---------------------------------------------------
if [ -f "$keyfile" ]; then
rm -f $keyfile
fi

View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -e
# Generate new version number by git tag and drone id
base_version="0.5"
version_config="\"version\": \"$base_version.$DRONE_BUILD_NUMBER\""
harbor_root="/drone/src/github.com/vmware/harbor"
ui_lib_path="/src/ui_ng/lib"
npm_token_script_path="/tools/ui_lib/get_npm_token.py"
TOKEN=$($harbor_root$npm_token_script_path)
npm set //registry.npmjs.org/:_authToken $TOKEN
echo "Build harbor-ui lib ..."
cd $harbor_root$ui_lib_path
npm install
npm run build
echo "Update package file for VIC ..."
cd ./dist
# update lib name for VIC
sed -i -e 's/harbor-ui/harbor-ui-vic/1' package.json
# update drone number based version number
sed -i -e "s/\"version\":[[:space:]]\".*\"/$version_config/g" package.json
npm publish

32
tools/ui_lib/get_npm_token.py Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This is a script to get npm token
"""
import os
import json
import httplib
def main():
"""
get token from npm
"""
username = os.getenv("NPM_USERNAME")
password = os.getenv("NPM_PASSWORD")
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
auth = {'name': username, 'password': password}
data = json.dumps(auth)
conn = httplib.HTTPSConnection("registry.npmjs.org")
conn.request('PUT', '/-/user/org.couchdb.user:{name}'.format(**auth), data, headers)
res = conn.getresponse()
if int(res.status) / 100 != 2:
raise Exception("npm response not 2XX status")
print json.loads(res.read())['token']
if __name__ == '__main__':
main()