Skip to content

feat: Add GitHub Pages support for static site generation and deploym… #3

feat: Add GitHub Pages support for static site generation and deploym…

feat: Add GitHub Pages support for static site generation and deploym… #3

Workflow file for this run

name: CI
on:
push:
branches: ["**"]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
actions: write
jobs:
build:
name: Build and unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: "1.26.2"
cache: true
- name: Go test
run: go test ./...
- name: Build binary
run: make build
- uses: actions/upload-artifact@v7
with:
name: relay-ping-bin
path: bin/relay-ping
latency-matrix:
name: Latency matrix (public relays)
needs: build
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
timeout-minutes: 360
permissions:
contents: write
actions: write
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v7
with:
name: relay-ping-bin
path: bin
- name: Fetch relay list from chatmail.at
run: |
chmod +x scripts/fetch-chatmail-relays.sh
{
echo '# Chatmail public relays — generated in CI from https://chatmail.at/relays'
echo '# Source: https://chatmail.at/relays'
./scripts/fetch-chatmail-relays.sh
} > servers.txt
- name: Run matrix against servers.txt
run: |
chmod +x bin/relay-ping
mkdir -p dist
bin/relay-ping -test latency_matrix \
-servers-file servers.txt \
-export dist/latency-matrix-run.json.gz \
-timeout 3h \
-color never \
-log-file -
- name: WebXDC packages
run: |
make build-webxdc
make build-webxdc-with-results RUN_EXPORT=dist/latency-matrix-run.json.gz
cp bin/relay-ping.xdc dist/
cp bin/relay-ping-with-results.xdc dist/
- name: Publish matrix run release (timestamped assets)
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
TIMESTAMP=$(date -u +%Y%m%dT%H%M%SZ)
TAG="matrix-${TIMESTAMP}-${{ github.run_id }}"
cp dist/latency-matrix-run.json.gz "dist/latency-matrix-run_${TIMESTAMP}.json.gz"
cp dist/relay-ping-with-results.xdc "dist/relay-ping-with-results_${TIMESTAMP}.xdc"
NOTES_FILE=$(mktemp)
{
echo "Latency matrix run (public relays from [chatmail.at/relays](https://chatmail.at/relays))."
echo ""
echo "**Completed (UTC):** ${TIMESTAMP}"
echo "**Workflow run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
echo "**Commit:** \`${{ github.sha }}\`"
echo ""
echo "### Result summary"
echo ""
gzip -dc dist/latency-matrix-run.json.gz | jq -r '
if .status then
"**Servers:** \(.servers | length)\n\n" +
"**Federated pairs:** \(.status.federated)\n**Fed latency (avg ms):** \(.status.fedLatency)\n\n" +
"**Buckets** — good: \(.status.good), ok: \(.status.mid), slow: \(.status.slow), bad: \(.status.bad)"
elif (.servers | length) > 0 then
"**Servers:** \(.servers | length)"
else
"(export present)"
end
' || echo "(could not parse matrix JSON summary)"
} > "$NOTES_FILE"
gh release create "${TAG}" \
--latest=false \
--title "Latency matrix ${TIMESTAMP}" \
--notes-file "$NOTES_FILE" \
"dist/latency-matrix-run_${TIMESTAMP}.json.gz" \
"dist/relay-ping.xdc" \
"dist/relay-ping-with-results_${TIMESTAMP}.xdc"
rm -f "$NOTES_FILE"
- uses: actions/upload-artifact@v7
with:
name: latency-matrix-dist
path: dist
if-no-files-found: error
pages-build:
name: GitHub Pages (bundled matrix site)
needs: latency-matrix
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
pages: write
id-token: write
concurrency:
group: github-pages-${{ github.ref }}
cancel-in-progress: false
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v7
with:
name: latency-matrix-dist
path: dist
- name: Assemble static site (WebXDC-style bundle + latest matrix JSON)
run: |
set -euo pipefail
mkdir -p site/static
cp web/index.html site/
cp -r web/static/. site/static/
cp dist/latency-matrix-run.json.gz site/static/bundled-run.json.gz
sed -i 's/WEBXDC_BUILD_MODE = false/WEBXDC_BUILD_MODE = true/' site/static/app.js
- uses: actions/upload-pages-artifact@v5
with:
path: site
pages-deploy:
name: Deploy GitHub Pages
needs: pages-build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
concurrency:
group: github-pages-${{ github.ref }}
cancel-in-progress: false
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v5
semantic-release:
name: Semantic release
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [latency-matrix]
permissions:
contents: write
issues: write
pull-requests: write
actions: read
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-node@v6
with:
node-version: "24"
cache: npm
- uses: actions/download-artifact@v7
with:
name: latency-matrix-dist
path: dist
- uses: actions/download-artifact@v7
with:
name: relay-ping-bin
path: bin
- name: Stage Linux binary for semantic-release assets
run: |
cp bin/relay-ping dist/relay-ping
chmod +x dist/relay-ping
- name: Install npm dependencies
run: npm ci
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release