Skip to content

Commit

Permalink
improved versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Акулов Александр Яковлевич committed Mar 12, 2019
1 parent 5b92f78 commit 40d778e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
services:
- docker
script:
- go build -o clickhouse-backup/clickhouse-backup
- go build -ldflags "-X main.version=${TRAVIS_TAG} -X main.gitCommit=${TRAVIS_COMMIT} -X main.buildDate=$(date --iso-8601)" -o clickhouse-backup/clickhouse-backup
- ./clickhouse-backup/clickhouse-backup default-config > clickhouse-backup/config.yml
- docker-compose -f integration-test/docker-compose-travis.yml up -d --force-recreate
- go test -tags integration
Expand All @@ -19,6 +19,5 @@ deploy:
file: clickhouse-backup.tar.gz
skip_cleanup: true
overwrite: true

on:
tags: true
2 changes: 1 addition & 1 deletion integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -e

docker-compose -f integration-test/docker-compose.yml up -d --force-recreate
go test -tags integration
# docker-compose -f integration-test/docker-compose.yml down
# docker-compose -f integration-test/docker-compose.yml down
20 changes: 14 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ import (
"github.com/urfave/cli"
)

var config *Config
var (
config *Config
version = "unknown"
gitCommit = "unknown"
buildDate = "unknown"
)

func main() {
cliapp := cli.NewApp()
cliapp.Name = "clickhouse-backup"
cliapp.Usage = "Backup ClickHouse to s3"
cliapp.Version = "0.0.2"
cliapp.Version = version

cliapp.Flags = []cli.Flag{
cli.StringFlag{
Name: "config, c",
Expand All @@ -37,7 +43,9 @@ func main() {
}

cli.VersionPrinter = func(c *cli.Context) {
fmt.Println(c.App.Version)
fmt.Println("Version:\t", c.App.Version)
fmt.Println("Git Commit:\t", gitCommit)
fmt.Println("Build Date:\t", buildDate)
}

cliapp.Before = func(c *cli.Context) error {
Expand Down Expand Up @@ -236,7 +244,8 @@ func createTables(config Config, args []string, dryRun bool) error {
databaseName := file.Name()
if databaseName == "system" {
// do not touch system database
continue }
continue
}
log.Printf("Found metadata files for database: %s", databaseName)
ch.CreateDatabase(databaseName)
databaseDir := path.Join(metadataPath, databaseName)
Expand Down Expand Up @@ -325,8 +334,7 @@ func freeze(config Config, args []string, dryRun bool) error {
return nil
}
for _, table := range backupTables {
err := ch.FreezeTable(table)
if err != nil {
if err := ch.FreezeTable(table); err != nil {
return err
}
}
Expand Down

0 comments on commit 40d778e

Please sign in to comment.