-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
2,308 additions
and
7 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Nightly | ||
|
||
on: [push, pull_request] | ||
|
||
env: | ||
BINARY_PREFIX: "nbp_" | ||
BINARY_SUFFIX: "" | ||
PR_PROMPT: "::warning:: Build artifact will not be uploaded due to the workflow is trigged by pull request." | ||
LD_FLAGS: "-w -s" | ||
|
||
jobs: | ||
build: | ||
name: Build binary CI | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/amd64, darwin/arm64 | ||
goos: [linux, windows] | ||
goarch: ["386", amd64, arm, arm64] | ||
exclude: | ||
- goos: windows | ||
goarch: arm | ||
- goos: windows | ||
goarch: arm64 | ||
fail-fast: true | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Setup Go environment | ||
uses: actions/setup-go@master | ||
with: | ||
go-version: "1.20" | ||
- name: Cache downloaded module | ||
uses: actions/cache@master | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ matrix.goos }}-${{ matrix.goarch }}-${{ hashFiles('**/go.sum') }} | ||
- name: Build binary file | ||
env: | ||
GOOS: ${{ matrix.goos }} | ||
GOARCH: ${{ matrix.goarch }} | ||
IS_PR: ${{ !!github.head_ref }} | ||
run: | | ||
if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi | ||
if $IS_PR ; then echo $PR_PROMPT; fi | ||
export BINARY_NAME="$BINARY_PREFIX$GOOS_$GOARCH$BINARY_SUFFIX" | ||
export CGO_ENABLED=0 | ||
go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" . | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@master | ||
if: ${{ !github.head_ref }} | ||
with: | ||
name: ${{ matrix.goos }}_${{ matrix.goarch }} | ||
path: output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: PullLint | ||
on: [ pull_request ] | ||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@master | ||
with: | ||
go-version: "1.20" | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@master | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@master | ||
with: | ||
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version | ||
version: latest | ||
|
||
# Optional: working directory, useful for monorepos | ||
# working-directory: somedir | ||
|
||
# Optional: golangci-lint command line arguments. | ||
# args: --issues-exit-code=0 | ||
|
||
# Optional: show only new issues if it's a pull request. The default value is `false`. | ||
# only-new-issues: true | ||
|
||
# Optional: if set to true then the action don't cache or restore ~/go/pkg. | ||
# skip-pkg-cache: true | ||
|
||
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build. | ||
# skip-build-cache: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: PushLint | ||
on: [ push ] | ||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@master | ||
with: | ||
go-version: "1.20" | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@master | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@master | ||
with: | ||
version: latest | ||
args: --issues-exit-code=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@master | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@master | ||
with: | ||
go-version: '"1.20"' | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@master | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
linters-settings: | ||
errcheck: | ||
ignore: fmt:.* | ||
ignoretests: true | ||
|
||
goimports: | ||
local-prefixes: github.com/FloatTech/NanoBot-Plugin | ||
|
||
forbidigo: | ||
# Forbid the following identifiers | ||
forbid: | ||
- ^fmt\.Errorf$ # consider errors.Errorf in github.com/pkg/errors | ||
|
||
linters: | ||
# please, do not use `enable-all`: it's deprecated and will be removed soon. | ||
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint | ||
disable-all: true | ||
fast: false | ||
enable: | ||
- bodyclose | ||
- deadcode | ||
- depguard | ||
- dogsled | ||
- errcheck | ||
- exportloopref | ||
- exhaustive | ||
#- funlen | ||
#- goconst | ||
- gocritic | ||
#- gocyclo | ||
- gofmt | ||
- goimports | ||
- goprintffuncname | ||
#- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
#- misspell | ||
- nolintlint | ||
- rowserrcheck | ||
- staticcheck | ||
- structcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- varcheck | ||
- whitespace | ||
- prealloc | ||
- predeclared | ||
- asciicheck | ||
- revive | ||
- forbidigo | ||
- makezero | ||
|
||
run: | ||
# default concurrency is a available CPU number. | ||
# concurrency: 4 # explicitly omit this value to fully utilize available resources. | ||
deadline: 5m | ||
issues-exit-code: 1 | ||
tests: false | ||
skip-dirs: | ||
- order | ||
go: '1.20' | ||
|
||
# output configuration options | ||
output: | ||
format: "colored-line-number" | ||
print-issued-lines: true | ||
print-linter-name: true | ||
uniq-by-line: true | ||
|
||
issues: | ||
# Fix found issues (if it's supported by the linter) | ||
fix: true | ||
exclude-use-default: false | ||
exclude: | ||
- "Error return value of .((os.)?std(out|err)..*|.*Close|.*Seek|.*Flush|os.Remove(All)?|.*print(f|ln)?|os.(Un)?Setenv). is not check" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
project_name: nbp | ||
env: | ||
- GO111MODULE=on | ||
before: | ||
hooks: | ||
- go mod tidy | ||
builds: | ||
- id: nowin | ||
env: | ||
- CGO_ENABLED=0 | ||
- GO111MODULE=on | ||
goos: | ||
- linux | ||
goarch: | ||
- 386 | ||
- amd64 | ||
- arm | ||
- arm64 | ||
goarm: | ||
- 6 | ||
- 7 | ||
mod_timestamp: "{{ .CommitTimestamp }}" | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- -s -w | ||
- id: win | ||
env: | ||
- CGO_ENABLED=0 | ||
- GO111MODULE=on | ||
goos: | ||
- windows | ||
goarch: | ||
- 386 | ||
- amd64 | ||
mod_timestamp: "{{ .CommitTimestamp }}" | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- -s -w | ||
|
||
checksum: | ||
name_template: "nbp_checksums.txt" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^test:" | ||
- fix typo | ||
- Merge pull request | ||
- Merge branch | ||
- Merge remote-tracking | ||
- go mod tidy | ||
|
||
archives: | ||
- id: nowin | ||
builds: | ||
- nowin | ||
- win | ||
name_template: "nbp_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
|
||
nfpms: | ||
- license: GPL 3.0 | ||
homepage: https://github.com/FloatTech/NanoBot-Plugin | ||
file_name_template: "nbp_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" | ||
formats: | ||
- deb | ||
- rpm | ||
maintainer: FloatTech |
Oops, something went wrong.