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: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.64.5
version: v2.12.2
args: --timeout=5m

vuln:
Expand Down Expand Up @@ -55,8 +55,10 @@ jobs:
go-version-file: go.mod
cache: true
- name: build
shell: bash
run: go build ./...
- name: test
shell: bash
run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
- name: upload coverage
if: matrix.os == 'ubuntu-latest'
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,31 @@ jobs:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}

- name: Set up QEMU
if: env.DOCKERHUB_USERNAME != ''
uses: docker/setup-qemu-action@v3
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}

- name: Set up Docker Buildx
if: env.DOCKERHUB_USERNAME != ''
uses: docker/setup-buildx-action@v3
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}

- name: Compute goreleaser skip flags
id: skip
run: |
flags=""
[ -z "${{ secrets.DOCKERHUB_USERNAME }}" ] && flags="$flags --skip=docker"
[ -z "${{ secrets.TAP_GITHUB_TOKEN }}" ] && flags="$flags --skip=homebrew,scoop"
echo "flags=$flags" >> "$GITHUB_OUTPUT"

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean
args: release --clean ${{ steps.skip.outputs.flags }}
env:
# Default token can create the release on this repo. The
# external tap/bucket repos need a PAT with `repo` scope
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ checksum:
release:
github:
owner: ararahq
name: arara-cli
name: cli
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ararahq/cli

go 1.26.1
go 1.26.2

require (
github.com/charmbracelet/bubbles v1.0.0
Expand Down
34 changes: 34 additions & 0 deletions workers/install-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# arara-install-cli (Cloudflare Worker)

Serve os scripts de instalação do AraraHQ CLI em `get.ararahq.com`.

```
GET https://get.ararahq.com/install-cli → install.sh (Unix)
GET https://get.ararahq.com/install-cli.ps1 → install.ps1 (Windows)
GET https://get.ararahq.com/ → 302 docs.ararahq.com/cli
```

Os scripts são puxados de `raw.githubusercontent.com/ararahq/cli/main/`. Cache de 5min na borda da Cloudflare.

## Deploy

1. **Instale o Wrangler** (uma vez): `npm i -g wrangler`
2. **Login**: `wrangler login`
3. **Deploy**: dentro deste diretório, `wrangler deploy`
4. **Custom domain**: dashboard Cloudflare → Workers → `arara-install-cli` → Settings → Triggers → Add Custom Domain → `get.ararahq.com`

DNS é criado automaticamente quando você adiciona o custom domain (Cloudflare resolve internamente).

## Testar antes do deploy

```bash
wrangler dev
curl http://127.0.0.1:8787/install-cli
```

## Validar produção

```bash
curl -fsSL https://get.ararahq.com/install-cli | head -20
curl -I https://get.ararahq.com/install-cli.ps1
```
56 changes: 56 additions & 0 deletions workers/install-cli/src/worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const REPO = "ararahq/cli";
const SH_URL = `https://raw.githubusercontent.com/${REPO}/main/install.sh`;
const PS1_URL = `https://raw.githubusercontent.com/${REPO}/main/install.ps1`;
const DOCS_URL = "https://docs.ararahq.com/cli";

const SH_HEADERS = { "Content-Type": "text/x-shellscript; charset=utf-8" };
const PS1_HEADERS = { "Content-Type": "text/plain; charset=utf-8" };
const CACHE_HEADER = { "Cache-Control": "public, max-age=300" };

export default {
async fetch(request) {
const url = new URL(request.url);
const ua = (request.headers.get("User-Agent") || "").toLowerCase();
const looksLikeShell = /curl|wget|fetch/.test(ua);

if (url.pathname === "/install-cli" || url.pathname === "/install-cli.sh") {
return proxy(SH_URL, SH_HEADERS);
}

if (url.pathname === "/install-cli.ps1") {
return proxy(PS1_URL, PS1_HEADERS);
}

// Root: serve install.sh when called by curl/wget (so `curl ... | sh` works),
// otherwise redirect humans to the docs.
if (url.pathname === "/" || url.pathname === "") {
if (looksLikeShell) {
return proxy(SH_URL, SH_HEADERS);
}
return Response.redirect(DOCS_URL, 302);
}

return new Response("Not found. Try /install-cli or /install-cli.ps1\n", {
status: 404,
headers: { "Content-Type": "text/plain; charset=utf-8" },
});
},
};

async function proxy(upstream, contentHeaders) {
const upstreamResponse = await fetch(upstream, {
cf: { cacheTtl: 300, cacheEverything: true },
});

if (!upstreamResponse.ok) {
return new Response(`Upstream fetch failed (${upstreamResponse.status})\n`, {
status: 502,
headers: { "Content-Type": "text/plain; charset=utf-8" },
});
}

return new Response(upstreamResponse.body, {
status: 200,
headers: { ...contentHeaders, ...CACHE_HEADER },
});
}
10 changes: 10 additions & 0 deletions workers/install-cli/wrangler.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name = "arara-install-cli"
main = "src/worker.js"
compatibility_date = "2025-01-01"

# Custom domain attached via dashboard:
# get.ararahq.com → this worker
# Worker handles:
# GET /install-cli → install.sh (Unix)
# GET /install-cli.ps1 → install.ps1 (Windows)
# GET / → redirect to docs.ararahq.com/cli
Loading