53 lines
1.6 KiB
YAML
53 lines
1.6 KiB
YAML
name: Build and Release Core
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*' # Only trigger when you push a version tag (e.g., v1.0.0)
|
|
pull_request:
|
|
branches: [ main ] # Run tests on PRs, but don't build release binaries
|
|
|
|
jobs:
|
|
build:
|
|
name: Test and Build
|
|
runs-on: ubuntu-latest # This runs on your Gitea act_runner
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: '1.26' # Update to match your go.mod if different
|
|
|
|
- name: Run Tests
|
|
run: go test ./... -v
|
|
|
|
- name: Build Binaries
|
|
# Only run the build steps if this was triggered by a tag push
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
run: |
|
|
|
|
VERSION=${GITHUB_REF_NAME}
|
|
COMMIT=$(echo ${GITHUB_SHA} | cut -c1-7)
|
|
|
|
|
|
LDFLAGS="-X 'main.BuildVersion=$VERSION' -X 'main.BuildCommit=$COMMIT'"
|
|
|
|
mkdir -p bin
|
|
|
|
echo "Building Linux (amd64)..."
|
|
GOOS=linux GOARCH=amd64 go build -ldflags="$LDFLAGS" -o bin/rr-linux-amd64 ./cmd/rr/main.go
|
|
|
|
echo "Building macOS (Apple Silicon arm64)..."
|
|
GOOS=darwin GOARCH=arm64 go build -ldflags="$LDFLAGS" -o bin/rr-darwin-arm64 ./cmd/rr/main.go
|
|
|
|
echo "Building Windows (amd64)..."
|
|
GOOS=windows GOARCH=amd64 go build -ldflags="$LDFLAGS" -o bin/rr-windows-amd64.exe ./cmd/rr/main.go
|
|
|
|
- name: Upload Artifacts
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: riskrancher-core-binaries
|
|
path: bin/ |