diff --git a/.travis.yml b/.travis.yml index 283baf89..09c393d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,8 @@ services: - mongodb env: - - VERSION=0.18 + global: + - VERSION=0.18 matrix: allow_failures: diff --git a/build.sh b/build.sh index 281f27c1..d13507c4 100755 --- a/build.sh +++ b/build.sh @@ -1,17 +1,21 @@ #!/usr/bin/env bash - -mkdir build - APP="statup" +printf "\nUPDATE core SET version='$VERSION';" >> sql/upgrade.sql + rice embed-go +docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS +docker build -f Dockerfile -t hunterlong/statup:$VERSION . +docker tag hunterlong/statup:$VERSION hunterlong/statup:latest +docker tag hunterlong/statup:$VERSION hunterlong/statup:$VERSION +docker push hunterlong/statup + +mkdir build xgo -go 1.10.x --targets=darwin/amd64 --dest=build -ldflags="-X main.VERSION=$VERSION" ./ xgo -go 1.10.x --targets=darwin/386 --dest=build -ldflags="-X main.VERSION=$VERSION" ./ - xgo -go 1.10.x --targets=linux/amd64 --dest=build -ldflags="-X main.VERSION=$VERSION" ./ xgo -go 1.10.x --targets=linux/386 --dest=build -ldflags="-X main.VERSION=$VERSION" ./ - xgo -go 1.10.x --targets=windows/amd64 --dest=build -ldflags="-X main.VERSION=$VERSION" ./ cd build diff --git a/communication.go b/communication.go index 0817f311..bf694a38 100644 --- a/communication.go +++ b/communication.go @@ -1,16 +1,16 @@ package main import ( - "fmt" "github.com/hunterlong/statup/types" "time" ) func LoadDefaultCommunications() { emailer := SelectCommunication(1) - fmt.Println(emailer) - LoadMailer(emailer) - go EmailerQueue() + if emailer.Enabled { + LoadMailer(emailer) + go EmailerQueue() + } } func LoadComms() { diff --git a/main.go b/main.go index 5a846b42..b11c8a94 100644 --- a/main.go +++ b/main.go @@ -147,6 +147,7 @@ func mainProcess() { if err != nil { throw(err) } + RunDatabaseUpgrades() core, err = SelectCore() if err != nil { fmt.Println("Core database was not found, Statup is not setup yet.") diff --git a/setup.go b/setup.go index ac8c4c16..507d3069 100644 --- a/setup.go +++ b/setup.go @@ -10,6 +10,7 @@ import ( "strconv" "strings" "time" + "upper.io/db.v3" ) type DbConfig struct { @@ -28,6 +29,19 @@ type DbConfig struct { Error error `yaml:"-"` } +func RunDatabaseUpgrades() { + fmt.Println("Upgrading Tables...") + upgrade, _ := sqlBox.String("upgrade.sql") + requests := strings.Split(upgrade, ";") + for _, request := range requests { + _, err := dbSession.Exec(db.Raw(request + ";")) + if err != nil { + fmt.Println(err) + } + } + fmt.Println("Database Upgraded") +} + func ProcessSetupHandler(w http.ResponseWriter, r *http.Request) { if core != nil { http.Redirect(w, r, "/", http.StatusSeeOther)