From e67f564d23b4afb32cc647ff80cace91a7522441 Mon Sep 17 00:00:00 2001 From: j178 <10510431+j178@users.noreply.github.com> Date: Sat, 4 Mar 2023 14:48:14 +0800 Subject: [PATCH] chore: add goreleaser and release workflow --- .github/workflows/release.yaml | 31 ++++++++++++ .goreleaser.yaml | 88 ++++++++++++++++++++++++++++++++++ README.md | 19 +++++++- 3 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yaml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..b051eef --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,31 @@ +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + packages: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - run: git fetch --force --tags + - uses: actions/setup-go@v3 + with: + go-version: '1.20.x' + cache: true + - uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + # Custom secret here since we need to access to j178/homebrew-tap and j178/scoop-bucket repo. + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..992cba6 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,88 @@ +before: + hooks: + - go mod tidy +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + flags: + - -v + - -trimpath + ldflags: + - -s + - -w + +archives: + - format: tar.gz + rlcp: true + # this name template makes the OS and Arch compatible with the results of uname. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + files: + - LICENSE* + - README* + - CHANGELOG* +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + use: github + groups: + - title: Features + regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$' + order: 0 + - title: 'Bug fixes' + regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$' + order: 1 + - title: Others + order: 999 + filters: + exclude: + - '^docs:' + - '^test:' + - '(?i)^Minor' +brews: +- tap: + owner: j178 + name: homebrew-tap + commit_author: + name: goreleaserbot + email: bot@goreleaser.com + homepage: https://github.com/j178/chatgpt + description: >- + A simple cli wrapper for ChatGPT API, powered by GPT-3.5-turbo model. + license: MIT + +scoop: + bucket: + owner: j178 + name: scoop-bucket + commit_author: + name: goreleaserbot + email: bot@goreleaser.com + folder: bucket + homepage: https://github.com/j178/chatgpt + description: >- + A simple cli wrapper for ChatGPT API, powered by GPT-3.5-turbo model. + license: MIT + +# The lines beneath this are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj diff --git a/README.md b/README.md index 0d6be55..8b0a282 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,25 @@ $ chatgpt ## Installation +You can download the latest binary from the [release page](https://github.com/j178/chatgpt/releases). + +### Install via go + +```shell +go install github.com/j178/chatgpt@latest +``` + +### Install via [HomeBrew](https://brew.sh/) on macOS/Linux + +```shell +brew install j178/tap/chatgpt +``` + +### Install via [Scoop](https://scoop.sh/) on Windows + ```shell -$ go install github.com/j178/chatgpt@latest +scoop bucket add j178 https://github.com/j178/scoop-bucket.git +scoop install j178/chatgpt ``` ## License