Skip to content

Build and Release Cosmos #33

Build and Release Cosmos

Build and Release Cosmos #33

Workflow file for this run

name: Build and Release Cosmos
on:
push:
branches: [main, dev]
tags: ['v*']
pull_request:
branches: [main, dev]
workflow_dispatch:
inputs:
version_override:
description: 'Override version (e.g., 0.19.1-genieos.1)'
required: false
env:
GO_VERSION: '1.23.2'
NODE_VERSION: '18'
jobs:
build:
runs-on: [self-hosted, Linux, X64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Get version
id: version
run: |
if [ -n "${{ github.event.inputs.version_override }}" ]; then
echo "VERSION=${{ github.event.inputs.version_override }}" >> $GITHUB_OUTPUT
else
echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
fi
- name: Install frontend dependencies
run: npm ci
- name: Build frontend
run: npm run client-build
- name: Copy update.go to launcher
run: cp src/update.go src/launcher/update.go
- name: Build Go binaries (AMD64)
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o build/cosmos ./src/*.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o build/cosmos-launcher ./src/launcher/launcher.go ./src/launcher/update.go
- name: Build Go binaries (ARM64)
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o build/cosmos-arm64 ./src/*.go
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o build/cosmos-launcher-arm64 ./src/launcher/launcher.go ./src/launcher/update.go
- name: Copy assets and package
run: |
# Verify binaries were built
echo "=== Checking build directory ==="
ls -la build/
# Make binaries executable
chmod +x build/cosmos build/cosmos-arm64 build/cosmos-launcher build/cosmos-launcher-arm64
# Copy optional assets (ok to fail)
cp start.sh build/ 2>/dev/null || true
cp -r static build/
cp GeoLite2-Country.mmdb build/ 2>/dev/null || true
cp restic restic-arm nebula nebula-arm nebula-cert nebula-arm-cert Logo.png build/ 2>/dev/null || true
mkdir -p build/images
cp client/src/assets/images/icons/cosmos_gray.png build/cosmos_gray.png 2>/dev/null || true
# Create meta.json
cat > build/meta.json << EOF
{
"version": "${{ steps.version.outputs.VERSION }}",
"buildDate": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"commit": "${{ github.sha }}"
}
EOF
echo "=== Build directory contents ==="
ls -la build/
# Package AMD64 (MUST succeed)
cd build
echo "=== Packaging AMD64 ==="
tar -czvf ../cosmos-genieos-${{ steps.version.outputs.VERSION }}-amd64.tar.gz \
cosmos cosmos-launcher static/ meta.json
# Package ARM64 (MUST succeed)
echo "=== Packaging ARM64 ==="
tar -czvf ../cosmos-genieos-${{ steps.version.outputs.VERSION }}-arm64.tar.gz \
cosmos-arm64 cosmos-launcher-arm64 static/ meta.json
cd ..
echo "=== Generated packages ==="
ls -la cosmos-genieos-*.tar.gz
sha256sum cosmos-genieos-*.tar.gz > checksums.sha256
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: cosmos-binaries-${{ steps.version.outputs.VERSION }}
path: |
cosmos-genieos-*.tar.gz
checksums.sha256
release:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: [self-hosted, Linux, X64]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Get version
id: version
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: cosmos-binaries-${{ steps.version.outputs.VERSION }}
path: ./release
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
./release/cosmos-genieos-*.tar.gz
./release/checksums.sha256
generate_release_notes: true
body: |
## Cosmos Server for GenieOS
This release includes Proxmox LXC runtime support alongside Docker.
### Downloads
- **AMD64**: `cosmos-genieos-${{ steps.version.outputs.VERSION }}-amd64.tar.gz`
- **ARM64**: `cosmos-genieos-${{ steps.version.outputs.VERSION }}-arm64.tar.gz`
### Installation
```bash
curl -L https://github.com/namastexlabs/genieos1-cosmos/releases/download/${{ github.ref_name }}/cosmos-genieos-${{ steps.version.outputs.VERSION }}-amd64.tar.gz -o cosmos.tar.gz
tar -xzvf cosmos.tar.gz -C /opt/cosmos/
```
deploy:
needs: release
if: startsWith(github.ref, 'refs/tags/v')
runs-on: [self-hosted, Linux, X64]
steps:
- name: Trigger Jenkins deployment
run: |
curl -sf -X POST "http://10.114.1.103:8080/generic-webhook-trigger/invoke?token=genieos-cosmos" \
-H "Content-Type: application/json" \
-d '{
"action": "deploy",
"tag": "${{ github.ref_name }}",
"repository": "genieos1-cosmos"
}' || echo "Jenkins webhook failed (non-critical)"