-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
750c8a0
commit 4f10013
Showing
5 changed files
with
59 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
### Versioner | ||
|
||
Before a release run in project root: | ||
|
||
```sh | ||
go run cmd/versioner.go v1.5.1 | ||
``` | ||
|
||
where tag is the next tag to be used. | ||
|
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,5 @@ | ||
// Code generated from versioner.go; DO NOT EDIT. | ||
|
||
package dbsql | ||
|
||
var DriverVersion = "{{.Version}}" |
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,39 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path" | ||
"regexp" | ||
"runtime" | ||
"text/template" | ||
) | ||
|
||
func getTemplateFilePath() string { | ||
_, filename, _, _ := runtime.Caller(0) | ||
dir := path.Dir(filename) | ||
return path.Join(dir, "version.go.tmpl") | ||
} | ||
|
||
func main() { | ||
tag := os.Args[1] // The first argument is the tag | ||
// If the tag is not a valid semantic version, then it is not a release tag | ||
re := regexp.MustCompile(`^v\d+\.\d+\.\d+$`) | ||
if !re.MatchString(tag) { | ||
panic(fmt.Errorf("tag %s is not a valid semantic version", tag)) | ||
} | ||
tmpl, err := template.ParseFiles(getTemplateFilePath()) | ||
if err != nil { | ||
panic(err) | ||
} | ||
f, err := os.Create("version.go") | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer f.Close() | ||
if err := tmpl.Execute(f, map[string]string{ | ||
"Version": string(tag), | ||
}); err != nil { | ||
panic(err) | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.