diff --git a/.circleci/config.yml b/.circleci/config.yml index 67b061a..14ffc42 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -167,6 +167,9 @@ jobs: version: 20.10.14 - restore_cache: <<: *cache-defaults + - run: + name: Install jq + command: sudo apt-get install jq -y - run: name: Create Release command: if [ -z ${CIRCLE_SKIP_DEPLOY+x} ]; then npm run semantic-release;else echo 'job skipped';fi @@ -205,7 +208,9 @@ workflows: requires: - install - deploy: - context: npm-packages + context: + - npm-packages + - docker requires: - test-coverage - test-package diff --git a/bin/release/prepare.sh b/bin/release/prepare.sh index e749b90..793c8c7 100755 --- a/bin/release/prepare.sh +++ b/bin/release/prepare.sh @@ -1,7 +1,14 @@ #!/bin/bash +set -e + VERSION=$1 docker build -t pustovitdmytro/ianus-base:$VERSION -f docker/Base.dockerfile . docker build -t pustovitdmytro/ianus-worker:$VERSION -f docker/Worker.dockerfile . docker build -t pustovitdmytro/ianus-admin:$VERSION -f docker/Admin.dockerfile . + +repo_url=$(cat package.json | jq -r .repository.url) +readme=$(jq tostring --raw-input --slurp README.md) + +echo '{"full_description":'$readme',"description":"'"$repo_url"'"}' > .dockerhub.readme diff --git a/bin/release/publish.sh b/bin/release/publish.sh index c4e49c2..effdf60 100755 --- a/bin/release/publish.sh +++ b/bin/release/publish.sh @@ -1,13 +1,19 @@ #!/bin/bash +set -e + VERSION=$1 MINOR=${VERSION%.*} MAJOR=${MINOR%.*} +jwt=$(cat .dockerhub.jwt) +readme=$(cat .dockerhub.readme) + for image in "pustovitdmytro/ianus-base" "pustovitdmytro/ianus-admin" "pustovitdmytro/ianus-worker"; do for tag in $VERSION $MINOR $MAJOR "latest"; do docker tag $image:$VERSION $image:$tag docker push $image:$tag echo "Pushed $image:$tag" + curl -X PATCH --fail -H "Content-type: application/json" -H "Authorization: JWT $jwt" -d "$readme" "https://hub.docker.com/v2/repositories/$image" done; done diff --git a/bin/release/verifyConditions.sh b/bin/release/verifyConditions.sh index 774bfca..a2a3c8c 100755 --- a/bin/release/verifyConditions.sh +++ b/bin/release/verifyConditions.sh @@ -1,3 +1,11 @@ #!/bin/bash -docker login -u $DOCKER_REGISTRY_USER -p $DOCKER_REGISTRY_PASSWORD \ No newline at end of file +set -e + +docker login -u $DOCKER_REGISTRY_USER -p $DOCKER_REGISTRY_PASSWORD + +AUTH_BODY='{"username":"'"$DOCKER_REGISTRY_USER"'","password":"'"$DOCKER_REGISTRY_PASSWORD"'"}' + +response=$(curl -XPOST --fail -H "Content-type: application/json" -d $AUTH_BODY 'https://hub.docker.com/v2/users/login') + +echo $response | jq -r .token >> .dockerhub.jwt \ No newline at end of file