Qi Zhao | 6d0399e | 2017-02-23 16:24:39 -0800 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | ####################################### |
| 4 | ## Attention: |
| 5 | ## Please make sure to update your wscript, RELEASE_NOTES.md and intro.md in |
| 6 | ## docs beforehand, and then run this script to auto-release application. |
| 7 | |
| 8 | usage() |
| 9 | { |
| 10 | echo "Usage:" |
| 11 | echo " $0 <VERSION> <IDENTITY> <SPARKLE_KEY>" |
| 12 | echo "" |
| 13 | echo "Options:" |
| 14 | echo " <VERSION>: the version that will be used for this release" |
| 15 | echo " <IDENTITY>: XCode identity (Mac Developer) that will be used for signing the application" |
| 16 | echo " <SPARKLE_KEY>: the path to your Sparkle private key for signing the application" |
| 17 | echo "" |
| 18 | exit |
| 19 | } |
| 20 | |
| 21 | ####################################### |
| 22 | ## Script for automatically release application binary |
| 23 | |
| 24 | NCC_VERSION=${NCC_VERSION:-$1} |
| 25 | IDENTITY=${IDENTITY:-$2} |
| 26 | KEY_LOCATION=${KEY_LOCATION:-$3} |
| 27 | |
| 28 | if [[ -z $NCC_VERSION ]] || [[ -z $IDENTITY ]] || [[ -z $KEY_LOCATION ]]; then |
| 29 | usage |
| 30 | fi |
| 31 | |
| 32 | echo "Preparing release $NCC_VERSION" |
| 33 | echo " will sign with XCode identity: $IDENTITY" |
| 34 | echo " will sign with Sparkle key: $KEY_LOCATION" |
| 35 | |
| 36 | BINARY_WEBSERVER=${BINARY_WEBSERVER:-named-data.net:binaries/NDN-Control-Center/} |
| 37 | |
| 38 | rm -rf build/release |
| 39 | mkdir build/release |
| 40 | |
| 41 | ####################################### |
| 42 | ## Build .dmg file with code sign with Apple Developer ID |
| 43 | |
| 44 | echo "[auto-release] Build .dmg file and sign with Apple Developer ID" |
| 45 | |
| 46 | ./make-osx-bundle.py -r "${NCC_VERSION}" --codesign="${IDENTITY}" |
| 47 | |
| 48 | ####################################### |
| 49 | ## Code sign with Sparkle (private key existed) |
| 50 | |
| 51 | cp build/NDN-${NCC_VERSION}.dmg build/release/ |
| 52 | cp build/release-notes-${NCC_VERSION}.html build/release/ |
| 53 | |
| 54 | ####################################### |
| 55 | ## Code sign with Sparkle (private key needed) |
| 56 | |
| 57 | #OPENSSL="/usr/bin/openssl" |
| 58 | #openssl gendsa <($OPENSSL dsaparam 4096) -out dsa_priv.pem |
| 59 | #chmod 0400 dsa_priv.pem |
| 60 | #openssl dsa -in dsa_priv.pem -pubout -out ndn_sparkle_pub.pem |
| 61 | #mv ndn_sparkle_pub.pem ../res/ |
| 62 | #./bin/sign_update "../NDN-${NCC_VERSION}.dmg" "${KEY_LOCATION}" |
| 63 | |
| 64 | ####################################### |
| 65 | ## Generate appcast xml file |
| 66 | |
| 67 | echo "[auto-release] Generate appcast xml file" |
| 68 | |
| 69 | ./build/Sparkle/bin/generate_appcast "${KEY_LOCATION}" build/release/ |
| 70 | |
| 71 | cp ndn-control-center.xml build/ |
| 72 | cat <<EOF | python - |
| 73 | import xml.etree.ElementTree |
| 74 | cast = xml.etree.ElementTree.parse('build/ndn-control-center.xml') |
| 75 | item = xml.etree.ElementTree.parse('build/release/ndn-control-center.xml') |
| 76 | |
| 77 | ndncxx = open("build/ndn-cxx/VERSION").read() |
| 78 | nfd = open("build/NFD/VERSION").read() |
| 79 | tools = open("build/ndn-tools/VERSION").read() |
| 80 | |
| 81 | channel = cast.getroot()[0] |
| 82 | |
| 83 | for item in item.getroot().findall('./channel/item'): |
| 84 | ncc = item.findall('.//title')[0].text |
| 85 | item.findall('.//title')[0].text = "Version %s (ndn-cxx version %s, NFD version %s, ndn-tools version %s)" % (ncc, ndncxx, nfd, tools) |
| 86 | notes = xml.etree.ElementTree.Element('ns0:releaseNotesLink') |
| 87 | notes.text = 'https://named-data.net/binaries/NDN-Control-Center/release-notes-%s.html' % ncc |
| 88 | item.append(notes) |
| 89 | channel.append(item) |
| 90 | |
| 91 | cast.write('ndn-control-center.xml', encoding="utf-8") |
| 92 | EOF |
| 93 | |
| 94 | cp ndn-control-center.xml build/release/ |
| 95 | |
| 96 | ####################################### |
| 97 | ## Upload dmg & xml & html to https://named-data.net/binaries/NDN-Control-Center/ |
| 98 | |
| 99 | echo "[auto-release] Publish dmg xml and html file to website server" |
| 100 | |
| 101 | pushd build |
| 102 | pushd release |
| 103 | ln -s "NDN-${NCC_VERSION}.dmg" NDN.dmg |
| 104 | ln -s "release-notes-${NCC_VERSION}.html" release-notes.html |
| 105 | popd |
| 106 | popd |
| 107 | |
| 108 | echo "Ready to upload:" |
| 109 | echo "rsync -avz build/release/* \"${BINARY_WEBSERVER}\"" |