Skip to content

bugfix and new cmd

bugfix and new cmd #3

Workflow file for this run

name: Build and Test
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.19'
- name: Get dependencies
run: go mod download
- name: Run tests
run: go test -v -cover ./...
- name: Run linter
uses: golangci/golangci-lint-action@v3
with:
version: latest
build:
name: Build
runs-on: ubuntu-latest
needs: test
strategy:
matrix:
goos: [linux, darwin, windows]
goarch: [amd64, arm64]
exclude:
- goos: windows
goarch: arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.19'
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
VERSION=${GITHUB_REF_NAME:-dev}
BUILD_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ)
COMMIT_HASH=${GITHUB_SHA::7}
OUTPUT_NAME="cmd4coder-${VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}"
if [ "${{ matrix.goos }}" = "windows" ]; then
OUTPUT_NAME="${OUTPUT_NAME}.exe"
fi
go build \
-ldflags "-s -w -X 'main.Version=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.CommitHash=${COMMIT_HASH}'" \
-trimpath \
-o "${OUTPUT_NAME}" \
./cmd/cli
echo "Built: ${OUTPUT_NAME}"
ls -lh "${OUTPUT_NAME}"
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: cmd4coder-${{ matrix.goos }}-${{ matrix.goarch }}
path: cmd4coder-*