From 0be8a7ed6bec64e04eb36d35dc202b7b5c3af132 Mon Sep 17 00:00:00 2001 From: Samuel Chai Date: Sun, 20 Apr 2025 17:23:08 -0400 Subject: [PATCH 1/5] Compatibility --- cmd/execute.go | 22 ++++++++++++++++++++++ cmd/gh.go | 10 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/cmd/execute.go b/cmd/execute.go index ff661a5..9ce0e4f 100644 --- a/cmd/execute.go +++ b/cmd/execute.go @@ -42,6 +42,28 @@ func init() { rootCmd.SetHelpTemplate(generateHelpText()) } +func isGitHubAction() bool { + return os.Getenv("GITHUB_ACTIONS") == "true" +} + +func exportGitHubOutput(key, value string) error { + outputPath := os.Getenv("GITHUB_OUTPUT") + if outputPath == "" { + return fmt.Errorf("GITHUB_OUTPUT not set") + } + + f, err := os.OpenFile(outputPath, os.O_APPEND|os.O_WRONLY, 0644) + if err != nil { + return fmt.Errorf("failed to open GITHUB_OUTPUT file: %w", err) + } + defer func(f *os.File) { + _ = f.Close() + }(f) + + _, err = fmt.Fprintf(f, "%s=%s\n", key, value) + return err +} + func (rn *RunSettings) ExecuteDryRun() { heading := color.New(color.FgCyan, color.Bold).SprintFunc() fmt.Printf("%s\n\n", heading("The following files would be committed:")) diff --git a/cmd/gh.go b/cmd/gh.go index ad4e5ea..e155055 100644 --- a/cmd/gh.go +++ b/cmd/gh.go @@ -11,6 +11,7 @@ import ( "github.com/fatih/color" "net/http" "os" + "strconv" ) func ValidateGitRemote() (*RepoSettings, error) { @@ -231,6 +232,10 @@ func AssociateCommitWithBranch(branch string, commitSha string) error { } } + if isGitHubAction() { + _ = exportGitHubOutput("sha", commitSha) + } + return err } @@ -283,5 +288,10 @@ func CreatePullRequest(baseRef, headRef, title, description string, labels []str link := color.New(color.FgBlue, color.Bold).Sprintf("🔗 Pull Request URL: %s", prResponse.Url) fmt.Println(link) + if isGitHubAction() { + _ = exportGitHubOutput("pr-number", strconv.Itoa(prResponse.Number)) + _ = exportGitHubOutput("branch", headRef) + } + return nil } From f9225618ab4b8b02a39aa66c350be2375677dcaf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 20 Apr 2025 21:24:15 +0000 Subject: [PATCH 2/5] Updating tracked Git version in source code --- cmd/execute.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/execute.go b/cmd/execute.go index 9ce0e4f..d3859ff 100644 --- a/cmd/execute.go +++ b/cmd/execute.go @@ -11,7 +11,7 @@ import ( ) // VERSION number: changed in CI -const VERSION = "v0.1.0" +const VERSION = "v0.0.16" var rootPath string var repo repository.Repository From 3391fa437ae30910697512dbc5b34c9b57f8fb18 Mon Sep 17 00:00:00 2001 From: Samuel Chai Date: Sun, 20 Apr 2025 17:26:40 -0400 Subject: [PATCH 3/5] #minor github action compt --- cmd/gh.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/gh.go b/cmd/gh.go index e155055..14214d2 100644 --- a/cmd/gh.go +++ b/cmd/gh.go @@ -289,8 +289,8 @@ func CreatePullRequest(baseRef, headRef, title, description string, labels []str fmt.Println(link) if isGitHubAction() { - _ = exportGitHubOutput("pr-number", strconv.Itoa(prResponse.Number)) _ = exportGitHubOutput("branch", headRef) + _ = exportGitHubOutput("pr-number", strconv.Itoa(prResponse.Number)) } return nil From 63bb7b0124cf4c5e0e4839d35ef2477fb7e65919 Mon Sep 17 00:00:00 2001 From: Samuel Chai Date: Sun, 20 Apr 2025 17:31:11 -0400 Subject: [PATCH 4/5] #minor --- .github/workflows/push.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index c8f8440..7f62e5a 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -32,6 +32,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} WITH_V: true DEFAULT_BUMP: patch + DEFAULT_BRANCH: ${{ github.ref_name }} + RELEASE_BRANCHES: ${{ github.ref_name }} - uses: cli/gh-extension-precompile@v2.0.0 with: From 2544f5b1a7af45021d4c920def4cc7c0813f5a39 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 20 Apr 2025 21:32:03 +0000 Subject: [PATCH 5/5] Updating tracked Git version in source code --- cmd/execute.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/execute.go b/cmd/execute.go index d3859ff..9ce0e4f 100644 --- a/cmd/execute.go +++ b/cmd/execute.go @@ -11,7 +11,7 @@ import ( ) // VERSION number: changed in CI -const VERSION = "v0.0.16" +const VERSION = "v0.1.0" var rootPath string var repo repository.Repository