github.com/aneshas/cli@v0.0.0-20180104210444-aec958fa47db/release.sh (about) 1 #!/bin/bash 2 set -ex 3 4 # ensure working dir is clean 5 git status 6 if [[ -z $(git status -s) ]] 7 then 8 echo "tree is clean" 9 else 10 echo "tree is dirty, please commit changes before running this" 11 exit 1 12 fi 13 14 git pull 15 16 version_file="version.go" 17 # Bump version, patch by default - also checks if previous commit message contains `[bump X]`, and if so, bumps the appropriate semver number - https://github.com/treeder/dockers/tree/master/bump 18 docker run --rm -it -v $PWD:/app -w /app treeder/bump --filename $version_file "$(git log -1 --pretty=%B)" 19 version=$(grep -m1 -Eo "[0-9]+\.[0-9]+\.[0-9]+" $version_file) 20 echo "Version: $version" 21 22 #cd lambda 23 #./release.sh 24 #cd .. 25 26 # make dep 27 make release 28 29 tag="$version" 30 git add -u 31 git commit -m "fn CLI: $version release [skip ci]" 32 # todo: might make sense to move this into it's own repo so it can have it's own versioning at some point 33 git tag -f -a $tag -m "version $version" 34 git push 35 git push origin $tag 36 37 # For GitHub 38 url='https://api.github.com/repos/fnproject/cli/releases' 39 output=$(curl -s -u $GH_DEPLOY_USER:$GH_DEPLOY_KEY -d "{\"tag_name\": \"$version\", \"name\": \"$version\"}" $url) 40 upload_url=$(echo "$output" | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["upload_url"]' | sed -E "s/\{.*//") 41 html_url=$(echo "$output" | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["html_url"]') 42 curl --data-binary "@fn_linux" -H "Content-Type: application/octet-stream" -u $GH_DEPLOY_USER:$GH_DEPLOY_KEY $upload_url\?name\=fn_linux >/dev/null 43 curl --data-binary "@fn_mac" -H "Content-Type: application/octet-stream" -u $GH_DEPLOY_USER:$GH_DEPLOY_KEY $upload_url\?name\=fn_mac >/dev/null 44 curl --data-binary "@fn.exe" -H "Content-Type: application/octet-stream" -u $GH_DEPLOY_USER:$GH_DEPLOY_KEY $upload_url\?name\=fn.exe >/dev/null 45 curl --data-binary "@fn_alpine" -H "Content-Type: application/octet-stream" -u $GH_DEPLOY_USER:$GH_DEPLOY_KEY $upload_url\?name\=fn_alpine >/dev/null 46 47 # TODO: Add the download URLS to install.sh. Maybe we should make a template to generate install.sh 48 # TODO: Download URL's are in the output vars above under "url". Eg: "url":"/uploads/9a1848c5ebf2b83f8b055ac0e50e5232/fn.exe" 49 # sed "s/release=.*/release=\"$version\"/g" install.sh > install.sh.tmp 50 # mv install.sh.tmp install.sh 51 # TODO: then git commit and push? Would be nice to do that along with the vrsion git push above 52 53 docker build -t fnproject/fn:latest . 54 docker tag fnproject/fn:latest fnproject/fn:$version 55 docker push fnproject/fn:$version 56 docker push fnproject/fn:latest