Add version reporting to weaver
This commit is contained in:
1 parent
bfc9df4d25
commit
ccf7e9993a
2 files changed
+67
-16
No files matched your search
+48
-7
@@ -1,24 +1,65 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
# Preparation
|
# Preparation
|
||||||
|
|
||||||
## Get the new version number from the most recent tag
|
## Get the new version number from the most recent tag
|
||||||
|
|
||||||
# Sanity checks
|
LATEST_TAG=$(git describe --abbrev=0 --match='v*')
|
||||||
|
VERSION=${LATEST_TAG#v}
|
||||||
|
echo Attempt to build distributables for version $VERSION
|
||||||
|
# NB does not check that this tag is on master
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo == Sanity checks
|
||||||
|
|
||||||
## Check that the version doesn't already exist by looking at github
|
## Check that the version doesn't already exist by looking at github
|
||||||
## releases
|
## releases
|
||||||
|
if curl -sSf https://api.github.com/repos/zettio/weave/releases/$LATEST_TAG 2>/dev/null; then
|
||||||
|
echo Release $LATEST_TAG already exists on GitHub
|
||||||
|
echo https://github.com/zettio/weave/releases/$LATEST_TAG
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
## Clone the repo at the tag and go there
|
||||||
|
RELEASE_DIR=releases/$LATEST_TAG
|
||||||
|
mkdir -p releases
|
||||||
|
git clone -q -b $LATEST_TAG . $RELEASE_DIR
|
||||||
|
cd $RELEASE_DIR
|
||||||
|
|
||||||
## Check that the top changelog entry is this version
|
## Check that the top changelog entry is this version
|
||||||
|
latest_changelog=$(grep -o "Release v.*" -m1 ./CHANGELOG.md)
|
||||||
|
if ! [ `echo "$latest_changelog" | grep -o 'v[^ ]*'` == $LATEST_TAG ]; then
|
||||||
|
echo Latest changelog entry $latest_changelog does not match
|
||||||
|
echo the latest tag $LATEST_TAG
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Build and test
|
echo Sanity checks OK for releasing tag $LATEST_TAG
|
||||||
|
|
||||||
# Clone the repo at the tag, inject the version numbers, build
|
echo
|
||||||
# distributables (library versions?)
|
echo == Build and test
|
||||||
|
|
||||||
# Run tests with the distributables, including version check
|
## Inject the version numbers and build the distributables
|
||||||
|
## (library versions?)
|
||||||
|
|
||||||
|
sed -i "/var version = / c\var version = \"$VERSION\"" weaver/main.go
|
||||||
|
make
|
||||||
|
|
||||||
|
## Run tests with the distributables, including version check
|
||||||
|
v=$(./weaver/weaver --version)
|
||||||
|
if ! [ "$v" == "weaver $VERSION" ]; then
|
||||||
|
echo Version of distributable "$v" does not match tag $LATEST_TAG
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
make tests
|
||||||
|
|
||||||
|
echo Build and tests OK
|
||||||
|
|
||||||
# Publish
|
# Publish
|
||||||
|
|
||||||
# Either leave the distributables in a directory for the dev to
|
## Either leave the distributables in a directory for the dev to
|
||||||
# upload, or upload them automatically?
|
## upload, or upload them automatically?
|
||||||
+19
-9
@@ -18,6 +18,8 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var version = "(unreleased version)"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
log.SetPrefix(weave.Protocol + " ")
|
log.SetPrefix(weave.Protocol + " ")
|
||||||
@@ -32,17 +34,19 @@ func main() {
|
|||||||
runtime.GOMAXPROCS(procs)
|
runtime.GOMAXPROCS(procs)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ifaceName string
|
justVersion bool
|
||||||
routerName string
|
ifaceName string
|
||||||
password string
|
routerName string
|
||||||
wait int
|
password string
|
||||||
debug bool
|
wait int
|
||||||
prof string
|
debug bool
|
||||||
peers []string
|
prof string
|
||||||
connLimit int
|
peers []string
|
||||||
bufSz int
|
connLimit int
|
||||||
|
bufSz int
|
||||||
)
|
)
|
||||||
|
|
||||||
|
flag.BoolVar(&justVersion, "version", false, "print version and exit")
|
||||||
flag.StringVar(&ifaceName, "iface", "", "name of interface to read from")
|
flag.StringVar(&ifaceName, "iface", "", "name of interface to read from")
|
||||||
flag.StringVar(&routerName, "name", "", "name of router (defaults to MAC)")
|
flag.StringVar(&routerName, "name", "", "name of router (defaults to MAC)")
|
||||||
flag.StringVar(&password, "password", "", "network password")
|
flag.StringVar(&password, "password", "", "network password")
|
||||||
@@ -54,6 +58,11 @@ func main() {
|
|||||||
flag.Parse()
|
flag.Parse()
|
||||||
peers = flag.Args()
|
peers = flag.Args()
|
||||||
|
|
||||||
|
if justVersion {
|
||||||
|
io.WriteString(os.Stdout, fmt.Sprintf("weaver %s\n", version))
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
options := make(map[string]string)
|
options := make(map[string]string)
|
||||||
flag.Visit(func(f *flag.Flag) {
|
flag.Visit(func(f *flag.Flag) {
|
||||||
value := f.Value.String()
|
value := f.Value.String()
|
||||||
@@ -127,6 +136,7 @@ func main() {
|
|||||||
|
|
||||||
func handleHttp(router *weave.Router) {
|
func handleHttp(router *weave.Router) {
|
||||||
http.HandleFunc("/status", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/status", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
io.WriteString(w, fmt.Sprintln("weaver version", version))
|
||||||
io.WriteString(w, router.Status())
|
io.WriteString(w, router.Status())
|
||||||
})
|
})
|
||||||
http.HandleFunc("/connect", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/connect", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
Reference in new issue
Block a user