Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions ABOUT.md
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.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## \[0.2.6]
## [0.2.7]

- Added `release`, `release-id` and `release-version` to the action outputs.

## [0.2.6]

- [`70f1904`](https://github.com/crabnebula-dev/cloud-release/commit/70f19045c5c3ffa7262bd5a4461ffb8cc6baa329) Sets a User-Agent when downloading the CLI.

Expand Down
32 changes: 30 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ outputs:
stdout:
description: "The stdout of the CLI"
value: ${{ steps.run-command.outputs.stdout }}
release:
description: "The release object as JSON"
value: ${{ steps.run-command.outputs.release }}
release-id:
description: "The ID of the release"
value: ${{ steps.run-command.outputs.release-id }}
release-version:
description: "The version of the release"
value: ${{ steps.run-command.outputs.release-version }}

runs:
using: 'composite'
Expand Down Expand Up @@ -92,8 +101,27 @@ runs:
run: |
: run cn ${{ inputs.command }}
echo "running \"${{ steps.download-cn-cli.outputs.cn-path }}\" from '${{ inputs.working-directory }}'"
exec 5>&1
OUTPUT=$(${{ steps.download-cn-cli.outputs.cn-path }} ${{ inputs.command }} | tee >(cat - >&5))
OUTPUT=$(${{ steps.download-cn-cli.outputs.cn-path }} ${{ inputs.command }})
echo "$OUTPUT"
echo "stdout<<nEOFn" >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo "nEOFn" >> $GITHUB_OUTPUT

# Try to extract JSON from the output
if JSON=$(echo "$OUTPUT" | sed -n '/^{/,/}/p' | jq -c '.' 2>/dev/null); then
if [ -n "$JSON" ]; then
echo "release<<nEOFn" >> $GITHUB_OUTPUT
echo "$JSON" >> $GITHUB_OUTPUT
echo "nEOFn" >> $GITHUB_OUTPUT

ID=$(echo "$JSON" | jq -r '.id // empty')
if [ -n "$ID" ]; then
echo "release-id=$ID" >> $GITHUB_OUTPUT
fi

VERSION=$(echo "$JSON" | jq -r '.version // empty')
if [ -n "$VERSION" ]; then
echo "release-version=$VERSION" >> $GITHUB_OUTPUT
fi
fi
fi
Comment on lines +110 to +127
Copy link
Copy Markdown
Member

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.

2 changes: 1 addition & 1 deletion package.json
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
}
Loading