Files
dendrite-unofficial/.github/workflows/build-dendrite-demos.yml
eyedeekay 2958b6a11d test
2025-04-24 02:20:21 -04:00

122 lines
3.7 KiB
YAML

# File: .github/workflows/build-dendrite-demos.yml
# Purpose: Builds Dendrite Matrix homeserver demo commands
# Usage with act:
# act -j build-and-release --artifact-server-path /tmp/artifacts
name: Build Dendrite Demo Commands
on:
schedule:
- cron: '0 1 * * *' # 01:00 UTC daily
push:
branches: [ main ]
workflow_dispatch:
jobs:
build-and-release:
runs-on: ubuntu-22.04
permissions:
contents: write
env:
GO_VERSION: '1.21.1'
DENDRITE_REPO: 'https://github.com/element-hq/dendrite.git'
BUILD_DIR: ${{ github.workspace }}/build
steps:
- name: Create build directory
run: mkdir -p ${{ env.BUILD_DIR }}
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Clone Dendrite
run: |
git clone --depth 1 ${{ env.DENDRITE_REPO }} dendrite
cd dendrite
echo "DENDRITE_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
if [ ! -d "cmd" ] || [ ! -d "contrib" ]; then
echo "Error: Invalid repository structure"
exit 1
fi
- name: Build commands
working-directory: dendrite
run: |
# Build all commands in cmd/
for cmd in cmd/*/; do
if [ -f "${cmd}/main.go" ]; then
name=$(basename ${cmd})
echo "Building ${name}..."
CGO_ENABLED=0 go build \
-trimpath \
-ldflags="-s -w -extldflags '-static'" \
-o "${{ env.BUILD_DIR }}/${name}" \
"./${cmd}"
fi
done
# Build all commands in contrib/
for cmd in contrib/*/; do
if [ -f "${cmd}/main.go" ]; then
name=$(basename ${cmd})
echo "Building ${name}..."
CGO_ENABLED=0 go build \
-trimpath \
-ldflags="-s -w -extldflags '-static'" \
-o "${{ env.BUILD_DIR }}/${name}" \
"./${cmd}"
fi
done
# Verify builds
echo "Built binaries:"
ls -la ${{ env.BUILD_DIR }}
if [ -z "$(ls -A ${{ env.BUILD_DIR }})" ]; then
echo "Error: No binaries were built"
exit 1
fi
- name: Generate build info
run: |
cat > "${{ env.BUILD_DIR }}/build-info.txt" << EOF
Dendrite Demo Commands Build Information
--------------------------------------
Build Date: $(date -u +'%Y-%m-%d %H:%M:%S UTC')
Dendrite Commit: ${DENDRITE_SHA}
Go Version: ${{ env.GO_VERSION }}
Build Trigger: ${{ github.event_name }}
EOF
- name: Create nightly release
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
uses: softprops/action-gh-release@v1
with:
name: "Dendrite Demo Commands (Nightly $(date +'%Y-%m-%d'))"
tag_name: "nightly-$(date +'%Y-%m-%d')"
files: |
${{ env.BUILD_DIR }}/*
body_path: ${{ env.BUILD_DIR }}/build-info.txt
prerelease: true
fail_on_unmatched_files: true
- name: Update latest release
uses: softprops/action-gh-release@v1
with:
name: "Dendrite Demo Commands (Latest)"
tag_name: "latest"
files: |
${{ env.BUILD_DIR }}/*
body_path: ${{ env.BUILD_DIR }}/build-info.txt
prerelease: true
fail_on_unmatched_files: true
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: dendrite-binaries
path: ${{ env.BUILD_DIR }}
if-no-files-found: error