Skip to content
This repository has been archived by the owner on Aug 26, 2023. It is now read-only.

Commit

Permalink
feat: add fork code (#11)
Browse files Browse the repository at this point in the history
* feature(main): add gitw code

Signed-off-by: cuisongliu <cuisongliu@qq.com>

* feature(main): add maintainer code

Signed-off-by: cuisongliu <cuisongliu@qq.com>

---------

Signed-off-by: cuisongliu <cuisongliu@qq.com>
  • Loading branch information
cuisongliu authored Jun 7, 2023
1 parent 73be566 commit c6bc0b9
Show file tree
Hide file tree
Showing 102 changed files with 9,341 additions and 0 deletions.
36 changes: 36 additions & 0 deletions fork/github.com/gookit/gitw/.github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: inhere

---

**System (please complete the following information):**

- OS: `linux` [e.g. linux, macOS]
- GO Version: `1.13` [e.g. `1.13`]
- Pkg Version: `1.1.1` [e.g. `1.1.1`]

**Describe the bug**

A clear and concise description of what the bug is.

**To Reproduce**

```go
// go code
```

**Expected behavior**

A clear and concise description of what you expected to happen.

**Screenshots**

If applicable, add screenshots to help explain your problem.

**Additional context**

Add any other context about the problem here.
37 changes: 37 additions & 0 deletions fork/github.com/gookit/gitw/.github/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
title: '## Change Log'
# style allow: simple, markdown(mkdown), ghr(gh-release)
style: gh-release
# group names
names: [Refactor, Fixed, Feature, Update, Other]
# if empty will auto fetch by git remote
#repo_url: https://github.com/gookit/gitw

filters:
# message length should >= 12
- name: msg_len
min_len: 12
# message words should >= 3
- name: words_len
min_len: 3
- name: keyword
keyword: format code
exclude: true
- name: keywords
keywords: format code, action test
exclude: true

# group match rules
# not matched will use 'Other' group.
rules:
- name: Refactor
start_withs: [refactor, break]
contains: ['refactor:']
- name: Fixed
start_withs: [fix]
contains: ['fix:']
- name: Feature
start_withs: [feat, new]
contains: ['feat:']
- name: Update
start_withs: [update, 'up:']
contains: ['update:']
13 changes: 13 additions & 0 deletions fork/github.com/gookit/gitw/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10

- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: "daily"
66 changes: 66 additions & 0 deletions fork/github.com/gookit/gitw/.github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Unit-Tests
on:
pull_request:
paths:
- 'go.mod'
- '**.go'
- '**.yml'
push:
paths:
- '**.go'
- 'go.mod'
- '**.yml'

# https://github.com/actions
jobs:

test:
name: Test on go ${{ matrix.go_version }}
runs-on: ubuntu-latest
strategy:
matrix:
go_version: [1.18, 1.19, '1.20']

steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0

- run: git fetch --force --tags

- name: Display Env
run: |
git remote -v
git tag -l
env
- name: Setup Go Faster
uses: WillAbides/setup-go-faster@v1.8.0
timeout-minutes: 3
with:
go-version: ${{ matrix.go_version }}

- name: Revive check
uses: docker://morphy/revive-action:v2.3.1
with:
# Exclude patterns, separated by semicolons (optional)
exclude: "./internal/..."

- name: Run static check
uses: reviewdog/action-staticcheck@v1
if: ${{ github.event_name == 'pull_request'}}
with:
github_token: ${{ secrets.github_token }}
# Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review].
reporter: github-pr-check
# Report all results. [added,diff_context,file,nofilter].
filter_mode: added
# Exit with 1 when it find at least one finding.
fail_on_error: true

- name: Run tests
run: |
pwd
go test -v -cover ./...
# go run ./cmd/chlog last head
54 changes: 54 additions & 0 deletions fork/github.com/gookit/gitw/.github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Tag-release

on:
push:
tags:
- v*

jobs:
release:
name: Release new version
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Go Faster
uses: WillAbides/setup-go-faster@v1.8.0
timeout-minutes: 3
with:
go-version: 1.18

- name: Setup ENV
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
run: |
echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
echo "RELEASE_NAME=$GITHUB_WORKFLOW" >> $GITHUB_ENV
- name: Build bin package
run: make build-all

- name: Generate changelog
run: |
go install ./cmd/chlog
chlog -c .github/changelog.yml -o changelog.md prev last
# https://github.com/softprops/action-gh-release
- name: Create release and upload assets
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ env.RELEASE_TAG }}
tag_name: ${{ env.RELEASE_TAG }}
body_path: changelog.md
token: ${{ secrets.GITHUB_TOKEN }}
files: |
build/chlog-darwin-amd64
build/chlog-linux-amd64
build/chlog-linux-arm
build/chlog-windows-amd64.exe
22 changes: 22 additions & 0 deletions fork/github.com/gookit/gitw/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
*.log
*.swp
.idea
*.patch
### Go template
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
.DS_Store
/build
/vendor
/testdata
/main
20 changes: 20 additions & 0 deletions fork/github.com/gookit/gitw/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2016 inhere

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
64 changes: 64 additions & 0 deletions fork/github.com/gookit/gitw/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# link https://github.com/humbug/box/blob/master/Makefile
#SHELL = /bin/sh
.DEFAULT_GOAL := help
# 每行命令之前必须有一个tab键。如果想用其他键,可以用内置变量.RECIPEPREFIX 声明
# mac 下这条声明 没起作用 !!
#.RECIPEPREFIX = >
.PHONY: all usage help clean

# 需要注意的是,每行命令在一个单独的shell中执行。这些Shell之间没有继承关系。
# - 解决办法是将两行命令写在一行,中间用分号分隔。
# - 或者在换行符前加反斜杠转义 \
# 接收命令行传入参数 make COMMAND tag=v2.0.4
# TAG=$(tag)

BIN_NAME=chlog
MAIN_SRC_FILE=cmd/chlog/main.go
ROOT_PACKAGE := main
VERSION=$(shell git for-each-ref refs/tags/ --count=1 --sort=-version:refname --format='%(refname:short)' 1 | sed 's/^v//')

# Full build flags used when building binaries. Not used for test compilation/execution.
BUILD_FLAGS := -ldflags \
" -X $(ROOT_PACKAGE).Version=$(VERSION)"

##there some make command for the project
##

help:
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' | sed -e 's/: / /'

##Available Commands:

ins2bin: ## Install to GOPATH/bin
go build $(BUILD_FLAGS) -o $(GOPATH)/bin/chlog $(MAIN_SRC_FILE)
chmod +x $(GOPATH)/bin/chlog

build-all:linux arm win darwin ## Build for Linux,ARM,OSX,Windows

linux: ## Build for Linux
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o build/$(BIN_NAME)-linux-amd64 $(MAIN_SRC_FILE)
chmod +x build/$(BIN_NAME)-linux-amd64

arm: ## Build for ARM
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=arm go build $(BUILD_FLAGS) -o build/$(BIN_NAME)-linux-arm $(MAIN_SRC_FILE)
chmod +x build/$(BIN_NAME)-linux-arm

win: ## Build for Windows
CGO_ENABLED=$(CGO_ENABLED) GOOS=windows GOARCH=amd64 go build $(BUILD_FLAGS) -o build/$(BIN_NAME)-windows-amd64.exe $(MAIN_SRC_FILE)

darwin: ## Build for OSX
CGO_ENABLED=$(CGO_ENABLED) GOOS=darwin GOARCH=amd64 go build $(BUILD_FLAGS) -o build/$(BIN_NAME)-darwin-amd64 $(MAIN_SRC_FILE)
chmod +x build/$(BIN_NAME)-darwin-amd64

clean: ## Clean all created artifacts
clean:
git clean --exclude=.idea/ -fdx

cs-fix: ## Fix code style for all files
cs-fix:
gofmt -w ./

cs-diff: ## Display code style error files
cs-diff:
gofmt -l ./
Loading

0 comments on commit c6bc0b9

Please sign in to comment.