fix: reduce disk usage during release

Co-authored-by: Ludovic Fernandez <ldez@users.noreply.github.com>
This commit is contained in:
Michael 2023-08-04 12:26:05 +02:00 committed by GitHub
parent f518676238
commit 1ddb0afb24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 8 deletions

View file

@ -0,0 +1,41 @@
package main
import (
"fmt"
"log"
"os"
"path"
"strings"
"text/template"
)
func main() {
if len(os.Args) < 2 {
log.Fatal("GOOS should be provided as a CLI argument")
}
goos := strings.TrimSpace(os.Args[1])
if goos == "" {
log.Fatal("GOOS should be provided as a CLI argument")
}
tmpl := template.Must(
template.New(".goreleaser.yml.tmpl").
Delims("[[", "]]").
ParseFiles("./.goreleaser.yml.tmpl"),
)
outputPath := path.Join(os.TempDir(), fmt.Sprintf(".goreleaser_%s.yml", goos))
output, err := os.Create(outputPath)
if err != nil {
log.Fatal(err)
}
err = tmpl.Execute(output, map[string]string{"GOOS": goos})
if err != nil {
log.Fatal(err)
}
fmt.Print(outputPath)
}