go-cobra-cli
[[TOC]]
Overview
go-cobra-cli
is a full, working implementation of a go
cli application; the following
project is a template that can be forked, copied for private or personal usage.
The remaining README.md
's contents is for non-template usage. Of course, replace
section(s) where appropriate -- namely go-cobra-cli
and VCS references.
Getting Started
Installing
brew tap iac-factory/homebrew-taps
# --> GitLab Private Configuration Example
# brew tap ethr/homebrew-go-cobra-cli-tap [email protected]:ethrgg/templates/homebrew-go-cobra-cli-tap
# brew install iac-factory/taps/go-cobra-cli --verbose --debug
# --> Simplified
brew install go-cobra-cli
Upgrading
brew update && brew upgrade go-cobra-cli
Reinstalling
brew update
brew unlink go-cobra-cli
brew install go-cobra-cli
Pre-Commit
-
Install pre-commit from https://pre-commit.com/#install
-
Create a .pre-commit-config.yaml
file at the root of the repository with the following content:
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: latest
hooks:
- id: gitleaks
-
Auto-update the config to the latest repos' versions by executing pre-commit autoupdate
-
Install with pre-commit install
Deployment & Initial Setup (Maintainers)
The following section is intended only for project maintainers & developers.
- Please see the getting started section for installation and upgrade instructions.
-
Install goreleaser
if it isn't installed
brew install goreleaser/tap/goreleaser
-
Initialize the repository for new repositories
goreleaser init
-
Test the snapshot without VCS deployment
goreleaser release --snapshot --clean
-
Configure the default system's local gitlab_token
or github_token
secret
mkdir -p ~/.config/goreleaser && touch ~/.config/goreleaser/gitlab_token
mkdir -p ~/.config/goreleaser && touch ~/.config/goreleaser/github_token
-
Commit and push to VCS
git add . && git commit -m "CI - Example" && git push
-
List git
tags to get a version that isn't already established
git tag --list
-
Using the output from above, increment the version and push a new tag
git tag -a v0.0.1 -m "Bump: Initial Release" && git push origin v0.0.1
-
Create and push a new release
goreleaser release --clean
-
Update local Formula
to include the new tag (only applicable for private projects)
sed -i -e "s/using: GitDownloadStrategy/using: GitDownloadStrategy, tag: \"$(git tag --points-at HEAD)\"/g" ./dist/homebrew/Formula/go-cobra-cli.rb
-
Copy the updated Formula
to system clipboard (only applicable for private projects)
cat ./dist/homebrew/Formula/go-cobra-cli.rb | pbcopy
-
Update the Homebrew Tap's *.rb file with clipboard's contents (only applicable for private projects)
-
Tap the repository using git+ssh
protocol (only applicable for private repositories)
brew tap iac-factory/homebrew-taps [email protected]:iac-factory/homebrew-taps
-
Update the Cask if already established
brew update
-
Install the package (see the installation section)
Reference(s)
Useful Command(s)
Tags
# --> Delete Remote Tag
git push origin --delete v0.0.0
# --> HEAD Tag
git tag --points-at HEAD
SSH Agent
eval "$(ssh-agent -s)"