Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
๐Ÿš€ ci(goreleaser.yml): update goreleaser config to include separate buโ€ฆ
Browse files Browse the repository at this point in the history
โ€ฆilds for linux-amd64, darwin-amd64, and darwin-arm64

๐Ÿ” chore(.gitignore): add flags/version.txt to .gitignore

๐Ÿ†• chore(.goreleaser): add support for darwin-arm64 builds

๐Ÿš€ chore(goreleaser): add linux-amd64 build configuration
๐Ÿ”จ chore(Makefile): add generate target
๐Ÿ”จ chore(flags): add version variable and generate script
๐Ÿ”จ chore(cli): add version variable to kong.Vars

๐Ÿš€ feat(commands.go): add version flag to print version information and quit
๐Ÿ“ docs(commands.go): add help text for version flag
๐Ÿ“ docs(commands.go): add help text for count-tokens command
๐Ÿ› fix(get_version.sh): add newline at the end of file
  • Loading branch information
kamushadenes committed Mar 29, 2023
1 parent 48d0eb5 commit f54865e
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 12 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ permissions:
contents: write

jobs:
linux:
linux-amd64:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -35,12 +35,12 @@ jobs:
with:
distribution: goreleaser
version: latest
args: release --config .goreleaser/linux.yaml --clean
args: release --config .goreleaser/linux-amd64.yaml --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: mock

macos:
darwin-amd64:
runs-on: macos-latest
steps:
- name: Checkout
Expand All @@ -64,12 +64,12 @@ jobs:
with:
distribution: goreleaser
version: latest
args: release --config .goreleaser/macos.yaml --clean
args: release --config .goreleaser/darwin-amd64.yaml --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: mock

macos-m1:
darwin-arm64:
runs-on: macos-latest
steps:
- name: Checkout
Expand All @@ -94,7 +94,7 @@ jobs:
with:
distribution: goreleaser
version: latest
args: release --config .goreleaser/macos-m1.yaml --clean
args: release --config .goreleaser/darwin-arm64.yaml --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: mock
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ cmd/chloe/chloe
logging.iml

dist/
flags/version.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ archives:
- goos: windows
format: zip
checksum:
name_template: checksums-macos.txt
name_template: checksums-darwin-amd64.txt
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ archives:
- goos: windows
format: zip
checksum:
name_template: checksums-macos-m1.txt
name_template: checksums-darwin-arm64.txt
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ archives:
- goos: windows
format: zip
checksum:
name_template: checksums-linux.txt
name_template: checksums-linux-amd64.txt
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ ifdef TARGET
target := --target ${TARGET}
endif

.PHONY: all tokenizer build clean
.PHONY: all tokenizer generate build clean

all: tokenizer build

tokenizer:
cd tokenizer && cargo -C tiktoken-cffi build ${target} --release -Z unstable-options --out-dir .

build: tokenizer
generate:
go generate ./...

build: tokenizer generate
CGO_ENABLED=1 go build -o ./cmd/chloe/chloe ./cmd/chloe/main.go

clean:
Expand Down
8 changes: 8 additions & 0 deletions flags/flags.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
package flags

import (
_ "embed"
)

var InteractiveCLI bool

//go:generate bash ../scripts/get_version.sh
//go:embed version.txt
var Version string
6 changes: 5 additions & 1 deletion interfaces/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cli
import (
"context"
"github.com/alecthomas/kong"
"github.com/kamushadenes/chloe/flags"
"github.com/kamushadenes/chloe/memory"
)

Expand All @@ -29,7 +30,10 @@ func Handle(ctx context.Context) error {
kong.UsageOnError(),
kong.ConfigureHelp(kong.HelpOptions{
Compact: true,
}))
}),
kong.Vars{
"version": flags.Version,
})

return kongCtx.Run(&Globals{Context: ctx})
}
Expand Down
11 changes: 11 additions & 0 deletions interfaces/cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,23 @@ var CLIFlags struct {
TTS TTSCmd `cmd:"tts" short:"t" help:"Generate an audio from a prompt"`
Forget ForgetCmd `cmd:"forget" short:"f" help:"Forget all users"`
CountTokens CountTokensCmd `cmd:"count-tokens" help:"Count tokens"`
Version VersionFlag `name:"version" help:"Print version information and quit"`
}

func parseFlags() *kong.Context {
return kong.Parse(&CLIFlags)
}

type VersionFlag string

func (v VersionFlag) Decode(ctx *kong.DecodeContext) error { return nil }
func (v VersionFlag) IsBool() bool { return true }
func (v VersionFlag) BeforeApply(app *kong.Kong, vars kong.Vars) error {
fmt.Println(vars["version"])
app.Exit(0)
return nil
}

type CompleteCmd struct {
Prompt []string `arg:"" optional:"" help:"Prompt to complete"`
}
Expand Down
2 changes: 2 additions & 0 deletions scripts/get_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
git describe --tags --abbrev=0 > version.txt

0 comments on commit f54865e

Please sign in to comment.