Merge pull request #13 from starskim/dependabot/go_modules/google.gol… #76
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
name: "CI" | |
on: | |
push: | |
branches: | |
- '**' | |
pull_request: | |
branches: | |
- '**' | |
jobs: | |
# run unittest | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
go: [ '1.20' ] | |
steps: | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go }} | |
check-latest: true | |
cache-dependency-path: "**/*.sum" | |
- uses: actions/checkout@v4 | |
- run: go test -v -coverprofile=profile.cov ./... | |
- name: go vet | |
run: | | |
go vet ./... | |
- name: Send coverage | |
uses: shogo82148/actions-goveralls@v1 | |
with: | |
path-to-profile: profile.cov | |
flag-name: Go-${{ matrix.go }} | |
parallel: true | |
# build binary | |
build: | |
needs: test | |
name: Build binary CI | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
goos: [ linux, windows, darwin ] | |
goarch: [ "386", amd64, arm, arm64 ] | |
exclude: | |
- goos: darwin | |
goarch: arm | |
- goos: darwin | |
goarch: "386" | |
fail-fast: true | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Go environment | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' | |
check-latest: true | |
cache-dependency-path: "**/*.sum" | |
- name: Set env | |
run: | | |
echo BUILD_TIME=$(date --rfc-3339=seconds) >> ${GITHUB_ENV} | |
- name: Build binary file | |
env: | |
GOOS: ${{ matrix.goos }} | |
GOARCH: ${{ matrix.goarch }} | |
run: | | |
export BINARY_NAME="DDBOT" | |
if [ $GOOS = "windows" ]; then export BINARY_NAME="$BINARY_NAME.exe"; fi | |
go build -o "$BINARY_NAME" -ldflags '-w -s -X "github.com/starskim/DDBOT/lsp.BuildTime=${{ env.BUILD_TIME }}" -X github.com/starskim/DDBOT/lsp.CommitId=${{ github.sha }} -X github.com/starskim/DDBOT/lsp.Tags=${{ env.Tags }}' github.com/starskim/DDBOT/cmd | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
if: ${{ !github.head_ref }} | |
with: | |
name: ${{ matrix.goos }}_${{ matrix.goarch }} | |
path: | | |
./DDBOT | |
./DDBOT.exe | |
# notifies that all test jobs are finished. | |
finish: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: shogo82148/actions-goveralls@v1 | |
with: | |
parallel-finished: true |