Skip to content

Commit a1dbed9

Browse files
committed
feat: initial release of the RoxyAPI Go SDK
Typed Go client generated from the RoxyAPI OpenAPI spec via oapi-codegen v2, with a generated roxy.Domain.Method facade, typed RoxyError, and Date/Ptr helpers. Autopilot: a git tag is the publish, pkg.go.dev indexes it, and CI plus lefthook guard drift against the spec. 12+ insight domains, 160+ endpoints, one direct runtime dependency.
0 parents  commit a1dbed9

27 files changed

Lines changed: 129073 additions & 0 deletions

.github/dependabot.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: gomod
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
open-pull-requests-limit: 5
8+
# Wait 3 days before opening a bump PR so freshly published versions get
9+
# a chance to be flagged for supply-chain issues before they land.
10+
cooldown:
11+
default-days: 3
12+
groups:
13+
dependencies:
14+
patterns:
15+
- "*"
16+
# The oapi-codegen runtime is pinned to the generator version in
17+
# tools/roxygen. Bumping it out of step can desync the generated client, so it
18+
# is upgraded deliberately at generation time, never by dependabot.
19+
ignore:
20+
- dependency-name: "github.com/oapi-codegen/runtime"
21+
22+
- package-ecosystem: gomod
23+
directory: /tools/roxygen
24+
schedule:
25+
interval: weekly
26+
open-pull-requests-limit: 5
27+
cooldown:
28+
default-days: 3
29+
groups:
30+
dependencies:
31+
patterns:
32+
- "*"
33+
# The generator version is pinned and drives the generated output; bump it
34+
# deliberately and regenerate, never via an automated PR.
35+
ignore:
36+
- dependency-name: "github.com/oapi-codegen/oapi-codegen/v2"
37+
38+
- package-ecosystem: github-actions
39+
directory: /
40+
schedule:
41+
interval: weekly

.github/workflows/ci.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
# Drift, format and vet use the workspace (which includes the maintainer tool in
13+
# tools/roxygen) on a current Go. `go vet` also type-checks, so there is no separate
14+
# build step; the consumer build is covered by the test job below.
15+
checks:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v7
19+
- uses: actions/setup-go@v6
20+
with:
21+
go-version: stable
22+
23+
- name: Codegen drift check
24+
run: |
25+
go run ./tools/roxygen generate
26+
git diff --exit-code -- specs/openapi.json roxyapi.gen.go roxy.gen.go \
27+
|| { echo 'codegen drift: run "go run ./tools/roxygen generate" and commit the result'; exit 1; }
28+
29+
- name: Docs drift check
30+
run: |
31+
go run ./tools/roxygen sync-docs
32+
git diff --exit-code -- README.md AGENTS.md docs/llms-full.txt \
33+
|| { echo 'docs drift: run "go run ./tools/roxygen sync-docs" and commit the result'; exit 1; }
34+
35+
- name: gofmt
36+
run: test -z "$(gofmt -l .)" || { echo 'run gofmt -w .'; gofmt -l .; exit 1; }
37+
38+
- name: Vet
39+
run: go vet ./...
40+
41+
# The published module is built and tested from the consumer's perspective
42+
# (GOWORK off, no maintainer tooling) across supported Go versions.
43+
test:
44+
runs-on: ubuntu-latest
45+
strategy:
46+
matrix:
47+
go: ['1.24.x', 'stable']
48+
env:
49+
GOWORK: off
50+
steps:
51+
- uses: actions/checkout@v7
52+
- uses: actions/setup-go@v6
53+
with:
54+
go-version: ${{ matrix.go }}
55+
- name: Build
56+
run: go build .
57+
- name: Test
58+
run: go test .
59+
env:
60+
ROXY_API_KEY: ${{ secrets.ROXY_API_KEY }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Dependabot auto-merge
2+
3+
on: pull_request
4+
5+
permissions:
6+
contents: write
7+
pull-requests: write
8+
9+
jobs:
10+
auto-merge:
11+
if: github.actor == 'dependabot[bot]'
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Fetch Dependabot metadata
15+
id: meta
16+
uses: dependabot/fetch-metadata@v3
17+
- name: Auto-approve patch and minor bumps
18+
if: steps.meta.outputs.update-type == 'version-update:semver-patch' || steps.meta.outputs.update-type == 'version-update:semver-minor'
19+
run: gh pr review --approve "$PR_URL"
20+
env:
21+
PR_URL: ${{ github.event.pull_request.html_url }}
22+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
- name: Enable auto-merge for patch and minor bumps
24+
if: steps.meta.outputs.update-type == 'version-update:semver-patch' || steps.meta.outputs.update-type == 'version-update:semver-minor'
25+
run: gh pr merge --auto --squash --delete-branch "$PR_URL"
26+
env:
27+
PR_URL: ${{ github.event.pull_request.html_url }}
28+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Release
2+
3+
on:
4+
repository_dispatch:
5+
types: [openapi-updated] # fired by the server repo on an OpenAPI change
6+
schedule:
7+
- cron: '0 6 * * *' # daily fallback, also covers an unwired dispatch
8+
workflow_dispatch:
9+
inputs:
10+
version_bump:
11+
description: 'patch | minor | major'
12+
required: false
13+
default: 'patch'
14+
15+
# Go has no package registry and no OIDC publish: a release is just a git tag that
16+
# pkg.go.dev indexes through the module proxy. The only token needed is the default
17+
# GITHUB_TOKEN for the commit and tag. There are no publish secrets.
18+
permissions:
19+
contents: write
20+
21+
jobs:
22+
release:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v7
26+
with:
27+
fetch-depth: 0 # need all tags to compute the next version
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
- uses: actions/setup-go@v6
30+
with:
31+
go-version: stable
32+
33+
- name: Regenerate from live spec
34+
run: go run ./tools/roxygen generate
35+
36+
- name: Detect drift
37+
id: diff
38+
run: |
39+
if git diff --quiet -- specs/openapi.json roxyapi.gen.go roxy.gen.go README.md AGENTS.md docs/llms-full.txt; then
40+
echo "changed=false" >> "$GITHUB_OUTPUT"
41+
else
42+
echo "changed=true" >> "$GITHUB_OUTPUT"
43+
fi
44+
45+
- name: Vet, build, test
46+
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
47+
run: |
48+
go vet ./...
49+
go build ./...
50+
go test ./...
51+
env:
52+
ROXY_API_KEY: ${{ secrets.ROXY_API_KEY }}
53+
54+
- name: Compute next version
55+
id: bump
56+
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
57+
run: |
58+
git fetch --tags --force
59+
LATEST=$(git tag --list 'v*' --sort=-v:refname | head -1)
60+
LATEST=${LATEST:-v0.0.0}
61+
IFS=. read -r MA MI PA <<<"${LATEST#v}"
62+
case "${{ github.event.inputs.version_bump || 'patch' }}" in
63+
major) MA=$((MA+1)); MI=0; PA=0 ;;
64+
minor) MI=$((MI+1)); PA=0 ;;
65+
*) PA=$((PA+1)) ;;
66+
esac
67+
VER="$MA.$MI.$PA"
68+
sed -i "s/const Version = \".*\"/const Version = \"$VER\"/" version.go
69+
echo "version=$VER" >> "$GITHUB_OUTPUT"
70+
echo "Next version: v$VER"
71+
72+
- name: Commit, tag, push
73+
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
74+
run: |
75+
git config user.name "github-actions[bot]"
76+
git config user.email "github-actions[bot]@users.noreply.github.com"
77+
V=${{ steps.bump.outputs.version }}
78+
git add specs/openapi.json roxyapi.gen.go roxy.gen.go version.go README.md AGENTS.md docs/llms-full.txt
79+
git commit -m "release: v$V"
80+
git tag "v$V"
81+
git push --follow-tags
82+
83+
- name: Prompt pkg.go.dev to index the new version
84+
# The documented way to get a module indexed: ask the proxy for it via the go
85+
# tool (handles module-path case encoding; no manual curl bang-encoding).
86+
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
87+
env:
88+
GOPROXY: proxy.golang.org
89+
run: go list -m "github.com/RoxyAPI/sdk-go@v${{ steps.bump.outputs.version }}" || true
90+
91+
- name: Create GitHub release
92+
if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
93+
uses: softprops/action-gh-release@v3
94+
with:
95+
tag_name: v${{ steps.bump.outputs.version }}
96+
generate_release_notes: true
97+
make_latest: 'true'

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Go build/test output
2+
*.test
3+
*.out
4+
coverage.txt
5+
6+
# IDE
7+
.vs/
8+
.idea/
9+
*.user
10+
11+
# Local secrets
12+
.env
13+
.env.local
14+
*.env.*
15+
16+
# Maintainer-only, never published or pushed
17+
CLAUDE.md
18+
docs/todo.md

0 commit comments

Comments
 (0)