Skip to content

Commit c96d3e0

Browse files
authored
feat: update CLI code base to use latest major version of the Go API client (#178)
1 parent 3973707 commit c96d3e0

File tree

157 files changed

+4265
-3026
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+4265
-3026
lines changed

.envrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
# Automatically sets up your devbox environment whenever you cd into this
4+
# directory via our direnv integration:
5+
6+
eval "$(devbox generate direnv --print-envrc)"
7+
8+
# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/
9+
# for more details

.github/workflows/api-specs-pr.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ name: Scheduled API Specs Pull Request
22
on:
33
schedule:
44
- cron: '0 */12 * * *'
5-
65
jobs:
76
api-specs-pr:
87
runs-on: ubuntu-latest
98
steps:
10-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v4
1110
- name: Set up Go
12-
uses: actions/setup-go@v2
11+
uses: actions/setup-go@v5
1312
with:
14-
go-version: 1.19
15-
- run: |
16-
git config --global user.name "algolia-ci"
17-
git config --global user.email "[email protected]"
13+
go-version: 1.23
1814
- run: make api-specs-pr
1915
env:
20-
GH_TOKEN: ${{ secrets.GH_SECRET }}
16+
GH_TOKEN: ${{ secrets.GH_SECRET }}
17+
GIT_COMMITTER_NAME: algolia-ci
18+
GIT_AUTHOR_NAME: algolia-ci
19+
GIT_COMMITTER_EMAIL: [email protected]
20+
GIT_AUTHOR_EMAIL: [email protected]

.github/workflows/go.yml

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
name: Go
2-
32
on:
43
push:
54
branches: [main]
65
pull_request:
76
branches: [main]
8-
97
jobs:
108
build:
119
runs-on: ubuntu-latest
1210
steps:
13-
- uses: actions/checkout@v2
14-
11+
- uses: actions/checkout@v4
1512
- name: Set up Go
16-
uses: actions/setup-go@v2
13+
uses: actions/setup-go@v5
1714
with:
18-
go-version: 1.19
19-
15+
go-version: 1.23
2016
- name: Build
2117
run: go build -v ./...
22-
2318
- name: Test
2419
run: go test -v ./...

.github/workflows/golangci-lint.yml

+5-25
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,11 @@ jobs:
1414
name: lint
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/setup-go@v3
17+
- uses: actions/setup-go@v5
1818
with:
19-
go-version: 1.18
20-
- uses: actions/checkout@v3
19+
go-version: 1.23
20+
- uses: actions/checkout@v4
2121
- name: golangci-lint
22-
uses: golangci/golangci-lint-action@v3
22+
uses: golangci/golangci-lint-action@v6
2323
with:
24-
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
25-
version: v1.47.3
26-
27-
# Optional: working directory, useful for monorepos
28-
# working-directory: somedir
29-
30-
# Optional: golangci-lint command line arguments.
31-
# args: --issues-exit-code=0
32-
33-
# Optional: show only new issues if it's a pull request. The default value is `false`.
34-
# only-new-issues: true
35-
36-
# Optional: if set to true then the all caching functionality will be complete disabled,
37-
# takes precedence over all other caching options.
38-
# skip-cache: true
39-
40-
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
41-
# skip-pkg-cache: true
42-
43-
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
44-
# skip-build-cache: true
24+
version: v1.63.4

.github/workflows/releases.yml

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
name: goreleaser
2-
32
on:
43
push:
54
tags:
65
- "v*"
7-
86
permissions:
9-
contents: write # publishing releases
10-
7+
contents: write # publishing releases
118
jobs:
129
release:
1310
runs-on: ubuntu-latest
1411
steps:
1512
- name: Code checkout
16-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1714
with:
1815
fetch-depth: 0
1916
- name: Set up Go
20-
uses: actions/setup-go@v2
17+
uses: actions/setup-go@v5
2118
with:
22-
go-version: 1.19
19+
go-version: 1.23
2320
- name: Install chocolatey
2421
run: |
2522
mkdir -p /opt/chocolatey
@@ -30,15 +27,15 @@ jobs:
3027
env:
3128
CHOCOLATEY_VERSION: 1.2.0
3229
- name: Run GoReleaser
33-
uses: goreleaser/goreleaser-action@v2.8.0
30+
uses: goreleaser/goreleaser-action@v6
3431
with:
35-
version: "~1.13.1"
32+
version: "~> v2"
3633
args: release
3734
env:
3835
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
3936
CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}
4037
- name: Docs checkout
41-
uses: actions/checkout@v3
38+
uses: actions/checkout@v4
4239
with:
4340
repository: algolia/doc
4441
path: docs
@@ -53,4 +50,3 @@ jobs:
5350
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
5451
run: |
5552
make docs-pr
56-
make VARIATON=new docs-pr

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ vendor/
1818
# local build
1919
algolia
2020

21-
# Ignore docs directory
22-
docs/
21+
# Environment variables
22+
*.env

.golangci.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
linters:
2+
enable:
3+
- gosec
4+
- gofumpt
5+
- stylecheck

Dockerfile

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
FROM alpine
2-
RUN apk update && apk upgrade && \
3-
apk add --no-cache ca-certificates
4-
COPY algolia /bin/algolia
5-
ENTRYPOINT ["/bin/algolia"]
1+
# Build the binary
2+
FROM golang:1.23-alpine AS builder
3+
WORKDIR /app
4+
COPY . .
5+
ARG VERSION=docker
6+
RUN apk update && apk add --no-cache curl
7+
RUN go mod download
8+
RUN go install github.com/go-task/task/v3/cmd/task@latest
9+
RUN task download-spec-file && VERSION=${VERSION} task build
10+
11+
FROM alpine:3
12+
RUN apk update && apk upgrade && apk add --no-cache ca-certificates
13+
COPY --from=builder /app/algolia /bin/algolia
14+
ENTRYPOINT ["/bin/algolia"]

README.md

+40-20
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,69 @@
11
# Algolia CLI
22

3-
A command line interface to enable Algolia developers to interact with and configure their Algolia applications straight from a command line or terminal window. Automate common workloads, create snapshots, revert to backups, or quickly modify applications as needed! This is a lightweight tool, providing a text-only interface, that is easy to install and use!
3+
The Algolia CLI lets you work with your Algolia resources,
4+
such as indices, records, API keys, and synonyms,
5+
and from the command line.
46

57
![cli](https://user-images.githubusercontent.com/5702266/153008646-1fd8fbf2-4a4d-4421-b2f2-0886487f3e27.png)
68

79
## Documentation
810

9-
See the [documentation](https://algolia.com/doc/tools/cli/) for setup and usage instructions.
11+
See [Algolia CLI](https://algolia.com/doc/tools/cli/) in the Algolia documentation for setup and usage instructions.
1012

1113
## Installation
1214

13-
### Build from Source
15+
### macOS
1416

15-
A `Makefile` is available to help installing and building the CLI.
17+
The Algolia CLI is available on [Homebrew](https://brew.sh/) and as a downloadable binary from the [releases page](https://github.com/algolia/cli/releases).
1618

17-
```bash
18-
git clone [email protected]:algolia/cli.git && make install
19+
```sh
20+
brew install algolia/algolia-cli/algolia
1921
```
2022

21-
### MacOS
23+
### Linux
2224

23-
`algolia` is available on Homebrew and as a downloadable binary from the [releases page](https://github.com/algolia/cli/releases).
25+
The Algolia CLI is available as a `.deb` package:
2426

25-
```bash
26-
brew tap algolia/algolia-cli && brew install algolia
27+
```sh
28+
# Select the package appropriate for your platform:
29+
sudo dpkg -i algolia_*.deb
30+
```
31+
32+
as a `.rpm` package:
33+
34+
```sh
35+
# Select the package appropriate for your platform
36+
sudo rpm -i algolia_*.rpm
37+
```
38+
39+
or as a tarball from the [releases page](https://github.com/algolia/cli/releases):
40+
41+
```sh
42+
# Select the archive appropriate for your platform
43+
tar xvf algolia_*_linux_*.tar.gz
2744
```
2845

2946
### Windows
3047

31-
`algolia` is available via [Chocolatey](https://community.chocolatey.org/packages/algolia/) and as downloadable .exe files.
48+
The Algolia CLI is available via [Chocolatey](https://community.chocolatey.org/packages/algolia/) and as a downloadable binary from the [releases page](https://github.com/algolia/cli/releases)
3249

33-
#### Chocolatey
50+
### Community packages
3451

35-
| Install: | Upgrade: |
36-
| ------------------ | ------------------ |
37-
| `choco install algolia` | `choco upgrade algolia` |
52+
Other packages are maintained by the community, not by Algolia.
53+
If you distribute a package for the Algolia CLI, create a pull request so that we can list it here!
3854

39-
#### Executable
55+
### Build from source
4056

41-
Executable files are available on the [releases page](https://github.com/algolia/cli/releases).
57+
To build the Algolia CLI from source, you'll need:
4258

43-
### Other platforms
59+
- Go version 1.23 or later
60+
- [Go task](https://taskfile.dev/)
4461

45-
Download packaged binaries from the [releases page](https://github.com/algolia/cli/releases).
62+
1. Clone the repo: `git clone https://github.com/kai687/cli.git algolia-cli && cd algolia-cli`
63+
1. Run: `task build`
4664

4765
## Support
4866

49-
Found a bug on the CLI? [Open a new issue](https://github.com/algolia/cli/issues/new) or [contact the support](https://www.algolia.com/support/) to get help with Algolia!
67+
If you found an issue with the Algolia CLI,
68+
[open a new GitHub issue](https://github.com/algolia/cli/issues/new),
69+
or join the Algolia community on [Discord](https://alg.li/discord).

0 commit comments

Comments
 (0)