diff --git a/main.go b/main.go index 65eae47..f19d71c 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "context" "crypto/sha256" "encoding/hex" + "fmt" "io" "net/http" "os" @@ -394,7 +395,20 @@ func generate(release *github.RepositoryRelease, output string, cnOutput string, } func setActionOutput(name string, content string) { - os.Stdout.WriteString("::set-output name=" + name + "::" + content + "\n") + outputFile := os.Getenv("GITHUB_OUTPUT") + if outputFile == "" { + fmt.Println("GITHUB_OUTPUT not set (not running in GitHub Actions?)") + return + } + f, err := os.OpenFile(outputFile, os.O_APPEND|os.O_WRONLY, 0644) + if err != nil { + panic(err) + } + defer f.Close() + if _, err := fmt.Fprintf(f, "%s=%s\n", name, content); err != nil { + panic(err) + } + fmt.Printf("setActionOutput: %s=%s\n", name, content) } func release(source string, destination string, output string, cnOutput string, ruleSetOutput string, ruleSetOutputUnstable string) error { @@ -416,7 +430,7 @@ func release(source string, destination string, output string, cnOutput string, if err != nil { return err } - setActionOutput("tag", *sourceRelease.Name) + setActionOutput("tag", *sourceRelease.TagName) return nil }