From 4726fe683353e55d7ca37e33f2d6fd0fe5ca1014 Mon Sep 17 00:00:00 2001 From: chuksgpfr Date: Thu, 20 Nov 2025 21:45:49 +0100 Subject: [PATCH 1/2] added hombrew for goreleaser --- .goreleaser.yaml | 99 +++++++++++++++++++++++++++++++++++++++--------- go.mod | 8 ++-- go.sum | 11 ++++++ 3 files changed, 98 insertions(+), 20 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index d53627b..60da0bf 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -16,27 +16,71 @@ before: - go generate ./... builds: - - env: - - CGO_ENABLED=0 + - id: linux-amd64 + binary: zing-{{ .Os }}-{{ .Arch }} + # main: ./main.go goos: - linux - - windows + goarch: + - amd64 + # ldflags: + # - "{{ .Env.LDFLAGS }}" + no_unique_dist_dir: true + + - id: darwin-amd64 + binary: zing-{{ .Os }}-{{ .Arch }} + # main: ./main.go + goos: - darwin + goarch: + - amd64 + # ldflags: + # - "{{ .Env.LDFLAGS }}" + no_unique_dist_dir: true + - id: darwin-arm64 + binary: zing-{{ .Os }}-{{ .Arch }} + # main: ./main.go + goos: + - darwin + goarch: + - arm64 # M1, M2, M3, M4 all use this + # ldflags: + # - "{{ .Env.LDFLAGS }}" + no_unique_dist_dir: true + + - id: windows-amd64 + binary: zing-{{ .Os }}-{{ .Arch }} + # main: ./main.go + goos: + - windows + goarch: + - amd64 + # ldflags: + # - -buildmode=exe + # - "{{ .Env.LDFLAGS }}" + no_unique_dist_dir: true +# builds: +# - env: +# - CGO_ENABLED=0 +# goos: +# - linux +# - windows +# - darwin -archives: - - formats: [tar.gz] - # 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 - formats: [zip] +# archives: +# - formats: [tar.gz] +# # 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 +# formats: [zip] changelog: sort: asc @@ -51,3 +95,24 @@ release: --- Released by [GoReleaser](https://github.com/goreleaser/goreleaser). + + +homebrew_casks: + - name: zing # cask name (defaults to project_name if omitted) + binaries: + - zing # binary name inside the archive + + description: "Zing helps developers zing through repetitive commands." + homepage: "https://github.com/chuksgpfr/zing" + + # Where to put the generated cask file in *this same* repo + directory: Casks + + # Commit the cask to github.com/chuksgpfr/zing + repository: + owner: chuksgpfr + name: zing + + commit_author: + name: "Zing Bot" + email: "chuksgpfr+zingbot@gmail.com" diff --git a/go.mod b/go.mod index a615aa5..4ffc2c3 100644 --- a/go.mod +++ b/go.mod @@ -2,11 +2,14 @@ module github.com/chuksgpfr/zing go 1.23.0 -require github.com/fatih/color v1.18.0 +require ( + github.com/dgraph-io/badger/v4 v4.8.0 + github.com/fatih/color v1.18.0 + github.com/spf13/cobra v1.10.1 +) require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/dgraph-io/badger/v4 v4.8.0 // indirect github.com/dgraph-io/ristretto/v2 v2.2.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/go-logr/logr v1.4.3 // indirect @@ -16,7 +19,6 @@ require ( github.com/klauspost/compress v1.18.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/spf13/cobra v1.10.1 // indirect github.com/spf13/pflag v1.0.10 // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/otel v1.37.0 // indirect diff --git a/go.sum b/go.sum index 9831e4e..ae6367c 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,14 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgraph-io/badger/v4 v4.8.0 h1:JYph1ChBijCw8SLeybvPINizbDKWZ5n/GYbz2yhN/bs= github.com/dgraph-io/badger/v4 v4.8.0/go.mod h1:U6on6e8k/RTbUWxqKR0MvugJuVmkxSNc79ap4917h4w= github.com/dgraph-io/ristretto/v2 v2.2.0 h1:bkY3XzJcXoMuELV8F+vS8kzNgicwQFAaGINAEJdWGOM= github.com/dgraph-io/ristretto/v2 v2.2.0/go.mod h1:RZrm63UmcBAaYWC1DotLYBmTvgkrs0+XhBd7Npn7/zI= +github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da h1:aIftn67I1fkbMa512G+w+Pxci9hJPB8oMnkcP3iZF38= +github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= @@ -16,6 +20,8 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/google/flatbuffers v25.2.10+incompatible h1:F3vclr7C3HpB1k9mxCGRMXq6FdUalZ6H/pNX4FP1v0Q= github.com/google/flatbuffers v25.2.10+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= @@ -25,12 +31,16 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s= github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0= github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= @@ -48,4 +58,5 @@ golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 38b28ee4ab406ae0e16029b792d678c0dac4b07d Mon Sep 17 00:00:00 2001 From: chuksgpfr Date: Thu, 20 Nov 2025 22:45:34 +0100 Subject: [PATCH 2/2] added CI --- .github/workflows/ci.yml | 34 +++++++++++++++ .github/workflows/release.yml | 82 +++++++++++++++++++++++++++++++++++ README.md | 3 +- 3 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..92fbc00 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.22" + + - name: Cache Go modules + uses: actions/cache@v4 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Run tests + run: go test ./... diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..39a24df --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,82 @@ +name: Release + +on: + push: + branches: + - main + +permissions: + contents: write # needed to create tags & releases + id-token: write + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.22" + + - name: Cache Go modules + uses: actions/cache@v4 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Determine next tag + id: tag + run: | + # Get latest tag or default to v0.0.0 + LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") + echo "Last tag: $LAST_TAG" + + # Strip the leading v + VERSION=${LAST_TAG#v} + + MAJOR=$(echo "$VERSION" | cut -d. -f1) + MINOR=$(echo "$VERSION" | cut -d. -f2) + PATCH=$(echo "$VERSION" | cut -d. -f3) + + # bump patch by default; you can change this logic later + PATCH=$((PATCH + 1)) + + NEXT_TAG="v${MAJOR}.${MINOR}.${PATCH}" + echo "Next tag: $NEXT_TAG" + + echo "next_tag=$NEXT_TAG" >> $GITHUB_OUTPUT + + - name: Create tag + run: | + NEXT_TAG="${{ steps.tag.outputs.next_tag }}" + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + git tag "$NEXT_TAG" + git push origin "$NEXT_TAG" + + - name: Set LDFLAGS env + run: | + VERSION="${{ steps.tag.outputs.next_tag }}" + COMMIT="$(git rev-parse --short HEAD)" + DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" + echo "LDFLAGS=-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" >> $GITHUB_ENV + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LDFLAGS: ${{ env.LDFLAGS }} diff --git a/README.md b/README.md index ba94d79..bc054bf 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,8 @@ Automate your most frequent CLI workflows with human-friendly aliases, templates ### Install (Go example) - MacOS ```bash -brew install --cask chuksgpfr/zing +brew tap zing https://github.com/chuksgpfr/zing +brew install --cask zing ``` - Go