diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..71cfc73 --- /dev/null +++ b/.github/dependabot.yml @@ -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: + interval: daily diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..201ec8f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,89 @@ +name: CI + +on: + push: + paths: + - 'go.mod' + - '**.go' + - '**.yml' + pull_request: + paths: + - 'go.mod' + - '**.go' + - '**.yml' + +env: + # https://github.com/npm/node-semver#tilde-ranges-123-12-1 + lint_go_version: '~1.21' + test_go_version: '~1.16' + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '${{ env.lint_go_version }}' + + - run: go mod tidy + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v4 + with: + version: v1.56.1 + args: "--out-format colored-line-number" + skip-pkg-cache: true + + fmt: + name: Fmt + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '${{ env.lint_go_version }}' + + - name: Install tools + run: | + go install mvdan.cc/gofumpt@v0.6.0 + go install mvdan.cc/sh/v3/cmd/shfmt@v3.8.0 + go install github.com/incu6us/goimports-reviser/v3@v3.6.4 + go mod tidy + + - name: Code fmt + run: | + make fmt + if ! git diff --exit-code ':!go.mod' ':!go.sum'; then + echo "please run 'make fmt'" >&2 + exit 1 + fi + + test: + name: Test + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '${{ env.test_go_version }}' + + - name: Mod tidy + run: | + go mod tidy + if ! git diff --exit-code; then + echo "please run 'go mod tidy'" >&2 + exit 1 + fi + + - name: Run unit tests + run: go test -race ./... diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d7c76a3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,39 @@ +name: Release + +on: + release: + types: [ published, edited ] + +permissions: + contents: write + packages: write + +jobs: + releases-matrix: + name: Release grom binary + runs-on: ubuntu-latest + strategy: + matrix: + # build and publish in parallel: linux/386, linux/amd64, linux/arm64, + # windows/386, windows/amd64, windows/arm64, darwin/amd64, darwin/arm64 + goos: [ linux, windows, darwin ] + goarch: [ '386', amd64, arm64 ] + exclude: + - goarch: '386' + goos: darwin + steps: + - uses: actions/checkout@v4 + - uses: wangyoucao577/go-release-action@v1 + env: + GO_VERSION: "go1.19.13" + BUILD_TIME: $(date "+%Y-%m-%d %H:%M:%S") + GIT_COMMIT: $(git rev-parse --short=10 "$GITHUB_SHA") + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + goos: ${{ matrix.goos }} + goarch: ${{ matrix.goarch }} + goversion: "https://dl.google.com/go/go1.19.13.linux-amd64.tar.gz" + project_path: "." + binary_name: "grom" + extra_files: LICENSE README.md README_zh-CN.md + ldflags: -X "github.com/sliveryou/grom/cmd.goVersion=${{ env.GO_VERSION }}" -X "github.com/sliveryou/grom/cmd.buildTime=${{ env.BUILD_TIME }}" -X "github.com/sliveryou/grom/cmd.gitCommit=${{ env.GIT_COMMIT }}" diff --git a/cmd/version.go b/cmd/version.go index 3a9345c..6ca7c21 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -9,7 +9,7 @@ import ( var ( projectName = "grom" - projectVersion = "1.0.6" + projectVersion = "1.0.7" goVersion = "" gitCommit = "" buildTime = ""