Skip to content

docs: update documentation for clarity and completeness across multip… #23

docs: update documentation for clarity and completeness across multip…

docs: update documentation for clarity and completeness across multip… #23

Workflow file for this run

name: Release
on:
push:
branches:
- main
workflow_dispatch:
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
jobs:
release:
name: Create Release PR or Publish
permissions:
contents: write
pull-requests: write
id-token: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache: pnpm
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Create release pull request or publish
id: changesets
uses: changesets/action@v1
with:
publish: pnpm release
commit: "chore: version packages"
title: "chore: version packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HUSKY: 0
- name: Update Homebrew tap
if: >-
github.ref == 'refs/heads/main' &&
steps.changesets.outputs.published == 'true' &&
contains(steps.changesets.outputs.publishedPackages, '"cloudburn"')
env:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
VERSION=$(node -p "require('./packages/cloudburn/package.json').version")
TARBALL_URL="https://registry.npmjs.org/cloudburn/-/cloudburn-${VERSION}.tgz"
# Retry up to 5 times to handle npm CDN propagation delay
for i in 1 2 3 4 5; do
SHA256=$(curl -sfSL "$TARBALL_URL" | shasum -a 256 | cut -d ' ' -f 1) && break
SHA256=""
echo "Tarball not yet available, retrying in 15s (attempt $i/5)..."
sleep 15
done
if [ -z "$SHA256" ]; then
echo "::error::Failed to download tarball after 5 attempts"
exit 1
fi
cat > /tmp/cloudburn.rb <<FORMULA
class Cloudburn < Formula
desc "CLI for cloud cost optimization"
homepage "https://cloudburn.io/docs"
url "${TARBALL_URL}"
sha256 "${SHA256}"
license "Apache-2.0"
depends_on "node"
def install
system "npm", "install", *std_npm_args
bin.install_symlink libexec.glob("bin/*")
end
test do
assert_match version.to_s, shell_output("#{bin}/cloudburn --version")
end
end
FORMULA
# Remove leading whitespace from heredoc
sed -i 's/^ //' /tmp/cloudburn.rb
# Push updated formula to the homebrew tap repo
CONTENT=$(base64 -w 0 < /tmp/cloudburn.rb)
EXISTING_SHA=$(curl -sf -H "Authorization: token $HOMEBREW_TAP_TOKEN" \
"https://api.github.com/repos/towardsthecloud/homebrew-tap/contents/Formula/cloudburn.rb" \
| jq -r '.sha // empty') || EXISTING_SHA=""
JSON_PAYLOAD=$(jq -n \
--arg message "chore: update cloudburn to ${VERSION}" \
--arg content "$CONTENT" \
--arg sha "$EXISTING_SHA" \
'if $sha == "" then {message: $message, content: $content} else {message: $message, content: $content, sha: $sha} end')
curl -sfS -X PUT \
-H "Authorization: token $HOMEBREW_TAP_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/towardsthecloud/homebrew-tap/contents/Formula/cloudburn.rb" \
-d "$JSON_PAYLOAD"