Skip to content

Commit 7fc3dac

Browse files
committed
chore: add github workflows
1 parent 7e25975 commit 7fc3dac

File tree

4 files changed

+142
-1
lines changed

4 files changed

+142
-1
lines changed

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
4+
- package-ecosystem: "gomod"
5+
directory: "/"
6+
schedule:
7+
interval: daily
8+
open-pull-requests-limit: 10
9+
10+
- package-ecosystem: "github-actions"
11+
directory: "/"
12+
schedule:
13+
interval: daily

.github/workflows/ci.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
paths:
6+
- 'go.mod'
7+
- '**.go'
8+
- '**.yml'
9+
pull_request:
10+
paths:
11+
- 'go.mod'
12+
- '**.go'
13+
- '**.yml'
14+
15+
env:
16+
# https://github.com/npm/node-semver#tilde-ranges-123-12-1
17+
lint_go_version: '~1.21'
18+
test_go_version: '~1.16'
19+
20+
jobs:
21+
lint:
22+
name: Lint
23+
runs-on: ubuntu-latest
24+
timeout-minutes: 10
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Set up Go
29+
uses: actions/setup-go@v5
30+
with:
31+
go-version: '${{ env.lint_go_version }}'
32+
33+
- run: go mod tidy
34+
- name: Run golangci-lint
35+
uses: golangci/golangci-lint-action@v4
36+
with:
37+
version: v1.56.1
38+
args: "--out-format colored-line-number"
39+
skip-pkg-cache: true
40+
41+
fmt:
42+
name: Fmt
43+
runs-on: ubuntu-latest
44+
timeout-minutes: 10
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
- name: Set up Go
49+
uses: actions/setup-go@v5
50+
with:
51+
go-version: '${{ env.lint_go_version }}'
52+
53+
- name: Install tools
54+
run: |
55+
go install mvdan.cc/gofumpt@v0.6.0
56+
go install mvdan.cc/sh/v3/cmd/shfmt@v3.8.0
57+
go install github.com/incu6us/goimports-reviser/v3@v3.6.4
58+
go mod tidy
59+
60+
- name: Code fmt
61+
run: |
62+
make fmt
63+
if ! git diff --exit-code ':!go.mod' ':!go.sum'; then
64+
echo "please run 'make fmt'" >&2
65+
exit 1
66+
fi
67+
68+
test:
69+
name: Test
70+
runs-on: ubuntu-latest
71+
timeout-minutes: 10
72+
73+
steps:
74+
- uses: actions/checkout@v4
75+
- name: Set up Go
76+
uses: actions/setup-go@v5
77+
with:
78+
go-version: '${{ env.test_go_version }}'
79+
80+
- name: Mod tidy
81+
run: |
82+
go mod tidy
83+
if ! git diff --exit-code; then
84+
echo "please run 'go mod tidy'" >&2
85+
exit 1
86+
fi
87+
88+
- name: Run unit tests
89+
run: go test -race ./...

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [ published, edited ]
6+
7+
permissions:
8+
contents: write
9+
packages: write
10+
11+
jobs:
12+
releases-matrix:
13+
name: Release grom binary
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
# build and publish in parallel: linux/386, linux/amd64, linux/arm64,
18+
# windows/386, windows/amd64, windows/arm64, darwin/amd64, darwin/arm64
19+
goos: [ linux, windows, darwin ]
20+
goarch: [ '386', amd64, arm64 ]
21+
exclude:
22+
- goarch: '386'
23+
goos: darwin
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: wangyoucao577/go-release-action@v1
27+
env:
28+
GO_VERSION: "go1.19.13"
29+
BUILD_TIME: $(date "+%Y-%m-%d %H:%M:%S")
30+
GIT_COMMIT: $(git rev-parse --short=10 "$GITHUB_SHA")
31+
with:
32+
github_token: ${{ secrets.GITHUB_TOKEN }}
33+
goos: ${{ matrix.goos }}
34+
goarch: ${{ matrix.goarch }}
35+
goversion: "https://dl.google.com/go/go1.19.13.linux-amd64.tar.gz"
36+
project_path: "."
37+
binary_name: "grom"
38+
extra_files: LICENSE README.md README_zh-CN.md
39+
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 }}"

cmd/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
var (
1111
projectName = "grom"
12-
projectVersion = "1.0.6"
12+
projectVersion = "1.0.7"
1313
goVersion = ""
1414
gitCommit = ""
1515
buildTime = ""

0 commit comments

Comments
 (0)