Skip to content

fix: optimize code

fix: optimize code #16

Workflow file for this run

name: Build
on:
push:
branches: [main, master]
tags:
- 'v*'
pull_request:
branches: [main, master]
permissions:
contents: write
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
cache: true
- name: Run tests
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
files: ./coverage.txt
fail_ci_if_error: false
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.1.5
build:
name: Build
runs-on: ${{ matrix.os }}
needs: [test, lint]
strategy:
matrix:
include:
- os: ubuntu-latest
goos: linux
goarch: amd64
suffix: ''
- os: ubuntu-latest
goos: linux
goarch: arm64
suffix: ''
- os: macos-latest
goos: darwin
goarch: amd64
suffix: ''
- os: macos-latest
goos: darwin
goarch: arm64
suffix: ''
- os: windows-latest
goos: windows
goarch: amd64
suffix: '.exe'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
cache: true
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o ggo-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }} ./cmd/ggo
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ggo-${{ matrix.goos }}-${{ matrix.goarch }}
path: ggo-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}
release:
name: Release
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Prepare release assets
run: |
mkdir -p release
for dir in dist/ggo-*; do
name=$(basename "$dir")
cp "$dir"/* release/
done
cd release
for f in ggo-*; do
sha256sum "$f" > "$f.sha256"
done
ls -la
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: release/*
draft: false
prerelease: ${{ contains(github.ref, 'rc') || contains(github.ref, 'beta') || contains(github.ref, 'alpha') }}
generate_release_notes: true