diff --git a/internal/ci/actions/createOrUpdatePR.go b/internal/ci/actions/createOrUpdatePR.go index c58e9ac5b..149ea68c9 100644 --- a/internal/ci/actions/createOrUpdatePR.go +++ b/internal/ci/actions/createOrUpdatePR.go @@ -93,6 +93,7 @@ func GeneratePRFromReports(inputDir string) (*prdescription.Output, *versioning. LintingReportURL: lintingReportURL, ChangesReportURL: changesReportURL, ManualBump: manualBump, + ActionRunURL: environment.GetActionRunURL(environment.GetRepo()), } output, err := prdescription.Generate(input) diff --git a/internal/ci/environment/environment.go b/internal/ci/environment/environment.go index 980939533..346175338 100644 --- a/internal/ci/environment/environment.go +++ b/internal/ci/environment/environment.go @@ -365,6 +365,15 @@ func GetGithubServerURL() string { return os.Getenv("GITHUB_SERVER_URL") } +func GetActionRunURL(repo string) string { + serverURL := os.Getenv("GITHUB_SERVER_URL") + runID := os.Getenv("GITHUB_RUN_ID") + if serverURL == "" || repo == "" || runID == "" { + return "" + } + return fmt.Sprintf("%s/%s/actions/runs/%s", serverURL, repo, runID) +} + func GetGithubOIDCRequestURL() string { return os.Getenv("ACTIONS_ID_TOKEN_REQUEST_URL") } diff --git a/internal/ci/telemetry/telemetry.go b/internal/ci/telemetry/telemetry.go index aafc892ef..e56093472 100644 --- a/internal/ci/telemetry/telemetry.go +++ b/internal/ci/telemetry/telemetry.go @@ -68,8 +68,9 @@ func EnrichEventWithEnvironmentVariables(event *shared.CliEvent) { event.GhActionOrganization = &ghActionOrg repo := strings.TrimPrefix(ghActionRepoOrg, ghActionOrg+"/") event.GhActionRepository = &repo - runLink := fmt.Sprintf("%s/%s/actions/runs/%s", os.Getenv("GITHUB_SERVER_URL"), ghActionRepoOrg, os.Getenv("GITHUB_RUN_ID")) - event.GhActionRunLink = &runLink + if runLink := environment.GetActionRunURL(ghActionRepoOrg); runLink != "" { + event.GhActionRunLink = &runLink + } ghActionVersion := os.Getenv("GH_ACTION_VERSION") if ghActionVersion != "" { diff --git a/internal/prdescription/prdescription.go b/internal/prdescription/prdescription.go index 9895aa92d..1c6e833db 100644 --- a/internal/prdescription/prdescription.go +++ b/internal/prdescription/prdescription.go @@ -31,6 +31,7 @@ type Input struct { // Version information SpeakeasyVersion string `json:"speakeasy_version,omitempty"` ManualBump bool `json:"manual_bump,omitempty"` + ActionRunURL string `json:"action_run_url,omitempty"` // Version report data (from SPEAKEASY_VERSION_REPORT_LOCATION) VersionReport *versioning.MergedVersionReport `json:"version_report,omitempty"` @@ -113,6 +114,16 @@ func buildBody(input Input) string { versionMsg += fmt.Sprintf("\n\nThis PR will stay on the current version until the %s label is removed and/or modified.", bumpType) } else { versionMsg += "\U0001F916 (automated)" // 🤖 + versionMsg += "\n\n> [!TIP]" + switch bumpType { + case versioning.BumpPrerelease: + versionMsg += "\n> To exit [pre-release versioning](https://www.speakeasy.com/docs/sdks/manage/versioning#pre-release-version-bumps), set a new version or run `speakeasy bump graduate`." + case versioning.BumpPatch, versioning.BumpMinor: + versionMsg += "\n> If updates to your OpenAPI document introduce breaking changes, be sure to update the `info.version` field to [trigger the correct version bump](https://www.speakeasy.com/docs/sdks/manage/versioning#openapi-document-changes)." + default: + } + + versionMsg += "\n> Speakeasy supports manual control of SDK versioning through [multiple methods](https://www.speakeasy.com/docs/sdks/manage/versioning#manual-version-bumps)." } body.WriteString(versionMsg + "\n") } @@ -122,9 +133,14 @@ func buildBody(input Input) string { body.WriteString(stripANSICodes(markdownSection)) } - // Footer with CLI version - if !input.SourceGeneration && input.SpeakeasyVersion != "" { - body.WriteString(fmt.Sprintf("\nBased on [Speakeasy CLI](https://github.com/speakeasy-api/speakeasy) %s\n", input.SpeakeasyVersion)) + // Footer + if !input.SourceGeneration { + if input.SpeakeasyVersion != "" { + body.WriteString(fmt.Sprintf("\nBased on [Speakeasy CLI](https://github.com/speakeasy-api/speakeasy) %s\n", input.SpeakeasyVersion)) + } + if input.ActionRunURL != "" { + body.WriteString(fmt.Sprintf("\nLast updated by [Speakeasy workflow](%s)\n", input.ActionRunURL)) + } } return body.String()