github.com/fnproject/cli@v0.0.0-20240508150455-e5d88bd86117/release.sh (about) 1 #!/bin/bash 2 # 3 # Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 # 17 18 set -ex 19 20 # ensure working dir is clean 21 git status 22 if [[ -z $(git status -s) ]] 23 then 24 echo "tree is clean" 25 else 26 echo "tree is dirty, please commit changes before running this" 27 exit 1 28 fi 29 30 git pull 31 32 version_file="config/version.go" 33 # 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 34 docker run --rm -it -v $PWD:/app -w /app treeder/bump --filename $version_file "$(git log -1 --pretty=%B)" 35 version=$(grep -m1 -Eo "[0-9]+\.[0-9]+\.[0-9]+" $version_file) 36 echo "Version: $version" 37 38 #cd lambda 39 #./release.sh 40 #cd .. 41 42 # make dep 43 make release 44 45 tag="$version" 46 git add -u 47 git commit -m "fn CLI: $version release [skip ci]" 48 # todo: might make sense to move this into it's own repo so it can have it's own versioning at some point 49 git tag -f -a $tag -m "version $version" 50 git push 51 git push origin $tag 52 53 # For GitHub 54 url='https://api.github.com/repos/fnproject/cli/releases' 55 output=$(curl -s -u $GH_DEPLOY_USER:$GH_DEPLOY_KEY -d "{\"tag_name\": \"$version\", \"name\": \"$version\"}" $url) 56 upload_url=$(echo "$output" | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["upload_url"]' | sed -E "s/\{.*//") 57 html_url=$(echo "$output" | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["html_url"]') 58 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 59 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 60 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 61 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 62 63 # TODO: Add the download URLS to install.sh. Maybe we should make a template to generate install.sh 64 # TODO: Download URL's are in the output vars above under "url". Eg: "url":"/uploads/9a1848c5ebf2b83f8b055ac0e50e5232/fn.exe" 65 # sed "s/release=.*/release=\"$version\"/g" install.sh > install.sh.tmp 66 # mv install.sh.tmp install.sh 67 # TODO: then git commit and push? Would be nice to do that along with the vrsion git push above 68 69 docker build -t fnproject/fn:latest . 70 docker tag fnproject/fn:latest fnproject/fn:$version 71 docker push fnproject/fn:$version 72 docker push fnproject/fn:latest