From 775cbc6538393778e482afa1835ba6dfc4a13d2a Mon Sep 17 00:00:00 2001 From: Andres Date: Tue, 5 Sep 2017 10:50:39 +0200 Subject: [PATCH 1/7] Enable automatic releases --- .travis.yml | 17 ++++++++++++- package.json | 2 +- scripts/release.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100755 scripts/release.sh diff --git a/.travis.yml b/.travis.yml index 54e74ad..832270b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,22 @@ services: env: global: - KUBELESS_VERSION=0.1.0 + secure: "dPepHM5HTKrejZx4Ec3q2t/T0bqM6K5boZpVLdKAnHy4pIQ2+AQwYBRJO+DixQeD4vinhEEucDJuE9zJIe+nghB7RsdVMCMw8xDK7/QAW+rw+YO22sWcIye9kWYmHnteq6q+wAzcnOvyJ/UHY8ZhOXm42Lu6ZWc2u7ksibFGri2eC53Ot529P44Yy4gGUE+hZ14mXvivCSgiQp/cEEK/t7+t1ISl0BK97P7SeSCuNSZzXGu9aZTSjcaM52XqFwfnzn2Lb+qGqj8mthZOUBgnAnP5e9mmVPfeZURlFRDGZVY74erJarSlSNkko7RDZ5s8J0HQ/ur+KXWh9d9PICuJb5mPyfAVK9hYjd8R+hZ7MAH3UBQBIyJekflDCWiPVZLX3fsKsX4vX20lpYrEMwO7HSzrJiX2XHEnQU8aPJ+GtONpoeVH5c7MWhv5XpCo03nSMvxkIBe9P8tv4Wz1bTgU48NUn+noxz5aTu+G/35SCIeGfQOpWp1FSNFoB0NKOh9P15Uwlhot+gEA7XsxkCPpn4da8fs3rjcLhLCiZqUo1Anwitx3hMtViXqkR/QAlaEErIYqjLdIj15xfIND5JmveP7WveHotboprlblyMOqSDHc2B9L24RrlKNiZNS3W8Mr8qLh8S7kFqH9ixCPQRj+kfLrs/SWEbTY8tU/uTulHDA=" install: - ./scripts/install-test-environment.sh - npm install -g serverless - - npm install \ No newline at end of file + - npm install +after_success: + - | + if [[ "$TRAVIS_BRANCH" == master && \ + "$TRAVIS_PULL_REQUEST" == false ]]; then + REPO_DOMAIN=serverless REPO_NAME=serverless-kubeless ./scripts/release.sh + fi +deploy: + provider: npm + email: npm@bitnami.com + api_key: + secure: "rgqKaazC2RPDx4BJobB/XZcpClX7H4XZeZb2MHB6GYoibzf1EqDdHK3eGX2MwbtN9I2xMAn6h88gjbPSvPZrxIWQAfrrbwzPzOtteFfiRWWzlQpuNEuLTs3pAHpsYfrbJGMBBMLVq2X0+i1NGrEIlQfRfQvCBkV1xdCO0nRxheKhoikWCAVkd8MXDmmTre9+Uxk44MjjSKpn3eqM/IDMHDUoisLFnw4lsbM80TjMHNagQozBeoGQwLK81+0ZbFhW9qCSw8GeSznqJdkeJzz3iIYQs9JMqBv9VpLADTpPgUdbMvvtKhL5nGaJVDQCmLjVxmo9lZDNfrCjVq5zARt6s688tUqXZmC+pqJXPVqCTcs5UgcOUgU2hZejv0croE55lMNcCKTaICBg9MVBLUNEYXZVOKArAl9uvRc/FNOnnv7PVHMYC0iHBQADuIgskOBCboV6kC2EBH0h2mZdm4Y2hoFOD/ZEwfDtfWlrakKxPsD3zbDPhS31CjOQwp1UJqbj94w9ztXiqEI5B/Oo7OEpQ72aHbtlysQPKaa2BAyzxICJzB17otJjP7pcj3lmwiU3scIJjbzCAzPRKByQmyjGhHLZItJRMn6CMWY/EeodZXRrqej6ToTLNyzSt8c7r9xl8W9ViyRJxFbElYkZ/OLgLwc3sD1sB0vVvWfoM9xyzQI=" + on: + tags: true + repo: serverless/serverless-kubeless diff --git a/package.json b/package.json index 881decd..4fd3470 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "serverless-kubeless", - "version": "0.1.11", + "version": "0.1.12", "description": "This plugin enables support for Kubeless within the [Serverless Framework](https://github.com/serverless).", "main": "index.js", "directories": { diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000..ec9fc57 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,63 @@ +#!/bin/bash +set -e + +function get_version { + echo $(jq -r .version ./package.json) +} + +function check_tag { + local tag=$1 + published_tags=`curl -s https://api.github.com/repos/$REPO_DOMAIN/$REPO_NAME/tags` + already_published=`echo $published_tags | jq ".[] | select(.name == \"$tag\")"` + echo $already_published +} + +function release_tag { + local tag=$1 + git fetch --tags + local last_tag=`curl -s https://api.github.com/repos/$REPO_DOMAIN/$REPO_NAME/tags | jq --raw-output '.[0].name'` + local release_notes=`git log $last_tag..HEAD --oneline` + # Parse relase notes like an list (e.g): + # - 12345abcd Merge pull request #1 Title + # - 12345efgh commit included 1 + # - 12345hijk commit included 2 + local parsed_release_notes=$(echo "$release_notes" | sed -n -e 'H;${x;s/\n/\\n - /g;s/^\\n//;p;}') + parsed_release_notes=`echo "$parsed_release_notes" | sed -e '${s/ \( - [^ ]* Merge pull request\)/\1/g;}'` + release=`curl -H "Authorization: token $ACCESS_TOKEN" -s --data "{ + \"tag_name\": \"$tag\", + \"target_commitish\": \"master\", + \"name\": \"$REPO_NAME-$tag\", + \"body\": \"Release $tag includes the following commits: \n$parsed_release_notes\", + \"draft\": false, + \"prerelease\": false + }" https://api.github.com/repos/$REPO_DOMAIN/$REPO_NAME/releases` + echo $release | jq ".id" +} + +version=`get_version` + +if [[ -z $REPO_NAME ]]; then + echo "Github repository not specified" > /dev/stderr + exit 1 +fi + +repo_check=`curl -s https://api.github.com/repos/$REPO_DOMAIN/$REPO_NAME` +if [[ $repo_check == *"Not Found"* ]]; then + echo "Not found a Github repository for $REPO_DOMAIN/$REPO_NAME, it is not possible to publish it" > /dev/stderr + exit 1 +else + tag=v$version + already_published=`check_tag $tag` + if [[ -z $already_published ]]; then + echo "Releasing $tag in Github" + release_id=`release_tag $tag` + if [ "$release_id" == "null" ]; then + echo "There was an error trying to release $tag" > /dev/stderr + exit 1 + else + echo "Released $tag with ID $release_id" + fi + else + echo "Skipping Github release since $tag was already released" + fi +fi From 1bcf933d56f8dda32f2ed172826c456fe5f4ef30 Mon Sep 17 00:00:00 2001 From: Andres Date: Tue, 5 Sep 2017 11:30:07 +0200 Subject: [PATCH 2/7] Change account --- .travis.yml | 8 ++++---- scripts/release.sh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 832270b..40bbdc6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,8 @@ services: - docker env: global: - - KUBELESS_VERSION=0.1.0 - secure: "dPepHM5HTKrejZx4Ec3q2t/T0bqM6K5boZpVLdKAnHy4pIQ2+AQwYBRJO+DixQeD4vinhEEucDJuE9zJIe+nghB7RsdVMCMw8xDK7/QAW+rw+YO22sWcIye9kWYmHnteq6q+wAzcnOvyJ/UHY8ZhOXm42Lu6ZWc2u7ksibFGri2eC53Ot529P44Yy4gGUE+hZ14mXvivCSgiQp/cEEK/t7+t1ISl0BK97P7SeSCuNSZzXGu9aZTSjcaM52XqFwfnzn2Lb+qGqj8mthZOUBgnAnP5e9mmVPfeZURlFRDGZVY74erJarSlSNkko7RDZ5s8J0HQ/ur+KXWh9d9PICuJb5mPyfAVK9hYjd8R+hZ7MAH3UBQBIyJekflDCWiPVZLX3fsKsX4vX20lpYrEMwO7HSzrJiX2XHEnQU8aPJ+GtONpoeVH5c7MWhv5XpCo03nSMvxkIBe9P8tv4Wz1bTgU48NUn+noxz5aTu+G/35SCIeGfQOpWp1FSNFoB0NKOh9P15Uwlhot+gEA7XsxkCPpn4da8fs3rjcLhLCiZqUo1Anwitx3hMtViXqkR/QAlaEErIYqjLdIj15xfIND5JmveP7WveHotboprlblyMOqSDHc2B9L24RrlKNiZNS3W8Mr8qLh8S7kFqH9ixCPQRj+kfLrs/SWEbTY8tU/uTulHDA=" + KUBELESS_VERSION: 0.1.0 + secure: "s+L8ndj0uMNwqbLvbHePHeMJw2LI8DdEdcq1vJ98hNwHOWQc2mHVB4utG9EZFkaL+RAZYduldSJqr443d2BugxrkmzhLUlM5vDks+zHeKecwTah2uuaMUXVT/y/cWDDTVp3phqSqWbHBMG6u0ImvTVWHpnkux55S3QJTHevvhdodpO6VDTsJCEB3e1d2hHxi0L9tJrFXzQRpooV8IUuODwKBJyhK4CD7rvu0D1gBgHaUNnNLrCy4YTaFl19q5NdZUtrQDC7rpSPOhFI9CBFX8GiFq6nY3XzFASwq/JtKc3K7OLIC7Wqb6JpuvFhG6S1yhBzp73pnoE9U0Bi+YMa3L+nPoh58dCB2ldNCCCMbx7R6PWq/TwYzLvgZZ7queC2kbvCTrtU6JJfmb0CxmX1fnUIpCsNeyXaPuo4Ly6WJeAID32z79CwMo9NH0uOVTLy3LTrLcEfELhBRL5+WkMvKmXUt8yN/jEIa/H38pQN5Y/AnJ0KznO8RZ2nLhi1cR+xUkxfPVZ22Wr2XkbzJDZih/mZR+5GQBfUHWgpUChK+e8dOhplk+4PZJEO6Myja7ykXBPYtL9CV/Xi+1nQqLmfhyChiES201KusJr1IrFklslzCzgrSH8Dv2yaYUTe/Ub/I3gWIhKOXY66gkpmB6MSBJUfMK3uR4/wYfCvbtBTugsY=" install: - ./scripts/install-test-environment.sh - npm install -g serverless @@ -24,9 +24,9 @@ after_success: fi deploy: provider: npm - email: npm@bitnami.com + email: kubernetes@bitnami.com api_key: - secure: "rgqKaazC2RPDx4BJobB/XZcpClX7H4XZeZb2MHB6GYoibzf1EqDdHK3eGX2MwbtN9I2xMAn6h88gjbPSvPZrxIWQAfrrbwzPzOtteFfiRWWzlQpuNEuLTs3pAHpsYfrbJGMBBMLVq2X0+i1NGrEIlQfRfQvCBkV1xdCO0nRxheKhoikWCAVkd8MXDmmTre9+Uxk44MjjSKpn3eqM/IDMHDUoisLFnw4lsbM80TjMHNagQozBeoGQwLK81+0ZbFhW9qCSw8GeSznqJdkeJzz3iIYQs9JMqBv9VpLADTpPgUdbMvvtKhL5nGaJVDQCmLjVxmo9lZDNfrCjVq5zARt6s688tUqXZmC+pqJXPVqCTcs5UgcOUgU2hZejv0croE55lMNcCKTaICBg9MVBLUNEYXZVOKArAl9uvRc/FNOnnv7PVHMYC0iHBQADuIgskOBCboV6kC2EBH0h2mZdm4Y2hoFOD/ZEwfDtfWlrakKxPsD3zbDPhS31CjOQwp1UJqbj94w9ztXiqEI5B/Oo7OEpQ72aHbtlysQPKaa2BAyzxICJzB17otJjP7pcj3lmwiU3scIJjbzCAzPRKByQmyjGhHLZItJRMn6CMWY/EeodZXRrqej6ToTLNyzSt8c7r9xl8W9ViyRJxFbElYkZ/OLgLwc3sD1sB0vVvWfoM9xyzQI=" + secure: "jn9tA4DES1n4uxhD+rb7pbzux523AULAgv1f5umqAzvw9bCz7mD6nLS7fo1W8RZSPND7aPM+X5hPknyHm1L+tZbOInKNtCwFkKW2IELJ6a2OCQ+zXN/S/Cxu4dsfeDjE0kiAu5a3YejE5xEjkb98j4eC8i2N4gmdPvDLNqyMXH+W8jF/T2ivkxUGxYOMzyffmsfKmHQ2H31VZEDckcQIENUfLJuxeiBPyrppBKEOgQjpAXiAALnBUrLt741xxL7iQRDHUj8v1cmiymrERhcVpWmYvU4BonlcvPnuWK2dLglQAO+t1UoY5nXS23Lc24yXA8XMp/Bv/dHEB4WwQBNZ4vq+ImGqjFI7/HJlYpHa8eVe6rZJxNnmvBAa3HbTwTz0hoaGwAmHMqPtwelYwL92hEUV/lXQoial9WXSwIqrt24J4Q8UH7jZK3uY3LnCZggDTShSyTvzVp5Xjw/vN0xo5CDlXJ8FZpFkVUWOp7ISYEynzOlW8OZynRiboXyAgLfFMDglhDkcLCpkQLKfKSa0vZWmhgHgNsxs44cFb7pElciQ2uYQjFldXjU/4qVN65s58t4Sn69nFpSthSQKa5iwYMXbI792onVBO334pBdUFBagzP3e4Th4y2k1pFZTZ5UV5gs/2/ROK1KsM5XCi7px4Ddw1kMY4Q6PHZBaTLblqU4=" on: tags: true repo: serverless/serverless-kubeless diff --git a/scripts/release.sh b/scripts/release.sh index ec9fc57..25f948c 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -36,7 +36,7 @@ function release_tag { version=`get_version` -if [[ -z $REPO_NAME ]]; then +if [[ -z "$REPO_NAME" || -z "$REPO_DOMAIN" ]]; then echo "Github repository not specified" > /dev/stderr exit 1 fi From 0757404144bcf0acf7171a7f167c44013d94b075 Mon Sep 17 00:00:00 2001 From: Andres Date: Tue, 5 Sep 2017 11:36:13 +0200 Subject: [PATCH 3/7] Restore env value --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 40bbdc6..62b1e21 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ services: - docker env: global: - KUBELESS_VERSION: 0.1.0 + - KUBELESS_VERSION: 0.1.0 secure: "s+L8ndj0uMNwqbLvbHePHeMJw2LI8DdEdcq1vJ98hNwHOWQc2mHVB4utG9EZFkaL+RAZYduldSJqr443d2BugxrkmzhLUlM5vDks+zHeKecwTah2uuaMUXVT/y/cWDDTVp3phqSqWbHBMG6u0ImvTVWHpnkux55S3QJTHevvhdodpO6VDTsJCEB3e1d2hHxi0L9tJrFXzQRpooV8IUuODwKBJyhK4CD7rvu0D1gBgHaUNnNLrCy4YTaFl19q5NdZUtrQDC7rpSPOhFI9CBFX8GiFq6nY3XzFASwq/JtKc3K7OLIC7Wqb6JpuvFhG6S1yhBzp73pnoE9U0Bi+YMa3L+nPoh58dCB2ldNCCCMbx7R6PWq/TwYzLvgZZ7queC2kbvCTrtU6JJfmb0CxmX1fnUIpCsNeyXaPuo4Ly6WJeAID32z79CwMo9NH0uOVTLy3LTrLcEfELhBRL5+WkMvKmXUt8yN/jEIa/H38pQN5Y/AnJ0KznO8RZ2nLhi1cR+xUkxfPVZ22Wr2XkbzJDZih/mZR+5GQBfUHWgpUChK+e8dOhplk+4PZJEO6Myja7ykXBPYtL9CV/Xi+1nQqLmfhyChiES201KusJr1IrFklslzCzgrSH8Dv2yaYUTe/Ub/I3gWIhKOXY66gkpmB6MSBJUfMK3uR4/wYfCvbtBTugsY=" install: - ./scripts/install-test-environment.sh From 772b3e6fbdea73a8d0254dbff0bc8c5cd4a44f14 Mon Sep 17 00:00:00 2001 From: Andres Date: Tue, 5 Sep 2017 11:39:10 +0200 Subject: [PATCH 4/7] Fix syntax --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 62b1e21..be9b40f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ services: env: global: - KUBELESS_VERSION: 0.1.0 - secure: "s+L8ndj0uMNwqbLvbHePHeMJw2LI8DdEdcq1vJ98hNwHOWQc2mHVB4utG9EZFkaL+RAZYduldSJqr443d2BugxrkmzhLUlM5vDks+zHeKecwTah2uuaMUXVT/y/cWDDTVp3phqSqWbHBMG6u0ImvTVWHpnkux55S3QJTHevvhdodpO6VDTsJCEB3e1d2hHxi0L9tJrFXzQRpooV8IUuODwKBJyhK4CD7rvu0D1gBgHaUNnNLrCy4YTaFl19q5NdZUtrQDC7rpSPOhFI9CBFX8GiFq6nY3XzFASwq/JtKc3K7OLIC7Wqb6JpuvFhG6S1yhBzp73pnoE9U0Bi+YMa3L+nPoh58dCB2ldNCCCMbx7R6PWq/TwYzLvgZZ7queC2kbvCTrtU6JJfmb0CxmX1fnUIpCsNeyXaPuo4Ly6WJeAID32z79CwMo9NH0uOVTLy3LTrLcEfELhBRL5+WkMvKmXUt8yN/jEIa/H38pQN5Y/AnJ0KznO8RZ2nLhi1cR+xUkxfPVZ22Wr2XkbzJDZih/mZR+5GQBfUHWgpUChK+e8dOhplk+4PZJEO6Myja7ykXBPYtL9CV/Xi+1nQqLmfhyChiES201KusJr1IrFklslzCzgrSH8Dv2yaYUTe/Ub/I3gWIhKOXY66gkpmB6MSBJUfMK3uR4/wYfCvbtBTugsY=" + - secure: "s+L8ndj0uMNwqbLvbHePHeMJw2LI8DdEdcq1vJ98hNwHOWQc2mHVB4utG9EZFkaL+RAZYduldSJqr443d2BugxrkmzhLUlM5vDks+zHeKecwTah2uuaMUXVT/y/cWDDTVp3phqSqWbHBMG6u0ImvTVWHpnkux55S3QJTHevvhdodpO6VDTsJCEB3e1d2hHxi0L9tJrFXzQRpooV8IUuODwKBJyhK4CD7rvu0D1gBgHaUNnNLrCy4YTaFl19q5NdZUtrQDC7rpSPOhFI9CBFX8GiFq6nY3XzFASwq/JtKc3K7OLIC7Wqb6JpuvFhG6S1yhBzp73pnoE9U0Bi+YMa3L+nPoh58dCB2ldNCCCMbx7R6PWq/TwYzLvgZZ7queC2kbvCTrtU6JJfmb0CxmX1fnUIpCsNeyXaPuo4Ly6WJeAID32z79CwMo9NH0uOVTLy3LTrLcEfELhBRL5+WkMvKmXUt8yN/jEIa/H38pQN5Y/AnJ0KznO8RZ2nLhi1cR+xUkxfPVZ22Wr2XkbzJDZih/mZR+5GQBfUHWgpUChK+e8dOhplk+4PZJEO6Myja7ykXBPYtL9CV/Xi+1nQqLmfhyChiES201KusJr1IrFklslzCzgrSH8Dv2yaYUTe/Ub/I3gWIhKOXY66gkpmB6MSBJUfMK3uR4/wYfCvbtBTugsY=" install: - ./scripts/install-test-environment.sh - npm install -g serverless From 5f503d88128a1dd62271e0265b3d72fc02a0e384 Mon Sep 17 00:00:00 2001 From: Andres Date: Tue, 5 Sep 2017 11:53:54 +0200 Subject: [PATCH 5/7] Skip release if the current origin is not the goal --- scripts/release.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/release.sh b/scripts/release.sh index 25f948c..50e848e 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -41,6 +41,12 @@ if [[ -z "$REPO_NAME" || -z "$REPO_DOMAIN" ]]; then exit 1 fi +origin=`git config --get remote.origin.url` +if [[ "$origin" != "https://github.com/$REPO_DOMAIN/$REPO_NAME" ]]; then + echo "The current origin is not the goal of the relase. Skipping..." + exit 0 +fi + repo_check=`curl -s https://api.github.com/repos/$REPO_DOMAIN/$REPO_NAME` if [[ $repo_check == *"Not Found"* ]]; then echo "Not found a Github repository for $REPO_DOMAIN/$REPO_NAME, it is not possible to publish it" > /dev/stderr From aade28172ad0ad57f448dbb5d8a7b7e686e5e214 Mon Sep 17 00:00:00 2001 From: Andres Date: Tue, 5 Sep 2017 15:18:00 +0200 Subject: [PATCH 6/7] Apply review --- .travis.yml | 7 +++++-- scripts/release.sh | 10 ---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index be9b40f..5eae9c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,8 @@ services: env: global: - KUBELESS_VERSION: 0.1.0 + - REPO_DOMAIN: serverless + - REPO_NAME: serverless-kubeless - secure: "s+L8ndj0uMNwqbLvbHePHeMJw2LI8DdEdcq1vJ98hNwHOWQc2mHVB4utG9EZFkaL+RAZYduldSJqr443d2BugxrkmzhLUlM5vDks+zHeKecwTah2uuaMUXVT/y/cWDDTVp3phqSqWbHBMG6u0ImvTVWHpnkux55S3QJTHevvhdodpO6VDTsJCEB3e1d2hHxi0L9tJrFXzQRpooV8IUuODwKBJyhK4CD7rvu0D1gBgHaUNnNLrCy4YTaFl19q5NdZUtrQDC7rpSPOhFI9CBFX8GiFq6nY3XzFASwq/JtKc3K7OLIC7Wqb6JpuvFhG6S1yhBzp73pnoE9U0Bi+YMa3L+nPoh58dCB2ldNCCCMbx7R6PWq/TwYzLvgZZ7queC2kbvCTrtU6JJfmb0CxmX1fnUIpCsNeyXaPuo4Ly6WJeAID32z79CwMo9NH0uOVTLy3LTrLcEfELhBRL5+WkMvKmXUt8yN/jEIa/H38pQN5Y/AnJ0KznO8RZ2nLhi1cR+xUkxfPVZ22Wr2XkbzJDZih/mZR+5GQBfUHWgpUChK+e8dOhplk+4PZJEO6Myja7ykXBPYtL9CV/Xi+1nQqLmfhyChiES201KusJr1IrFklslzCzgrSH8Dv2yaYUTe/Ub/I3gWIhKOXY66gkpmB6MSBJUfMK3uR4/wYfCvbtBTugsY=" install: - ./scripts/install-test-environment.sh @@ -19,8 +21,9 @@ install: after_success: - | if [[ "$TRAVIS_BRANCH" == master && \ - "$TRAVIS_PULL_REQUEST" == false ]]; then - REPO_DOMAIN=serverless REPO_NAME=serverless-kubeless ./scripts/release.sh + "$TRAVIS_PULL_REQUEST" == false && \ + "$TRAVIS_REPO_SLUG" == "$REPO_DOMAIN/$REPO_NAME" ]]; then + ./scripts/release.sh fi deploy: provider: npm diff --git a/scripts/release.sh b/scripts/release.sh index 50e848e..838e599 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -17,10 +17,6 @@ function release_tag { git fetch --tags local last_tag=`curl -s https://api.github.com/repos/$REPO_DOMAIN/$REPO_NAME/tags | jq --raw-output '.[0].name'` local release_notes=`git log $last_tag..HEAD --oneline` - # Parse relase notes like an list (e.g): - # - 12345abcd Merge pull request #1 Title - # - 12345efgh commit included 1 - # - 12345hijk commit included 2 local parsed_release_notes=$(echo "$release_notes" | sed -n -e 'H;${x;s/\n/\\n - /g;s/^\\n//;p;}') parsed_release_notes=`echo "$parsed_release_notes" | sed -e '${s/ \( - [^ ]* Merge pull request\)/\1/g;}'` release=`curl -H "Authorization: token $ACCESS_TOKEN" -s --data "{ @@ -41,12 +37,6 @@ if [[ -z "$REPO_NAME" || -z "$REPO_DOMAIN" ]]; then exit 1 fi -origin=`git config --get remote.origin.url` -if [[ "$origin" != "https://github.com/$REPO_DOMAIN/$REPO_NAME" ]]; then - echo "The current origin is not the goal of the relase. Skipping..." - exit 0 -fi - repo_check=`curl -s https://api.github.com/repos/$REPO_DOMAIN/$REPO_NAME` if [[ $repo_check == *"Not Found"* ]]; then echo "Not found a Github repository for $REPO_DOMAIN/$REPO_NAME, it is not possible to publish it" > /dev/stderr From b06a4e5cecd1938f0186b1ef07a636ef6d1ae330 Mon Sep 17 00:00:00 2001 From: Andres Date: Tue, 5 Sep 2017 15:47:39 +0200 Subject: [PATCH 7/7] Check token instead of repo domain and ID --- .travis.yml | 2 +- scripts/release.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5eae9c4..c7124e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ after_success: - | if [[ "$TRAVIS_BRANCH" == master && \ "$TRAVIS_PULL_REQUEST" == false && \ - "$TRAVIS_REPO_SLUG" == "$REPO_DOMAIN/$REPO_NAME" ]]; then + -n "$ACCESS_TOKEN" ]]; then ./scripts/release.sh fi deploy: diff --git a/scripts/release.sh b/scripts/release.sh index 838e599..14b47d1 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -37,6 +37,11 @@ if [[ -z "$REPO_NAME" || -z "$REPO_DOMAIN" ]]; then exit 1 fi +if [[ -n "$ACCESS_TOKEN" ]]; then + echo "Unable to release: Github Token not specified" > /dev/stderr + exit 1 +fi + repo_check=`curl -s https://api.github.com/repos/$REPO_DOMAIN/$REPO_NAME` if [[ $repo_check == *"Not Found"* ]]; then echo "Not found a Github repository for $REPO_DOMAIN/$REPO_NAME, it is not possible to publish it" > /dev/stderr