Skip to content

Commit

Permalink
Merge pull request #32 from kimw/feature-version
Browse files Browse the repository at this point in the history
Feature auto-gen version
  • Loading branch information
cbeuw committed Apr 11, 2018
2 parents ab9b4de + deb2bd1 commit 7205be0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
default: all

client:
update-version:
./update-version.sh

client: update-version
go get github.com/cbeuw/gotfo
go build -o ./build/gq-client ./cmd/gq-client

server:
server: update-version
go get github.com/cbeuw/gotfo
go build -o ./build/gq-server ./cmd/gq-server

Expand Down
5 changes: 2 additions & 3 deletions cmd/gq-client/gq-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package main

import (
"flag"
"fmt"
"io"
"log"
"net"
Expand Down Expand Up @@ -137,8 +138,6 @@ func initSequence(ssConn net.Conn, sta *gqclient.State) {

}

var version string

func main() {
// Should be 127.0.0.1 to listen to ss-local on this machine
var localHost string
Expand Down Expand Up @@ -171,7 +170,7 @@ func main() {
flag.Parse()

if *askVersion {
log.Println("gq-client version: " + version)
fmt.Printf("gq-client %s\n", version)
return
}

Expand Down
3 changes: 3 additions & 0 deletions cmd/gq-client/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

const version = "master"
5 changes: 2 additions & 3 deletions cmd/gq-server/gq-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package main
import (
"errors"
"flag"
"fmt"
"io"
"log"
"net"
Expand Down Expand Up @@ -207,8 +208,6 @@ func usedRandomCleaner(sta *gqserver.State) {
}
}

var version string

func main() {
// Should be 127.0.0.1 to listen to ss-server on this machine
var localHost string
Expand All @@ -235,7 +234,7 @@ func main() {
flag.Parse()

if *askVersion {
log.Println("gq-server verison: " + version)
fmt.Printf("gq-server %s\n", version)
return
}

Expand Down
3 changes: 3 additions & 0 deletions cmd/gq-server/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

const version = "master"
9 changes: 9 additions & 0 deletions update-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

ver=$(git log -n 1 --pretty=oneline --format=%D | awk -F, '{print $1}' | awk '{print $3}')
if [ "$ver" = "master" ]
then
ver="master ($(git log -n 1 --pretty=oneline --format=%h))"
fi
sed -i "s/^const version = .*$/const version = \"$ver\"/" cmd/gq-server/version.go
sed -i "s/^const version = .*$/const version = \"$ver\"/" cmd/gq-client/version.go

0 comments on commit 7205be0

Please sign in to comment.