-
Notifications
You must be signed in to change notification settings - Fork 4
feat(CI): extract JSON from CLI output for downstream usage #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Cristian-Vogel
wants to merge
1
commit into
crabnebula-dev:main
from
Cristian-Vogel:extract_JSON_to_GITHUB_OUTPUT
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Why the GitHub Action and the CLI Are Separate | ||
|
|
||
| While they might look like they do the same thing on the surface, they each have a distinct purpose and work together to give us a smooth CI/CD experience. | ||
|
|
||
| ## 1️⃣ The GitHub Action Is a Wrapper | ||
|
|
||
| Think of the `cloud-release` GitHub Action as a convenience layer around the `cn` CLI. It handles all the “plumbing” that would otherwise require a bunch of manual steps in the workflow file: | ||
|
|
||
| - **Environment detection** – automatically picks the right binary for Linux (x64/ARM), macOS, or Windows. | ||
| - **Dependency management** – downloads the correct version of the `cn` CLI for the detected OS. | ||
| - **Permissions** – makes sure the binary is executable (`chmod +x`). | ||
| - **Configuration** – maps your GitHub secrets (e.g., `api-key`) straight to the CLI’s expected inputs. | ||
|
|
||
| Without this action we’d end up writing 10‑15 lines of `curl` and conditional logic in every repo. | ||
|
|
||
| ## 2️⃣ Interoperability (Why We Need Output Variables) | ||
|
|
||
| The `cn release draft` command prints a JSON object to stdout, but GitHub Actions can’t read that object directly. In the GitHub Actions world: | ||
|
|
||
| - **Stdout** is just human‑readable text in the logs. | ||
| - **Outputs** (e.g., `${{ steps.draft.outputs.release-id }}`) are special variables that later steps can consume. | ||
|
|
||
| The action captures the CLI’s text output, extracts the hidden JSON, and explicitly tells GitHub *“this piece of text is the Release ID – store it for the next step.”* That bridge lets us use the data downstream without writing custom parsers. | ||
|
|
||
| ## 3️⃣ Separation of Concerns | ||
|
|
||
| - **The CLI (`cn`)** – the engine. It contains the core logic for talking to CrabNebula Cloud’s API and can be used directly in a terminal or script. | ||
| - **The Action (`cloud-release`)** – the UI/integration. It adapts the engine to the GitHub environment, exposing its functionality as native workflow variables. | ||
|
|
||
| ### TL;DR | ||
|
|
||
| The CLI does the heavy lifting. The Action makes that work discoverable and usable as variables within a GitHub workflow, sparing us from writing custom parsing scripts in every project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "name": "cloud-release", | ||
| "version": "0.2.6", | ||
| "version": "0.2.7", | ||
| "publish": false | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes the stdout will contain valid JSON. And the only type ever returned is a release object.
That's very limiting in terms of features the CLI could implement. So supporting output variables should be done by the CLI, which is aware of what outputs are supposed to be generated.