Files
ServerKit/.github/workflows/agent-release.yml
T
Juan Denis 4dbda1b092 Add system tray app and IPC server to agent
Introduces a cross-platform system tray application for the agent, accessible via the new 'tray' command. Implements a local IPC HTTP server for tray/agent communication, exposes agent status, metrics, logs, and restart functionality. Updates build scripts, configuration, and documentation to support the tray app and IPC integration.
2026-01-25 13:03:23 -05:00

466 lines
16 KiB
YAML

name: Agent Release
on:
push:
tags:
- 'agent-v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.0.0)'
required: true
type: string
env:
GO_VERSION: '1.21'
jobs:
build:
name: Build Agent
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
suffix: ''
- goos: linux
goarch: arm64
suffix: ''
- goos: windows
goarch: amd64
suffix: '.exe'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: agent/go.sum
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION="${GITHUB_REF#refs/tags/agent-v}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Building version: $VERSION"
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
cd agent
go build -ldflags="-s -w -X main.Version=${{ steps.version.outputs.version }} -X github.com/serverkit/agent/internal/agent.Version=${{ steps.version.outputs.version }}" \
-o ../dist/serverkit-agent-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }} \
./cmd/agent
- name: Compress binary (Linux)
if: matrix.goos == 'linux'
run: |
cd dist
tar -czvf serverkit-agent-${{ steps.version.outputs.version }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz \
serverkit-agent-${{ matrix.goos }}-${{ matrix.goarch }}
- name: Compress binary (Windows)
if: matrix.goos == 'windows'
run: |
cd dist
zip serverkit-agent-${{ steps.version.outputs.version }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip \
serverkit-agent-${{ matrix.goos }}-${{ matrix.goarch }}.exe
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: serverkit-agent-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/serverkit-agent-${{ steps.version.outputs.version }}-*
retention-days: 5
# Build .deb packages
build-deb:
name: Build DEB Package
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
arch: [amd64, arm64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION="${GITHUB_REF#refs/tags/agent-v}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Download binary
uses: actions/download-artifact@v4
with:
name: serverkit-agent-linux-${{ matrix.arch }}
path: dist/
- name: Extract binary
run: |
cd dist
tar -xzf serverkit-agent-${{ steps.version.outputs.version }}-linux-${{ matrix.arch }}.tar.gz
- name: Build DEB package
run: |
chmod +x agent/packaging/deb/build.sh
cd agent/packaging/deb
./build.sh "${{ steps.version.outputs.version }}" "${{ matrix.arch }}" "../../../dist/serverkit-agent-linux-${{ matrix.arch }}" "../../../packages"
- name: Upload DEB package
uses: actions/upload-artifact@v4
with:
name: serverkit-agent-deb-${{ matrix.arch }}
path: packages/*.deb
retention-days: 5
# Build .rpm packages
build-rpm:
name: Build RPM Package
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
include:
- goarch: amd64
rpmarch: x86_64
- goarch: arm64
rpmarch: aarch64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION="${GITHUB_REF#refs/tags/agent-v}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Install RPM build tools
run: |
sudo apt-get update
sudo apt-get install -y rpm
- name: Download binary
uses: actions/download-artifact@v4
with:
name: serverkit-agent-linux-${{ matrix.goarch }}
path: dist/
- name: Extract binary
run: |
cd dist
tar -xzf serverkit-agent-${{ steps.version.outputs.version }}-linux-${{ matrix.goarch }}.tar.gz
- name: Build RPM package
run: |
chmod +x agent/packaging/rpm/build.sh
cd agent/packaging/rpm
./build.sh "${{ steps.version.outputs.version }}" "${{ matrix.rpmarch }}" "../../../dist/serverkit-agent-linux-${{ matrix.goarch }}" "../../../packages"
- name: Upload RPM package
uses: actions/upload-artifact@v4
with:
name: serverkit-agent-rpm-${{ matrix.rpmarch }}
path: packages/*.rpm
retention-days: 5
# Build Windows MSI
build-msi:
name: Build MSI Installer
runs-on: windows-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version
id: version
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION="${GITHUB_REF#refs/tags/agent-v}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Install WiX Toolset
run: |
dotnet tool install --global wix
- name: Download binary
uses: actions/download-artifact@v4
with:
name: serverkit-agent-windows-amd64
path: dist/
- name: Extract binary
shell: bash
run: |
cd dist
unzip serverkit-agent-${{ steps.version.outputs.version }}-windows-amd64.zip
- name: Build MSI
shell: pwsh
run: |
cd agent/packaging/msi
.\build.ps1 -Version "${{ steps.version.outputs.version }}" -BinaryPath "..\..\..\dist\serverkit-agent-windows-amd64.exe" -OutputDir "..\..\..\packages"
- name: Upload MSI
uses: actions/upload-artifact@v4
with:
name: serverkit-agent-msi
path: packages/*.msi
retention-days: 5
# Build Docker image
build-docker:
name: Build Docker Image
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION="${GITHUB_REF#refs/tags/agent-v}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
continue-on-error: true
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./agent
platforms: linux/amd64,linux/arm64
push: ${{ secrets.DOCKERHUB_USERNAME != '' }}
tags: |
jhd3197/serverkit-agent:latest
jhd3197/serverkit-agent:${{ steps.version.outputs.version }}
build-args: |
VERSION=${{ steps.version.outputs.version }}
BUILD_TIME=${{ github.event.repository.updated_at }}
GIT_COMMIT=${{ github.sha }}
release:
name: Create Release
runs-on: ubuntu-latest
needs: [build, build-deb, build-rpm, build-msi, build-docker]
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION="${GITHUB_REF#refs/tags/agent-v}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release files
run: |
mkdir -p release
# Binary archives
find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec mv {} release/ \;
# DEB packages
find artifacts -type f -name "*.deb" -exec mv {} release/ \;
# RPM packages
find artifacts -type f -name "*.rpm" -exec mv {} release/ \;
# MSI installers
find artifacts -type f -name "*.msi" -exec mv {} release/ \;
ls -la release/
- name: Generate checksums
run: |
cd release
sha256sum * > checksums.txt
cat checksums.txt
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: agent-v${{ steps.version.outputs.version }}
name: ServerKit Agent v${{ steps.version.outputs.version }}
draft: false
prerelease: false
files: |
release/*
body: |
## ServerKit Agent v${{ steps.version.outputs.version }}
### Downloads
#### Binary Archives
| Platform | Architecture | Download |
|----------|--------------|----------|
| Linux | x64 (amd64) | `serverkit-agent-${{ steps.version.outputs.version }}-linux-amd64.tar.gz` |
| Linux | ARM64 | `serverkit-agent-${{ steps.version.outputs.version }}-linux-arm64.tar.gz` |
| Windows | x64 (amd64) | `serverkit-agent-${{ steps.version.outputs.version }}-windows-amd64.zip` |
#### Linux Packages
| Format | Architecture | Download |
|--------|--------------|----------|
| DEB (Debian/Ubuntu) | amd64 | `serverkit-agent_${{ steps.version.outputs.version }}_amd64.deb` |
| DEB (Debian/Ubuntu) | arm64 | `serverkit-agent_${{ steps.version.outputs.version }}_arm64.deb` |
| RPM (RHEL/Fedora) | x86_64 | `serverkit-agent-${{ steps.version.outputs.version }}-1.x86_64.rpm` |
| RPM (RHEL/Fedora) | aarch64 | `serverkit-agent-${{ steps.version.outputs.version }}-1.aarch64.rpm` |
#### Windows Installer
| Format | Architecture | Download |
|--------|--------------|----------|
| MSI | x64 | `serverkit-agent-${{ steps.version.outputs.version }}-x64.msi` |
> **New:** Run `serverkit-agent tray` to launch the **System Tray Application** which provides a visual indicator that the agent is running, along with quick access to status, logs, and service controls. The MSI installer auto-starts the tray on Windows login.
#### Docker
```bash
docker pull jhd3197/serverkit-agent:${{ steps.version.outputs.version }}
docker pull jhd3197/serverkit-agent:latest
```
### Quick Install
**Debian/Ubuntu:**
```bash
curl -LO https://github.com/${{ github.repository }}/releases/download/agent-v${{ steps.version.outputs.version }}/serverkit-agent_${{ steps.version.outputs.version }}_amd64.deb
sudo dpkg -i serverkit-agent_${{ steps.version.outputs.version }}_amd64.deb
sudo serverkit-agent register --token "YOUR_TOKEN" --server "https://your-serverkit.com"
sudo systemctl start serverkit-agent
```
**RHEL/Fedora:**
```bash
sudo rpm -i https://github.com/${{ github.repository }}/releases/download/agent-v${{ steps.version.outputs.version }}/serverkit-agent-${{ steps.version.outputs.version }}-1.x86_64.rpm
sudo serverkit-agent register --token "YOUR_TOKEN" --server "https://your-serverkit.com"
sudo systemctl start serverkit-agent
```
**Windows (MSI):**
Download and run the MSI installer, then:
```powershell
serverkit-agent register --token "YOUR_TOKEN" --server "https://your-serverkit.com"
Start-Service ServerKitAgent
```
**Docker:**
```bash
docker run -d --name serverkit-agent \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v serverkit-config:/etc/serverkit-agent \
jhd3197/serverkit-agent:${{ steps.version.outputs.version }}
```
### Verification
Verify downloads using the checksums in `checksums.txt`:
```bash
sha256sum -c checksums.txt
```
### What's New
See [CHANGELOG](https://github.com/${{ github.repository }}/blob/main/agent/CHANGELOG.md) for details.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
summary:
name: Build Summary
runs-on: ubuntu-latest
needs: [build, build-deb, build-rpm, build-msi, build-docker, release]
steps:
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION="${GITHUB_REF#refs/tags/agent-v}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create summary
run: |
echo "## Agent Release Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version:** v${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Built Binaries" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Platform | Architecture | Status |" >> $GITHUB_STEP_SUMMARY
echo "|----------|--------------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Linux | amd64 | ✅ Built |" >> $GITHUB_STEP_SUMMARY
echo "| Linux | arm64 | ✅ Built |" >> $GITHUB_STEP_SUMMARY
echo "| Windows | amd64 | ✅ Built |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Packages" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Format | Architecture | Status |" >> $GITHUB_STEP_SUMMARY
echo "|--------|--------------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| DEB | amd64 | ✅ Built |" >> $GITHUB_STEP_SUMMARY
echo "| DEB | arm64 | ✅ Built |" >> $GITHUB_STEP_SUMMARY
echo "| RPM | x86_64 | ✅ Built |" >> $GITHUB_STEP_SUMMARY
echo "| RPM | aarch64 | ✅ Built |" >> $GITHUB_STEP_SUMMARY
echo "| MSI | x64 | ✅ Built |" >> $GITHUB_STEP_SUMMARY
echo "| Docker | multi-arch | ✅ Built |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Release" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Release created at: https://github.com/${{ github.repository }}/releases/tag/agent-v${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY