All checks were successful
Build and Release Core / Test and Build (push) Successful in 3m34s
64 lines
1.8 KiB
YAML
64 lines
1.8 KiB
YAML
name: Build and Release Core
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
tags:
|
|
- 'v*'
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
build:
|
|
name: Test and Build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: '1.26.x'
|
|
|
|
- name: Cache Go Modules and Build Cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cache/go-build
|
|
~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
|
|
- name: Run Tests
|
|
run: go test ./... -v
|
|
|
|
- name: Build Binaries
|
|
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: Create Release and Upload Binaries
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
files: bin/*
|
|
name: Release ${{ github.ref_name }}
|
|
generate_release_notes: true
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }} |