mirror of
https://github.com/octoleo/restic.git
synced 2024-11-21 20:35:12 +00:00
helpers: Use version string in built binaries
This commit is contained in:
parent
c5ec4efe91
commit
a5b40e9372
@ -17,12 +17,14 @@ var opts = struct {
|
||||
Verbose bool
|
||||
SourceDir string
|
||||
OutputDir string
|
||||
Version string
|
||||
}{}
|
||||
|
||||
func init() {
|
||||
pflag.BoolVarP(&opts.Verbose, "verbose", "v", false, "be verbose")
|
||||
pflag.StringVarP(&opts.SourceDir, "source", "s", "/restic", "path to the source code `directory`")
|
||||
pflag.StringVarP(&opts.OutputDir, "output", "o", "/output", "path to the output `directory`")
|
||||
pflag.StringVar(&opts.Version, "version", "", "use `x.y.z` as the version for output files")
|
||||
pflag.Parse()
|
||||
}
|
||||
|
||||
@ -108,6 +110,11 @@ func abs(dir string) string {
|
||||
|
||||
func build(sourceDir, outputDir, goos, goarch string) (filename string) {
|
||||
filename = fmt.Sprintf("%v_%v_%v", "restic", goos, goarch)
|
||||
|
||||
if opts.Version != "" {
|
||||
filename = fmt.Sprintf("%v_%v_%v_%v", "restic", opts.Version, goos, goarch)
|
||||
}
|
||||
|
||||
if goos == "windows" {
|
||||
filename += ".exe"
|
||||
}
|
||||
|
@ -339,12 +339,14 @@ func extractTar(filename, outputDir string) {
|
||||
}
|
||||
}
|
||||
|
||||
func runBuild(sourceDir, outputDir string) {
|
||||
func runBuild(sourceDir, outputDir, version string) {
|
||||
msg("building binaries...")
|
||||
run("docker", "run", "--rm",
|
||||
"--volume", sourceDir+":/restic",
|
||||
"--volume", outputDir+":/output",
|
||||
"restic/builder")
|
||||
"restic/builder",
|
||||
"go", "run", "-mod=vendor", "helpers/build-release-binaries/main.go",
|
||||
"--version", version)
|
||||
}
|
||||
|
||||
func readdir(dir string) []string {
|
||||
@ -443,7 +445,7 @@ func main() {
|
||||
exportTar(opts.Version, tarFilename)
|
||||
|
||||
extractTar(tarFilename, sourceDir)
|
||||
runBuild(sourceDir, opts.OutputDir)
|
||||
runBuild(sourceDir, opts.OutputDir, opts.Version)
|
||||
rmdir(sourceDir)
|
||||
|
||||
sha256sums(opts.OutputDir, filepath.Join(opts.OutputDir, "SHA256SUMS"))
|
||||
|
Loading…
Reference in New Issue
Block a user