blob: 5c378c4fb92721a7aaeffc78227c761fdc4b1b19 [file] [log] [blame]
Qi Zhao6d0399e2017-02-23 16:24:39 -08001#!/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
8usage()
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
24NCC_VERSION=${NCC_VERSION:-$1}
25IDENTITY=${IDENTITY:-$2}
26KEY_LOCATION=${KEY_LOCATION:-$3}
27
28if [[ -z $NCC_VERSION ]] || [[ -z $IDENTITY ]] || [[ -z $KEY_LOCATION ]]; then
29 usage
30fi
31
32echo "Preparing release $NCC_VERSION"
33echo " will sign with XCode identity: $IDENTITY"
34echo " will sign with Sparkle key: $KEY_LOCATION"
35
36BINARY_WEBSERVER=${BINARY_WEBSERVER:-named-data.net:binaries/NDN-Control-Center/}
37
38rm -rf build/release
39mkdir build/release
40
41#######################################
42## Build .dmg file with code sign with Apple Developer ID
43
44echo "[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
51cp build/NDN-${NCC_VERSION}.dmg build/release/
52cp 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
67echo "[auto-release] Generate appcast xml file"
68
69./build/Sparkle/bin/generate_appcast "${KEY_LOCATION}" build/release/
70
71cp ndn-control-center.xml build/
72cat <<EOF | python -
73import xml.etree.ElementTree
74cast = xml.etree.ElementTree.parse('build/ndn-control-center.xml')
75item = xml.etree.ElementTree.parse('build/release/ndn-control-center.xml')
76
77ndncxx = open("build/ndn-cxx/VERSION").read()
78nfd = open("build/NFD/VERSION").read()
79tools = open("build/ndn-tools/VERSION").read()
80
81channel = cast.getroot()[0]
82
83for 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
91cast.write('ndn-control-center.xml', encoding="utf-8")
92EOF
93
94cp ndn-control-center.xml build/release/
95
96#######################################
97## Upload dmg & xml & html to https://named-data.net/binaries/NDN-Control-Center/
98
99echo "[auto-release] Publish dmg xml and html file to website server"
100
101pushd build
102pushd release
103ln -s "NDN-${NCC_VERSION}.dmg" NDN.dmg
104ln -s "release-notes-${NCC_VERSION}.html" release-notes.html
105popd
106popd
107
108echo "Ready to upload:"
109echo "rsync -avz build/release/* \"${BINARY_WEBSERVER}\""