From 6dde2841e19a8833a0597cb45ff8b535265c3ab7 Mon Sep 17 00:00:00 2001 From: Micael Marques Date: Mon, 25 May 2026 17:12:56 -0300 Subject: [PATCH 1/2] feat: install via get.ararahq.com (Cloudflare Worker) + fix release pipeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Cloudflare Worker Novo worker em `workers/install-cli/` que serve install scripts em get.ararahq.com: - GET / → install.sh quando UA é curl/wget; senão 302 docs - GET /install-cli → install.sh (Unix) - GET /install-cli.sh → install.sh (Unix) - GET /install-cli.ps1 → install.ps1 (Windows) Proxy pra raw.githubusercontent.com/ararahq/cli/main/install.{sh,ps1} com cache de 5min na borda. Deploy via wrangler. Custom domain `get.ararahq.com` configurado pelo dashboard. ## Fix .goreleaser.yaml release.github.name estava como "arara-cli" mas o repo se chama "cli" — release falhava silenciosamente. Corrige pra "cli". ## Fix .github/workflows/release.yml Pula Docker Hub e Homebrew/Scoop quando os secrets correspondentes não estão configurados (antes goreleaser falhava o release inteiro nesse caso). Permite publicar o primeiro release com só GitHub Releases; brews/docker entram quando os secrets forem adicionados. --- .github/workflows/release.yml | 16 ++++++++- .goreleaser.yaml | 2 +- workers/install-cli/README.md | 34 +++++++++++++++++++ workers/install-cli/src/worker.js | 56 +++++++++++++++++++++++++++++++ workers/install-cli/wrangler.toml | 10 ++++++ 5 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 workers/install-cli/README.md create mode 100644 workers/install-cli/src/worker.js create mode 100644 workers/install-cli/wrangler.toml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 79e420e..06dc8d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index e6b7579..abccea5 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -129,4 +129,4 @@ checksum: release: github: owner: ararahq - name: arara-cli + name: cli diff --git a/workers/install-cli/README.md b/workers/install-cli/README.md new file mode 100644 index 0000000..fcb310e --- /dev/null +++ b/workers/install-cli/README.md @@ -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 +``` diff --git a/workers/install-cli/src/worker.js b/workers/install-cli/src/worker.js new file mode 100644 index 0000000..b3c8f4a --- /dev/null +++ b/workers/install-cli/src/worker.js @@ -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 }, + }); +} diff --git a/workers/install-cli/wrangler.toml b/workers/install-cli/wrangler.toml new file mode 100644 index 0000000..ce8e9f0 --- /dev/null +++ b/workers/install-cli/wrangler.toml @@ -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 From 16c7f3633f49346bf424e5cd2e4122a31ab5a3c0 Mon Sep 17 00:00:00 2001 From: Micael Marques Date: Mon, 25 May 2026 17:24:34 -0300 Subject: [PATCH 2/2] fix(ci): go 1.26.2, golangci-lint v2.12.2, shell bash no test windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 3 falhas no CI deste PR: - govulncheck reportou 7 CVEs do stdlib (crypto/tls, archive/tar, crypto/x509) fixadas em go1.26.2. Bump go.mod. - golangci-lint v1.64.5 (foi buildado com go1.24) recusa um projeto declarado como go1.26: "the Go language version (go1.24) used to build golangci-lint is lower than the targeted Go version (1.26.1)". Sobe pra v2.12.2 — config ja esta em formato v2 (.golangci.yml com version: "2"). - test (windows-latest) falha no PowerShell parseando `coverage.out` como propriedade de objeto: "FAIL .out [setup failed] / no required module provides package .out". Forca shell bash (Git Bash existe no runner Windows do GitHub Actions) tanto no build quanto no test. --- .github/workflows/ci.yml | 4 +++- go.mod | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75c25b2..ae91a5b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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' diff --git a/go.mod b/go.mod index 1ddf545..8c64e3e 100644 --- a/go.mod +++ b/go.mod @@ -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