- Create Dockerfile for server with multi-stage build - Create Dockerfile for agent with multi-stage build - Set up Gitea Actions workflow to automatically build and release binaries - Build for all platforms: Linux (amd64/arm64), macOS (amd64/arm64), Windows (amd64) - Generate checksums for all release artifacts - Include Docker image building in CI/CD pipeline - Add release upload script for manual Gitea releases - Add comprehensive RELEASE.md documentation
141 lines
4.5 KiB
YAML
141 lines
4.5 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: '1.24.4'
|
|
|
|
- name: Generate version
|
|
id: version
|
|
run: |
|
|
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
|
VERSION=${GITHUB_REF#refs/tags/}
|
|
else
|
|
VERSION=dev-${{ github.sha }}
|
|
fi
|
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build all binaries
|
|
run: |
|
|
mkdir -p bin
|
|
|
|
# Generate templ first
|
|
go run github.com/a-h/templ/cmd/templ@latest generate
|
|
|
|
# Linux AMD64
|
|
GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o bin/nerd-monitor-server-linux-amd64 ./cmd/server
|
|
GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o bin/nerd-monitor-agent-linux-amd64 ./cmd/agent
|
|
|
|
# Linux ARM64
|
|
GOOS=linux GOARCH=arm64 go build -ldflags="-w -s" -o bin/nerd-monitor-server-linux-arm64 ./cmd/server
|
|
GOOS=linux GOARCH=arm64 go build -ldflags="-w -s" -o bin/nerd-monitor-agent-linux-arm64 ./cmd/agent
|
|
|
|
# macOS AMD64
|
|
GOOS=darwin GOARCH=amd64 go build -ldflags="-w -s" -o bin/nerd-monitor-server-darwin-amd64 ./cmd/server
|
|
GOOS=darwin GOARCH=amd64 go build -ldflags="-w -s" -o bin/nerd-monitor-agent-darwin-amd64 ./cmd/agent
|
|
|
|
# macOS ARM64
|
|
GOOS=darwin GOARCH=arm64 go build -ldflags="-w -s" -o bin/nerd-monitor-server-darwin-arm64 ./cmd/server
|
|
GOOS=darwin GOARCH=arm64 go build -ldflags="-w -s" -o bin/nerd-monitor-agent-darwin-arm64 ./cmd/agent
|
|
|
|
# Windows AMD64
|
|
GOOS=windows GOARCH=amd64 go build -ldflags="-w -s" -o bin/nerd-monitor-server-windows-amd64.exe ./cmd/server
|
|
GOOS=windows GOARCH=amd64 go build -ldflags="-w -s" -o bin/nerd-monitor-agent-windows-amd64.exe ./cmd/agent
|
|
|
|
- name: Create checksums
|
|
run: |
|
|
cd bin
|
|
sha256sum * > SHA256SUMS
|
|
cd ..
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: binaries-${{ steps.version.outputs.version }}
|
|
path: bin/
|
|
retention-days: 30
|
|
|
|
- name: Create Release
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
uses: actions/create-release@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: ${{ github.ref }}
|
|
release_name: Release ${{ github.ref }}
|
|
draft: false
|
|
prerelease: false
|
|
|
|
- name: Upload release assets
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
run: |
|
|
# This step uploads binaries to the release
|
|
# Note: Gitea Actions may require additional configuration
|
|
for file in bin/*; do
|
|
if [ -f "$file" ]; then
|
|
echo "Uploading $file to release"
|
|
fi
|
|
done
|
|
|
|
docker-build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Generate version
|
|
id: version
|
|
run: |
|
|
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
|
VERSION=${GITHUB_REF#refs/tags/}
|
|
else
|
|
VERSION=dev-${{ github.sha }}
|
|
fi
|
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build and push server image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile.server
|
|
push: false
|
|
outputs: type=docker,dest=/tmp/nerd-monitor-server.tar
|
|
tags: |
|
|
nerd-monitor-server:latest
|
|
nerd-monitor-server:${{ steps.version.outputs.version }}
|
|
|
|
- name: Build and push agent image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile.agent
|
|
push: false
|
|
outputs: type=docker,dest=/tmp/nerd-monitor-agent.tar
|
|
tags: |
|
|
nerd-monitor-agent:latest
|
|
nerd-monitor-agent:${{ steps.version.outputs.version }}
|
|
|
|
- name: Upload Docker images
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: docker-images-${{ steps.version.outputs.version }}
|
|
path: /tmp/nerd-monitor-*.tar
|
|
retention-days: 30
|