diff --git a/app/napcomp/napcomp.go b/app/napcomp/napcomp.go index b1413f7..d1a0fa7 100644 --- a/app/napcomp/napcomp.go +++ b/app/napcomp/napcomp.go @@ -6,16 +6,23 @@ package main // in both files. import ( + "flag" + "fmt" "os" "os/signal" "runtime" "syscall" "github.com/nsip/nias2/napcomp" + "github.com/nsip/nias2/version" ) +var vers = flag.Bool("version", false, "Reports version of NIAS distribution") + func main() { + flag.Parse() + // shutdown handler c := make(chan os.Signal, 2) signal.Notify(c, os.Interrupt, syscall.SIGTERM) @@ -25,6 +32,11 @@ func main() { os.Exit(1) }() + if *vers { + fmt.Printf("NIAS: Version %s\n", version.TagName) + os.Exit(1) + } + napcomp.IngestData() napcomp.WriteReports() // shut down diff --git a/app/naprrql/naprrql.go b/app/naprrql/naprrql.go index e43fb8c..978fbf1 100644 --- a/app/naprrql/naprrql.go +++ b/app/naprrql/naprrql.go @@ -15,6 +15,7 @@ import ( "syscall" "github.com/nsip/nias2/naprrql" + "github.com/nsip/nias2/version" ) var ingest = flag.Bool("ingest", false, "Loads data from results file. Exisitng data is overwritten.") @@ -23,6 +24,7 @@ var report = flag.Bool("report", false, "Creates .csv reports. Existing reports // var isrprint = flag.Bool("isrprint", false, "Creates .csv files for use in isr printing") // var itemprint = flag.Bool("itemprint", false, "Creates .csv files reporting item results for each student against items") var qa = flag.Bool("qa", false, "Creates .csv files for QA checking of NAPLAN results") +var vers = flag.Bool("version", false, "Reports version of NIAS distribution") func main() { @@ -39,6 +41,11 @@ func main() { os.Exit(1) }() + if *vers { + fmt.Printf("NIAS: Version %s\n", version.TagName) + os.Exit(1) + } + // ingest results data, rebuild reports, and exit to save memory if *ingest { ingestData() diff --git a/app/napval/napval.go b/app/napval/napval.go index f7aa39e..3bc6e12 100644 --- a/app/napval/napval.go +++ b/app/napval/napval.go @@ -2,14 +2,25 @@ package main import ( + "fmt" "github.com/nsip/nias2/lib" "github.com/nsip/nias2/napval" + "github.com/nsip/nias2/version" "log" "runtime" ) +var vers = flag.Bool("version", false, "Reports version of NIAS distribution") + func main() { + flag.Parse() + + if *vers { + fmt.Printf("NIAS: Version %s\n", version.TagName) + os.Exit(1) + } + config := napval.LoadNAPLANConfig() NAPLAN_NATS_CFG := lib.NATSConfig{Port: config.NATSPort} log.Println("NAPVAL: Loading default config") diff --git a/release.sh b/release.sh index 6d516a4..8526369 100755 --- a/release.sh +++ b/release.sh @@ -1,5 +1,7 @@ cd tools; go build release.go; cd .. +./tools/release > version/version.go +sh build.sh ./tools/release nias2 nias-Mac.zip build/nias-Mac.zip ./tools/release nias2 nias-Win64.zip build/nias-Win64.zip ./tools/release nias2 nias-Win32.zip build/nias-Win32.zip diff --git a/tools/release.go b/tools/release.go index d06b5ec..04ff34e 100644 --- a/tools/release.go +++ b/tools/release.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "fmt" "io/ioutil" "log" "net/http" @@ -131,6 +132,7 @@ func uploadFile(release jsonRelease, name string, filename string) jsonUpload { // 1 = Project name // 2 = File name to upload // 3 = Local file path +// If called with just the project name, we generate versioning code func main() { // Load configuration if _, err := toml.DecodeFile(os.Getenv("HOME")+"/.nsip.toml", &cfg); err != nil { @@ -147,5 +149,9 @@ func main() { log.Printf("Received release %d as %s", release.Id, release.TagName) - uploadFile(release, os.Args[2], os.Args[3]) + if len(os.Args) == 2 { + fmt.Printf("package version\nvar(\nId = %d\nTagName = \"%s\"\n)\n", release.Id, release.TagName) + } else { + uploadFile(release, os.Args[2], os.Args[3]) + } } diff --git a/version/version.go b/version/version.go new file mode 100644 index 0000000..687766f --- /dev/null +++ b/version/version.go @@ -0,0 +1,5 @@ +package version +var( +Id = 10054986 +TagName = "0-9-21" +)