Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .changeset/homebrew-formula.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

Add a Homebrew formula for the CLI (`brew tap osbytes/crypt-fyi https://github.com/osbytes/crypt.fyi && brew install crypt-fyi`). Docs and release automation only; no package release needed.
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,66 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

homebrew:
name: Bump Homebrew formula
needs: release
# Formula/crypt-fyi.rb pins the npm tarball by sha256, so it can only be updated once
# the CLI is actually on the registry. Manual runs re-sync it to the released version.
if: >-
!cancelled() && needs.release.outputs.version != '' &&
(contains(needs.release.outputs.publishedPackages, '"@crypt.fyi/cli"') ||
(github.event_name == 'workflow_dispatch' && needs.release.result == 'success'))
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout main
uses: actions/checkout@v7
with:
ref: main

- name: Update formula url and sha256
env:
VERSION: ${{ needs.release.outputs.version }}
run: |
set -euo pipefail
url="https://registry.npmjs.org/@crypt.fyi/cli/-/cli-${VERSION}.tgz"
tarball="$RUNNER_TEMP/cli.tgz"
# The registry can lag a fresh publish by a few seconds; -f makes a 404 retryable.
curl -fsSL --retry 10 --retry-delay 10 --retry-all-errors -o "$tarball" "$url"
# Cross-check the download against the integrity npm recorded at publish time.
expected="$(npm view "@crypt.fyi/cli@${VERSION}" dist.integrity)"
actual="sha512-$(openssl dgst -sha512 -binary "$tarball" | base64 -w0)"
if [ "$expected" != "$actual" ]; then
echo "::error::Downloaded tarball does not match npm dist.integrity for ${VERSION}"
exit 1
fi
sha256="$(sha256sum "$tarball" | cut -d' ' -f1)"
sed -i -E \
-e "s|^ url \".*\"$| url \"${url}\"|" \
-e "s|^ sha256 \".*\"$| sha256 \"${sha256}\"|" \
Formula/crypt-fyi.rb
grep -qF "url \"${url}\"" Formula/crypt-fyi.rb
grep -qF "sha256 \"${sha256}\"" Formula/crypt-fyi.rb

# Pushed with GITHUB_TOKEN, which does not trigger further workflow runs.
- name: Commit and push
env:
VERSION: ${{ needs.release.outputs.version }}
run: |
set -euo pipefail
if git diff --quiet -- Formula/crypt-fyi.rb; then
echo "Formula already points at ${VERSION}"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -m "chore(cli): bump Homebrew formula to ${VERSION}" -- Formula/crypt-fyi.rb
for attempt in 1 2 3; do
if git pull --rebase origin main && git push origin HEAD:main; then
exit 0
fi
sleep $((attempt * 5))
done
exit 1
25 changes: 25 additions & 0 deletions Formula/crypt-fyi.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Homebrew formula for the crypt.fyi CLI (`cfyi`), installed from the npm package.
# url and sha256 are bumped by the `homebrew` job in .github/workflows/release.yml
# after each @crypt.fyi/cli publish.
class CryptFyi < Formula
desc "Zero-knowledge, end-to-end encrypted secret sharing CLI"
homepage "https://crypt.fyi"
url "https://registry.npmjs.org/@crypt.fyi/cli/-/cli-0.2.0.tgz"
sha256 "960382854b6e7a9918af208702e220e5a980a35806ad87e932c818c8704377b5"
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}/cfyi --version")
assert_match "Encrypt and share a secret", shell_output("#{bin}/cfyi --help")
# Exercises argument validation without touching the network.
output = shell_output("#{bin}/cfyi encrypt secret --file #{testpath}/missing 2>&1", 1)
assert_match "Cannot provide both content and file", output
end
end
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
- 🌐 IP/CIDR allow-listing
- 🔢 Read count limits
- 📱 QR code generation
- ⌨️ [CLI](https://www.npmjs.com/package/@crypt.fyi/cli) for interacting with the API
- ⌨️ [CLI](https://www.npmjs.com/package/@crypt.fyi/cli) for interacting with the API (`npm install -g @crypt.fyi/cli`, or via [Homebrew](./packages/cli/README.md#homebrew-macos--linux))
- 🧩 [Chrome Extension](https://chromewebstore.google.com/detail/cryptfyi/hkmbmkjfjfdbpohlllleaacjkacfhald)
- 🐳 Docker images for the api server and web client
- 🌐 Internationalization support for multiple languages
Expand Down Expand Up @@ -183,7 +183,7 @@ docker compose exec redis rm /data/dump.rdb
Publishable packages: `@crypt.fyi/core` and `@crypt.fyi/cli` (npm), plus the Chrome extension.

1. Record changes: `pnpm changeset`
2. Merge to `main` — the Release workflow opens a Version Packages PR (or publishes when that PR is merged)
2. Merge to `main` — the Release workflow opens a Version Packages PR (or publishes when that PR is merged). After a CLI publish it also commits the new npm tarball `url` and `sha256` to the Homebrew formula in `Formula/crypt-fyi.rb`
3. Required GitHub secrets for publishing:
- `NPM_TOKEN`
- `CHROME_EXTENSION_ID`, `CHROME_CLIENT_ID`, `CHROME_CLIENT_SECRET`, `CHROME_REFRESH_TOKEN`, `CHROME_PUBLISHER_ID`
Expand Down
13 changes: 13 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,23 @@ CLI for interacting with the [crypt.fyi](https://crypt.fyi) API.

## Installation

### npm

```bash
npm install -g @crypt.fyi/cli
```

### Homebrew (macOS / Linux)

The formula lives in the [`Formula/`](https://github.com/osbytes/crypt.fyi/tree/main/Formula) directory of this repository, so tap the repository by URL first:

```bash
brew tap osbytes/crypt-fyi https://github.com/osbytes/crypt.fyi
brew install crypt-fyi
```

Both install the `cfyi` binary. `brew upgrade crypt-fyi` picks up new releases; the formula is bumped automatically after each CLI publish.

## Usage

```bash
Expand Down
Loading