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
111 changes: 111 additions & 0 deletions .github/workflows/cli-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: CLI CI

on:
push:
branches: [main]
paths: ['packages/cli/**']
pull_request:
paths: ['packages/cli/**']

permissions:
contents: read

defaults:
run:
working-directory: packages/cli

jobs:
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0

- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: packages/cli/go.mod
cache: true

- name: Verify dependencies
run: go mod verify

- name: Run tests
if: matrix.os != 'ubuntu-latest'
run: go test -v -race ./...

- name: Run tests (with coverage)
if: matrix.os == 'ubuntu-latest'
run: go test -v -race -coverprofile=coverage.out ./...

- name: Upload coverage
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
files: packages/cli/coverage.out
fail_ci_if_error: false

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0

- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: packages/cli/go.mod
cache: true

- name: Run go vet
run: go vet ./...

- name: Run golangci-lint
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run --timeout=5m ./cmd/gemini-markets ./cmd/gen-docs ./internal/...

docs:
name: Docs Drift
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0

- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: packages/cli/go.mod
cache: true

- name: Regenerate manpages
run: go run ./cmd/gen-docs

- name: Verify manpages are up to date
run: git diff --exit-code -- docs/man

build:
name: Build (${{ matrix.goos }}/${{ matrix.goarch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
goos: [darwin, linux, windows]
goarch: [amd64, arm64]
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0

- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: packages/cli/go.mod
cache: true

- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: go build ./cmd/gemini-markets
45 changes: 45 additions & 0 deletions .github/workflows/cli-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CLI Release

on:
push:
tags:
- 'cli/v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g., cli/v0.1.5)'
required: true
type: string

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/cli
steps:
- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
fetch-depth: 0
ref: ${{ inputs.tag || github.ref }}

- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: packages/cli/go.mod
cache: true

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
with:
distribution: goreleaser
version: latest
args: release --clean
workdir: packages/cli
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
42 changes: 42 additions & 0 deletions packages/cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Binaries
/gemini-markets
/gemini-markets-*
*.exe
!*.go
bin/

# IDE
.idea/
.vscode/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db
ehthumbs.db

# Build
dist/
*.test
*.out

# Test coverage
coverage.out
coverage.html
*.coverprofile

# Config & credentials (safety)
.config/
.env
.env.local
*.pem
*.key

# Dependencies
vendor/

# Temporary files
tmp/
temp/
90 changes: 90 additions & 0 deletions packages/cli/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
run:
timeout: 5m
modules-download-mode: readonly

linters:
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- gofmt
- goimports
- misspell
- unconvert
- unparam
- gosec
- bodyclose
- noctx
- errorlint
- exhaustive
- copyloopvar
- gocritic
- godot
- nilerr
- prealloc
- revive
- whitespace

linters-settings:
gofmt:
simplify: true
goimports:
local-prefixes: github.com/gemini/gemini-markets-cli
misspell:
locale: US
ignore-words:
- cancelled
gocritic:
enabled-tags:
- diagnostic
- style
- performance
disabled-checks:
- whyNoLint
- appendCombine
- hugeParam
- ifElseChain
- paramTypeCombine
- rangeValCopy
- unnamedResult
revive:
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
gosec:
excludes:
- G104 # Audit errors not checked (we handle this explicitly)
exhaustive:
default-signifies-exhaustive: true

issues:
exclude-rules:
- path: _test\.go
linters:
- gosec
- errcheck
- gocritic
- path: cmd/
linters:
- godot
max-issues-per-linter: 0
max-same-issues: 0
99 changes: 99 additions & 0 deletions packages/cli/.goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
version: 2

project_name: gemini-markets

before:
hooks:
- go mod tidy
- go generate ./...

builds:
- main: ./cmd/gemini-markets
binary: gemini-markets
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
ldflags:
- -s -w
- -X github.com/gemini/developer-platform/packages/cli/internal/cmd.Version={{.Version}}
- -X github.com/gemini/developer-platform/packages/cli/internal/cmd.Commit={{.ShortCommit}}
- -X github.com/gemini/developer-platform/packages/cli/internal/cmd.Date={{.Date}}

archives:
- format: tar.gz
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
format_overrides:
- goos: windows
format: zip
files:
- README.md
- LICENSE
- CHANGELOG.md

checksum:
name_template: 'checksums.txt'

brews:
- name: gemini-markets
skip_upload: '{{ if .Env.HOMEBREW_TAP_TOKEN }}false{{ else }}true{{ end }}'
repository:
owner: gemini
name: homebrew-tap
token: "{{ .Env.HOMEBREW_TAP_TOKEN }}"
homepage: "https://github.com/gemini/developer-platform/tree/main/packages/cli"
description: "CLI for trading on Gemini Exchange - spot and prediction markets"
license: "MIT"
install: |
bin.install "gemini-markets"
test: |
system "#{bin}/gemini-markets", "version"

snapshot:
version_template: "{{ incpatch .Version }}-next"

changelog:
sort: asc
use: github
groups:
- title: Features
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
order: 0
- title: Bug Fixes
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
order: 1
- title: Documentation
regexp: '^.*?docs(\([[:word:]]+\))??!?:.+$'
order: 2
- title: Others
order: 999
filters:
exclude:
- '^test:'
- '^chore:'
- '^ci:'

release:
github:
owner: gemini
name: developer-platform
draft: false
prerelease: auto
name_template: "cli/v{{.Version}}"
footer: |
## Installation

Download the appropriate binary for your platform from the assets below.

### Quick Install (Linux/macOS)
```bash
curl -sSL https://raw.githubusercontent.com/gemini/developer-platform/main/packages/cli/scripts/install.sh | sh
```

## Checksums
See `checksums.txt` for SHA256 checksums of all binaries.
Loading
Loading