Files
dendrite-unofficial/.github/workflows/build-dendrite-demos.yml
2025-04-29 22:55:50 -04:00

99 lines
3.1 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
- name: Build commands
working-directory: dendrite
run: |
# Build all commands in cmd/
export CGO_ENABLED=0
go build -trimpath -ldflags="-s -w -extldflags '-static'" -o "${{ env.BUILD_DIR }}/" ./cmd/...
# Build all commands in contrib/
export CGO_ENABLED=0
go build -trimpath -ldflags="-s -w -extldflags '-static'" -o "${{ env.BUILD_DIR }}/" ./contrib/...
# 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: ncipollo/release-action@v1
with:
name: "Dendrite Demo Commands (Nightly $(date +'%Y-%m-%d'))"
tag: "nightly-$(date +'%Y-%m-%d')"
artifacts: "${{ env.BUILD_DIR }}/*"
bodyFile: ${{ env.BUILD_DIR }}/build-info.txt
prerelease: true
allowUpdates: false
removeArtifacts: false
- name: Update latest release
uses: ncipollo/release-action@v1
with:
name: "Dendrite Demo Commands (Latest)"
tag: "latest"
artifacts: "${{ env.BUILD_DIR }}/*"
bodyFile: ${{ env.BUILD_DIR }}/build-info.txt
prerelease: true
allowUpdates: true
removeArtifacts: true
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dendrite-binaries
path: ${{ env.BUILD_DIR }}
if-no-files-found: error