Skip to content

Conversation

@YaRissi
Copy link
Contributor

@YaRissi YaRissi commented Oct 20, 2025

Changes

  • Goreleaser injects on build the correct version to the builds
  • New Job updates the version in the checker.go file -> needed for users that use go install feat: installable via go #31 otherwise there still would be the old version

Why

Simplify the release process, less manual steps

Summary by CodeRabbit

  • Chores

    • Automated version-bump step added to the release workflow to keep release branches in sync and remove the manual bump step.
    • Build process now embeds the release tag into the CLI binary for accurate reporting.
  • Documentation

    • Release guide reorganized and updated to reflect the automated release flow and embedded version metadata.
  • User-facing

    • Version reporting and update-check behavior remain unchanged; CLI now reports embedded release metadata.

@YaRissi YaRissi force-pushed the version-inject branch 2 times, most recently from 5cb7580 to d78b7eb Compare October 20, 2025 22:56
@andrasbacsai
Copy link
Member

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

Walkthrough

Refactors version handling to an accessor, adds a CI update-version job to bump the version file after releases, and configures goreleaser to inject the build version via ldflags into binaries.

Changes

Cohort / File(s) Summary
CI Workflow
\.github/workflows/release-cli.yml``
Added update-version job that runs after release-cli, checks out v4.x, extracts the tag from GITHUB_REF, updates internal/version/checker.go to set the tag, commits chore: bump version to $TAG, and pushes to origin v4.x.
Build Configuration
\.goreleaser.yml``
Added ldflags for coolify build: -X github.com/coollabsio/coolify-cli/internal/version.version={{ .Version }} so goreleaser injects the release version into the binary.
Version API Refactor
\internal/version/checker.go``
Removed exported CliVersion constant; added unexported version var and exported GetVersion() string; internal callers updated to use GetVersion().
Command Updates
\cmd/root.go`, `cmd/update/update.go`, `cmd/version/version.go``
Replaced uses of version.CliVersion with version.GetVersion() across CLI commands and update logic.
Docs
\HOW-TO-RELEASE.md``
Removed manual version-bump steps and updated release instructions to reflect goreleaser injecting the version and to reference GetVersion() instead of CliVersion.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Dev as Release trigger
    participant Build as Goreleaser
    participant CI as release-cli job
    participant Updater as update-version job
    participant Repo as Repository
    participant Git as Git Remote

    Dev->>Build: create GitHub Release (tag)
    Build->>CI: run release-cli pipeline
    CI->>Build: produce artifacts (ldflags set internal/version.version)
    Build-->>Repo: artifacts published
    CI->>Updater: trigger update-version job
    Updater->>Repo: checkout branch `v4.x`
    Updater->>Updater: parse tag from GITHUB_REF
    Updater->>Repo: modify `internal/version/checker.go` version var
    Updater->>Git: commit "chore: bump version to $TAG"
    Updater->>Git: push branch `v4.x`
    Note right of Build: GetVersion() returns injected `internal/version.version`
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Check parsing of GITHUB_REF and branch target in .github/workflows/release-cli.yml.
  • Verify the ldflags package path and symbol name internal/version.version match the compiled package.
  • Confirm all occurrences of CliVersion (code + docs) were updated to GetVersion().

Possibly related PRs

Poem

🐰 I nudged a constant into a hopping Get,

CI tightens paws and sets the version yet.
Linker sprinkles tags into each build,
Branches pushed neat, the meadow trimmed and tilled.
A tiny hop — the meadow hums, content.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "feat: Version inject" directly relates to and clearly summarizes the main change in this pull request. The changeset is fundamentally about injecting the version into builds via Goreleaser and updating the version retrieval mechanism to support this new approach. The title is concise, uses the conventional commit format, and is specific enough that a teammate scanning the history would understand this introduces version injection functionality. The title is not vague or generic, and it accurately reflects the core objective of the PR.
Description Check ✅ Passed The PR description provides a well-structured Changes section that clearly explains what was implemented: Goreleaser version injection at build time and a new CI job to update the version in checker.go for go install users. The description includes helpful context through a Why section explaining the motivation to simplify the release process. While the description deviates from the template by including a "Why" section instead of the "Issues & Discussions" section, the critical Changes section is complete and well-detailed, making the description mostly complete overall. The content is clear, specific, and on-topic.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ca4c3a and 8a58cdd.

📒 Files selected for processing (1)
  • HOW-TO-RELEASE.md (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • HOW-TO-RELEASE.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
.github/workflows/release-cli.yml (1)

39-48: Add error handling and validation to the version update workflow.

The workflow lacks safeguards for several failure scenarios:

  • No verification that the sed command actually modified the file
  • No validation that TAG was extracted correctly
  • Push failures are not explicitly handled

Consider adding validation and error handling:

       - name: Update version file
         run: |
           TAG=${GITHUB_REF#refs/tags/}
+          if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
+            echo "Error: Invalid tag format: $TAG"
+            exit 1
+          fi
           echo "Updating version to $TAG"
           sed -i "s/^\tversion = \".*\"/\tversion = \"$TAG\"/" internal/version/checker.go
+          if ! git diff --quiet internal/version/checker.go; then
+            echo "Version file updated successfully"
+          else
+            echo "Warning: No changes detected in version file"
+            exit 1
+          fi
           git config user.name "github-actions[bot]"
           git config user.email "github-actions[bot]@users.noreply.github.com"
           git add internal/version/checker.go
           git commit -m "chore: bump version to $TAG"
           git push origin v4.x
internal/version/checker.go (1)

16-23: Consider using "dev" or "unknown" as the default version.

The default version "v1.0.3" could be misleading if the binary is built without proper ldflags injection (e.g., during local development with go build). Users might incorrectly believe they're running v1.0.3.

Consider using a more obvious development version:

 // Version variables injected by GoReleaser at build time via ldflags
 var (
-	version = "v1.0.3"
+	version = "dev"
 )

Alternatively, "unknown" or "v0.0.0-dev" would also clearly indicate an unofficial build.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa1bda4 and 559d4e2.

📒 Files selected for processing (7)
  • .github/workflows/release-cli.yml (1 hunks)
  • .goreleaser.yml (2 hunks)
  • HOW-TO-RELEASE.md (4 hunks)
  • cmd/root.go (2 hunks)
  • cmd/update/update.go (1 hunks)
  • cmd/version/version.go (1 hunks)
  • internal/version/checker.go (3 hunks)
🔇 Additional comments (9)
cmd/version/version.go (1)

16-16: LGTM!

The migration from version.CliVersion to version.GetVersion() is correct and consistent with the refactoring to support build-time version injection.

cmd/update/update.go (1)

30-30: LGTM!

The migration to version.GetVersion() is correct and maintains the existing update comparison logic.

cmd/root.go (2)

71-71: LGTM!

The version string formatting correctly uses version.GetVersion() to display the CLI version in the help text.


156-156: LGTM!

The update check logic correctly uses version.GetVersion() for version comparison.

.goreleaser.yml (1)

6-7: LGTM!

The ldflags configuration correctly targets github.com/coollabsio/coolify-cli/internal/version.version to inject the version at build time. This aligns with the private version variable in internal/version/checker.go.

HOW-TO-RELEASE.md (1)

47-48: LGTM!

Documentation correctly reflects the new version injection approach and the rename from CliVersion to GetVersion().

Also applies to: 114-114

internal/version/checker.go (2)

21-23: LGTM!

The GetVersion() accessor function provides a clean interface for retrieving the build-time injected version, and the unexported version variable correctly follows Go conventions for variables modified via ldflags.


42-42: LGTM!

The internal usages correctly call GetVersion() instead of directly accessing the old CliVersion constant.

Also applies to: 96-96

.github/workflows/release-cli.yml (1)

29-48: Unable to verify branch protection settings due to insufficient API permissions.

The GitHub API returned a 403 Forbidden error when attempting to query branch protection rules for the v4.x branch. This indicates the current authentication context lacks permissions to view these settings—not that protection rules don't exist.

Manually verify in repository settings whether the v4.x branch has protection rules enabled and confirm the GitHub Actions bot is allowed to bypass them if needed.

@andrasbacsai
Copy link
Member

@YaRissi can you please check if the rabbit makes sense? :)

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@YaRissi
Copy link
Contributor Author

YaRissi commented Oct 28, 2025

@andrasbacsai fixed all issues

@andrasbacsai
Copy link
Member

Oh, I merged the other PR's and it caused some conflicts. Sorry. Can you please fix them?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
.github/workflows/release-cli.yml (1)

44-46: Validate the extracted TAG before using it.

The TAG is extracted from GITHUB_REF without validation. If GITHUB_REF has an unexpected format or the tag is empty, the sed command could produce incorrect results or the commit message could be malformed.

Apply this diff to add validation:

          TAG=${GITHUB_REF#refs/tags/}
+          if [[ -z "$TAG" ]] || [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
+            echo "Error: Invalid or missing tag format. Expected vX.Y.Z, got: $TAG"
+            exit 1
+          fi
          echo "Updating version to $TAG"
          sed -i "s/^\tversion = \".*\"/\tversion = \"$TAG\"/" internal/version/checker.go
internal/version/checker.go (1)

17-20: Consider updating the comment to singular form.

The comment mentions "Version variables" (plural), but only one variable is declared. While this is minor, it could be clearer.

Apply this diff:

-// Version variables injected by GoReleaser at build time via ldflags
+// version is injected by GoReleaser at build time via ldflags.
+// The default value serves as a fallback for `go install` builds.
 var (
 	version = "v1.0.3"
 )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef15d01 and 5ca4c3a.

📒 Files selected for processing (7)
  • .github/workflows/release-cli.yml (1 hunks)
  • .goreleaser.yml (1 hunks)
  • HOW-TO-RELEASE.md (4 hunks)
  • cmd/root.go (2 hunks)
  • cmd/update/update.go (1 hunks)
  • cmd/version/version.go (1 hunks)
  • internal/version/checker.go (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • cmd/root.go
  • cmd/update/update.go
🧰 Additional context used
🧬 Code graph analysis (1)
cmd/version/version.go (1)
internal/version/checker.go (1)
  • GetVersion (22-24)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test
🔇 Additional comments (4)
.goreleaser.yml (1)

15-15: LGTM! Version injection is correctly configured.

The ldflags correctly targets the unexported version variable in internal/version/checker.go and uses the standard Goreleaser {{ .Version }} template. This will properly inject the release tag into binaries at build time.

cmd/version/version.go (1)

17-17: LGTM! Correctly uses the new version accessor.

The change from version.CliVersion to version.GetVersion() is correct and consistent with the refactoring across the codebase. This enables build-time version injection via Goreleaser.

internal/version/checker.go (2)

22-24: LGTM! Clean accessor implementation.

The GetVersion() function provides a clean, thread-safe way to access the build-time injected version. This pattern correctly enables ldflags injection, which wouldn't work with a constant or direct variable export.


43-43: LGTM! GetVersion() calls are correctly placed.

Both usages of GetVersion() are appropriate:

  • Line 43: Returns the current version when skipping the update check
  • Line 100: Retrieves the current version for semantic version comparison

The refactoring from CliVersion to GetVersion() is complete and consistent throughout the file.

Also applies to: 100-100

@YaRissi
Copy link
Contributor Author

YaRissi commented Oct 30, 2025

@andrasbacsai fixed the merge conflicts

@andrasbacsai
Copy link
Member

Thank you for the PR! 💜

@andrasbacsai andrasbacsai merged commit ed2dbd4 into coollabsio:v4.x Nov 10, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants