diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..99f12d2 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "monthly" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..de2b5c3 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,36 @@ +name: build-and-test-gfn +on: [push, pull_request] +jobs: + build: + strategy: + matrix: + version: [1.23.5] + os: [ubuntu-latest, windows-latest, macos-latest] + name: Build + runs-on: ${{ matrix.os }} + steps: + - name: Set up Go ${{ matrix.os }} + uses: actions/setup-go@v5 + with: + go-version: '${{ matrix.version }}' + id: go + + - name: checkout + uses: actions/checkout@v4 + + - name: build + run: go build + + - name: test + run: make test + + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v5 + with: + go-version: 1.23 + - uses: actions/checkout@v4 + - name: golangci-lint + uses: golangci/golangci-lint-action@v8 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..d0ca1cf --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,87 @@ +name: build-release +on: + push: + tags: + - "v*.*.*" + +jobs: + release: + name: Build Release Assets + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.23.5 + + - name: Build the executables + run: ./mkrel.sh ts ${{ github.ref_name}} + + - name: List the executables + run: ls -l ./releases + + - name: Upload the binaries + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref_name }} + file: ./releases/* + file_glob: true + + - name: Build Changelog + id: github_release + uses: mikepenz/release-changelog-builder-action@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + mode: "PR" + configurationJson: | + { + "template": "#{{CHANGELOG}}\n\n**Full Changelog**: #{{RELEASE_DIFF}}", + "pr_template": "- #{{TITLE}} (##{{NUMBER}}) by #{{AUTHOR}}\n#{{BODY}}", + "empty_template": "- no changes", + "categories": [ + { + "title": "## New Features", + "labels": ["add", "feature"] + }, + { + "title": "## Bug Fixes", + "labels": ["fix", "bug", "revert"] + }, + { + "title": "## Documentation Enhancements", + "labels": ["doc"] + }, + { + "title": "## Refactoring Efforts", + "labels": ["refactor"] + }, + { + "title": "## Miscellaneus Changes", + "labels": [] + } + ], + "ignore_labels": [ + "duplicate", "good first issue", "help wanted", "invalid", "question", "wontfix" + ], + "label_extractor": [ + { + "pattern": "(.) (.+)", + "target": "$1" + }, + { + "pattern": "(.) (.+)", + "target": "$1", + "on_property": "title" + } + ] + } + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + body: ${{steps.github_release.outputs.changelog}} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..add81b8 --- /dev/null +++ b/Makefile @@ -0,0 +1,87 @@ +# Copyright © 2024 Thomas von Dein + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +# +# no need to modify anything below +tool = gfn +VERSION = $(shell grep VERSION config.go | head -1 | cut -d '"' -f2) +archs = darwin freebsd linux windows +PREFIX = /usr/local +UID = root +GID = 0 +HAVE_POD := $(shell pod2text -h 2>/dev/null) + +all: buildlocal + + +buildlocal: + CGO_LDFLAGS='-static' go build -tags osusergo,netgo -ldflags "-extldflags=-static" -o $(tool) + +install: buildlocal + install -d -o $(UID) -g $(GID) $(PREFIX)/bin + install -d -o $(UID) -g $(GID) $(PREFIX)/man/man1 + install -o $(UID) -g $(GID) -m 555 $(tool) $(PREFIX)/sbin/ + install -o $(UID) -g $(GID) -m 444 $(tool).1 $(PREFIX)/man/man1/ + +clean: + rm -rf $(tool) coverage.out testdata t/out + +test: clean + mkdir -p t/out + go test ./... $(ARGS) + +testlint: test lint + +lint: + golangci-lint run + +lint-full: + golangci-lint run --enable-all --exclude-use-default --disable exhaustivestruct,exhaustruct,depguard,interfacer,deadcode,golint,structcheck,scopelint,varcheck,ifshort,maligned,nosnakecase,godot,funlen,gofumpt,cyclop,noctx,gochecknoglobals,paralleltest + +testfuzzy: clean + go test -fuzz ./... $(ARGS) + +singletest: + @echo "Call like this: make singletest TEST=TestPrepareColumns ARGS=-v" + go test -run $(TEST) $(ARGS) + +cover-report: + go test ./... -cover -coverprofile=coverage.out + go tool cover -html=coverage.out + +goupdate: + go get -t -u=patch ./... + +buildall: + ./mkrel.sh $(tool) $(VERSION) + +release: + gh release create v$(VERSION) --generate-notes + +show-versions: buildlocal + @echo "### gfn version:" + @./gfn -V + + @echo + @echo "### go module versions:" + @go list -m all + + @echo + @echo "### go version used for building:" + @grep -m 1 go go.mod + +# lint: +# golangci-lint run -p bugs -p unused diff --git a/README.md b/README.md index 96b17c6..e7086a9 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,81 @@ # ts + generic cli timestamp parser and calculator tool + +# Usage + +```default +This is ts, a timestamp tool. + +Usage: ts