Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/go
{
"name": "Go 1.23",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/go:1-1.23-bullseye",

"mounts": [
"type=bind,source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,readonly"
],

"settings": {
"workbench.colorCustomizations": {
"statusBar.background": "#ff4088",
"statusBar.foreground": "#ffffff"
}
},
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
}

}
26 changes: 26 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Go Test

on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.23' ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Install dependencies
run: go get .
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.62.2
- name: Run unit-tests
run: go test -v ./...

19 changes: 19 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

name: release-please

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.RELEASE_TOKEN }}
release-type: go
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: release

on:
push:
tags:
- "*"

permissions:
contents: write

env:
GO_VERSION: "1.23"

jobs:
manual-release:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Perform cross builds
run: make cross

- name: Compress binaries
run: |
cd out
tar czf web3datacli_${GITHUB_REF#refs/tags/}_darwin_amd64.tar.gz web3datacli_${GITHUB_REF#refs/tags/}_darwin_amd64/
tar czf web3datacli_${GITHUB_REF#refs/tags/}_linux_amd64.tar.gz web3datacli_${GITHUB_REF#refs/tags/}_linux_amd64/

- name: Get git tag
run: echo "tag=$(git describe --tags --exact-match HEAD)" >> $GITHUB_ENV

- name: Publish binaries
uses: svenstaro/upload-release-action@04733e069f2d7f7f0b4aebc4fbdbce8613b03ccd # 2.9.0
with:
repo_token: ${{ secrets.RELEASE_TOKEN }}
tag: ${{ env.tag }}
release_name: ${{ env.tag }}
file_glob: true
file: out/*.tar.gz
overwrite: true
63 changes: 63 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
linters-settings:
errcheck:
check-type-assertions: true
exhaustive:
default-signifies-exhaustive: true
goconst:
min-len: 2
min-occurrences: 3
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
govet:
enable-all: true
stylecheck:
checks: ["ST1000", "ST1001"]
nolintlint:
require-explanation: true
require-specific: true
wsl:
allow-assign-and-anything: true
allow-cuddle-declarations: true
allow-assign-and-call: true

linters:
disable-all: true
enable:
- bodyclose
- dogsled
- dupl
- errcheck
- copyloopvar
- exhaustive
- goconst
- gofmt
- goimports
- govet
- mnd
- gocyclo
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nolintlint
- nakedret
- prealloc
- predeclared
- staticcheck
- stylecheck
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- whitespace
- wsl

run:
issues-exit-code: 1
1 change: 1 addition & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ ".": "1.0.0" }
36 changes: 36 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.DEFAULT_GOAL := help

BIN_NAME := web3datacli
BUILD_DIR := ./out

GIT_SHA := $(shell git rev-parse HEAD | cut -c 1-8)
GIT_TAG := $(shell git describe --tags)
DATE := $(shell date +%s)
VERSION_FLAGS=\
-X github.com/thewhitewizard/web3data-cli/cmd/version.Version=$(GIT_TAG) \
-X github.com/thewhitewizard/web3data-cli/cmd/version.Commit=$(GIT_SHA) \
-X github.com/thewhitewizard/web3data-cli/cmd/version.Date=$(DATE) \
-X github.com/thewhitewizard/web3data-cli/cmd/version.BuiltBy=makefile

.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Build

.PHONY: $(BUILD_DIR)
$(BUILD_DIR): ## Create the build folder.
mkdir -p $(BUILD_DIR)

.PHONY: build
build: $(BUILD_DIR) ## Build go binary.
go build -ldflags "$(VERSION_FLAGS)" -o $(BUILD_DIR)/$(BIN_NAME) main.go

.PHONY: cross
cross: $(BUILD_DIR) ## Cross-compile go binaries without using CGO.
GOOS=linux GOARCH=amd64 go build -o $(BUILD_DIR)/$(BIN_NAME)_$(GIT_TAG)_linux_amd64 main.go
GOOS=darwin GOARCH=amd64 go build -o $(BUILD_DIR)/$(BIN_NAME)_$(GIT_TAG)_darwin_amd64 main.go

.PHONY: clean
clean: ## Clean the binary folder.
$(RM) -r $(BUILD_DIR)
20 changes: 20 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cmd

import (
"github.com/thewhitewizard/web3data-cli/cmd/version"

"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "web3datacli",
Long: `A CLI tool to manage web3data`,
}

func Execute() {
cobra.CheckErr(rootCmd.Execute())
}

func init() {
rootCmd.AddCommand(version.VersionCmd)
}
21 changes: 21 additions & 0 deletions cmd/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package version

import (
"github.com/spf13/cobra"
)

var (
Version = "dev"
Commit = "none"
Date = "unknown"
BuiltBy = "unknown"
)

var VersionCmd = &cobra.Command{
Use: "version",
Short: "Get the current version of this application",
Long: `Nothing fancy. Print the version of this application`,
Run: func(cmd *cobra.Command, args []string) {
cmd.Printf("web3datacli Version %s\n", Version)
},
}
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/thewhitewizard/web3data-cli

go 1.23.4

require github.com/spf13/cobra v1.9.1

require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/pflag v1.0.6 // indirect
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import (
"github.com/thewhitewizard/web3data-cli/cmd"
)

func main() {
cmd.Execute()
}
28 changes: 28 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"changelog-sections": [
{ "type": "feat", "section": "🚀 Features", "hidden": false },
{ "type": "change", "section": "🚀 Features", "hidden": false },
{ "type": "deprecate", "section": "⚠️ Changes", "hidden": false },
{ "type": "remove", "section": "⚠️ Changes", "hidden": false },
{ "type": "fix", "section": "🐞 Bug Fixes", "hidden": false },
{ "type": "revert", "section": "🐞 Bug Fixes", "hidden": false },
{ "type": "security", "section": "🐞 Bug Fixes", "hidden": false },
{ "type": "perf", "section": "✨ Polish", "hidden": false },
{ "type": "refactor", "section": "✨ Polish", "hidden": false },
{ "type": "style", "section": "✨ Polish", "hidden": false },
{ "type": "build", "section": "🧰 Other", "hidden": false },
{ "type": "chore", "section": "🧰 Other", "hidden": false },
{ "type": "deps", "section": "🧰 Other", "hidden": true },
{ "type": "ci", "section": "🧰 Other", "hidden": true },
{ "type": "test", "section": "🧪 Tests", "hidden": false },
{ "type": "docs", "section": "📚 Documentation", "hidden": true }
],
"packages": {
".": {
"include-component-in-tag": false,
"release-type": "go",
"changelog-path": "CHANGELOG.md"
}
}
}