Skip to content

Commit

Permalink
feat: pass next version to pre-release hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
zepatrik committed Jun 19, 2023
1 parent ecc1663 commit 6aa8212
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cmd/dev/release/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"bytes"
"fmt"
"os"
"os/exec"
"regexp"
"strings"

Expand Down Expand Up @@ -140,14 +141,16 @@ Are you sure you want to proceed without creating a pre version first?`, current
for _, h := range cfg.PreReleaseHooks {
parts := strings.Split(h, " ")

var err error
var cmd *exec.Cmd
if len(parts) > 1 {
err = pkg.NewCommand(parts[0], parts[1:]...).Run()
cmd = pkg.NewCommand(parts[0], parts[1:]...)
} else {
err = pkg.NewCommand(parts[0]).Run()
cmd = pkg.NewCommand(parts[0])
}
cmd.Env = append(os.Environ(), "NEXT_VERSION=v"+nextVersion.String())
cmd.Env = append(cmd.Env, "CURRENT_VERSION=v"+currentVersion.String())

if err != nil {
if err := cmd.Run(); err != nil {
pkg.Fatalf("Pre-release hook failed: %s\nAborting release.", err.Error())
}
}
Expand Down

0 comments on commit 6aa8212

Please sign in to comment.