diff --git a/helpers/build-release-binaries/main.go b/helpers/build-release-binaries/main.go index 97f023445..f9e25e447 100644 --- a/helpers/build-release-binaries/main.go +++ b/helpers/build-release-binaries/main.go @@ -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" } diff --git a/helpers/prepare-release/main.go b/helpers/prepare-release/main.go index c5dc9b15d..a461c32ff 100644 --- a/helpers/prepare-release/main.go +++ b/helpers/prepare-release/main.go @@ -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"))