release.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "log"
  6. "os"
  7. "os/exec"
  8. "strings"
  9. )
  10. func main() {
  11. docker := flag.Bool("docker", false, "create a docker release")
  12. flag.Parse()
  13. version := os.Getenv("VERSION")
  14. sha := os.Getenv("GITHUB_SHA")
  15. if version == "" {
  16. cmd := exec.Command("git", "show", "--no-patch", "--no-notes", "--pretty=%ci", sha)
  17. out, err := cmd.CombinedOutput()
  18. if err != nil {
  19. log.Println(strings.TrimSpace(string(out)))
  20. log.Fatal(err)
  21. }
  22. var date string
  23. parts := strings.Split(string(out), " ")
  24. date = strings.Replace(parts[0]+parts[1], "-", "", -1)
  25. date = strings.Replace(date, ":", "", -1)
  26. version = fmt.Sprintf("v0.0.0-%s-%s", date, sha[:12])
  27. }
  28. if *docker {
  29. x := "-extldflags \"-static\" -X github.com/sqlc-dev/sqlc/internal/cmd.version=" + version
  30. args := []string{
  31. "build",
  32. "-a",
  33. "-ldflags", x,
  34. "-o", "/workspace/sqlc",
  35. "./cmd/sqlc",
  36. }
  37. cmd := exec.Command("go", args...)
  38. cmd.Env = os.Environ()
  39. out, err := cmd.CombinedOutput()
  40. if err != nil {
  41. log.Println(strings.TrimSpace(string(out)))
  42. log.Fatal(err)
  43. }
  44. return
  45. }
  46. arch := flag.Arg(0)
  47. if arch == "" {
  48. log.Fatalf("missing platform_arch argument")
  49. }
  50. log.Fatal("publishing to Equinox has been disabled")
  51. }