Skip to content

Commit

Permalink
chore: add github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
sliveryou committed Feb 14, 2024
1 parent 7e25975 commit 7fc3dac
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .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:
interval: daily
89 changes: 89 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
go install mvdan.cc/sh/v3/cmd/[email protected]
go install github.com/incu6us/goimports-reviser/[email protected]
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 ./...
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

var (
projectName = "grom"
projectVersion = "1.0.6"
projectVersion = "1.0.7"
goVersion = ""
gitCommit = ""
buildTime = ""
Expand Down

0 comments on commit 7fc3dac

Please sign in to comment.