Replace custom release script with ReleaseKit launcher

This commit is contained in:
2026-11-23 19:20:27 +00:00
parent 056e89f61a
commit 6347bbc094
6 changed files with 81 additions and 480 deletions

51
releasekit_test.go Normal file
View File

@@ -0,0 +1,51 @@
package scriptorium_test
import (
"errors"
"os"
"os/exec"
"path/filepath"
"runtime"
"testing"
)
func TestReleaseKitLauncher(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("POSIX shell launcher")
}
dir := t.TempDir()
fake := `#!/bin/sh
case "$1 $2" in
'env GOHOSTOS') printf '%s\n' hostos ;;
'env GOHOSTARCH') printf '%s\n' hostarch ;;
*) printf '%s\n' "$GOOS" "$GOARCH" "$@"; exit "$FAKE_STATUS" ;;
esac
`
if err := os.WriteFile(filepath.Join(dir, "go"), []byte(fake), 0755); err != nil {
t.Fatal(err)
}
for _, tc := range []struct {
name string
status string
code int
}{{"success", "0", 0}, {"failure", "23", 23}} {
t.Run(tc.name, func(t *testing.T) {
cmd := exec.Command("sh", "./releasekit", "publish", "value with spaces")
cmd.Env = append(os.Environ(), "PATH="+dir, "GOOS=otheros", "GOARCH=otherarch", "FAKE_STATUS="+tc.status)
output, err := cmd.Output()
if tc.code == 0 && err != nil {
t.Fatal(err)
}
if tc.code != 0 {
var exit *exec.ExitError
if !errors.As(err, &exit) || exit.ExitCode() != tc.code {
t.Fatalf("exit: %v", err)
}
}
want := "hostos\nhostarch\ntool\ngo.maximumdirect.net/releasekit/cmd/releasekit\npublish\nvalue with spaces\n"
if string(output) != want {
t.Fatalf("output = %q, want %q", output, want)
}
})
}
}