-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #483 from twhiston/version_generator
add version code generator
- Loading branch information
Showing
7 changed files
with
68 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ node_modules | |
caddyfile | ||
cli/semaphore_* | ||
*-packr.go | ||
util/version.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// +build ignore | ||
|
||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"text/template" | ||
) | ||
|
||
var versionTmpl = `package util | ||
//The Semaphore build version | ||
var Version = "{{ .VERSION }}" | ||
` | ||
|
||
func main(){ | ||
|
||
if len(os.Args) <= 1 { | ||
log.Fatalln("Must pass in version number") | ||
} | ||
|
||
data := make(map[string]string) | ||
data["VERSION"] = os.Args[1] | ||
|
||
tmpl := template.New("version") | ||
var err error | ||
if tmpl, err = tmpl.Parse(versionTmpl); err != nil { | ||
log.Fatalln(err) | ||
} | ||
|
||
f, err := os.Create("util/version.go") | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
defer func(r *os.File) { | ||
err = r.Close() | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
}(f) | ||
|
||
tmpl.Execute(f, data) | ||
} |