Skip to content

Download Runtimes

Download Runtimes #270

Workflow file for this run

name: Download Runtimes
on:
workflow_dispatch:
schedule:
- cron: '0 2 * * *' # Run daily at 2:00 AM UTC
permissions:
contents: write # For GitHub Releases
packages: write # For GHCR
pages: write # For GitHub Pages deployment
id-token: write # For GitHub Pages deployment
jobs:
download-runtimes:
name: Download Runtime Binaries
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
cache: true
- name: Build cdprun binary
run: make build-only
- name: Set up ORAS
run: |
go install oras.land/oras/cmd/oras@v1.3.0
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
oras version
- name: Login to GHCR
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | oras login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Download previous downloads.db from GHCR
run: |
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "Downloading existing database from ghcr.io/${REPO_LOWER}/downloads-db:latest"
oras pull ghcr.io/${REPO_LOWER}/downloads-db:latest -o . || echo "No existing database found, starting fresh"
continue-on-error: true
- name: Run download and packaging pipeline
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "GITHUB_TOKEN is set: ${{ secrets.GITHUB_TOKEN != '' }}"
echo "Repository: ${{ github.repository }}"
make run
- name: Verify packaging outputs
run: |
echo "Artifacts directory:"
ls -la artifacts/ || echo "No artifacts directory"
echo ""
echo "Packages directory:"
ls -la packages/ || echo "No packages directory"
- name: Verify downloads and database
run: |
echo "Database file:"
ls -lh downloads.db
echo ""
echo "Checking database contents:"
DOWNLOAD_COUNT=$(sqlite3 downloads.db "SELECT COUNT(*) FROM downloads;")
RELEASE_COUNT=$(sqlite3 downloads.db "SELECT COUNT(*) FROM releases;")
echo "Total downloads in database: $DOWNLOAD_COUNT"
echo "Total releases in database: $RELEASE_COUNT"
if [ "$DOWNLOAD_COUNT" -eq 0 ]; then
echo "ERROR: Database has no downloads! Download command may have failed."
exit 1
fi
if [ "$RELEASE_COUNT" -eq 0 ]; then
echo "ERROR: Database has no releases! Auto-release may have failed."
echo "This will cause sitegen to fail."
exit 1
fi
echo ""
echo "Sample downloads:"
sqlite3 downloads.db "SELECT runtime, version, platform, architecture, filename FROM downloads LIMIT 5;"
echo ""
echo "Sample releases:"
sqlite3 downloads.db "SELECT runtime, version, release_tag FROM releases LIMIT 5;"
echo ""
echo "Downloads directory:"
ls -la downloads/ || echo "No downloads directory"
- name: Upload downloads.db to GHCR
run: |
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "Uploading database to ghcr.io/${REPO_LOWER}/downloads-db:latest"
oras push ghcr.io/${REPO_LOWER}/downloads-db:latest ./downloads.db
deploy-site:
name: Deploy Site to GitHub Pages
runs-on: ubuntu-latest
if: ${{ github.ref_name == 'main' }}
needs: download-runtimes
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
cache: true
- name: Build cdprun binary
run: make build-only
- name: Set up ORAS
run: |
go install oras.land/oras/cmd/oras@v1.3.0
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
oras version
- name: Login to GHCR
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | oras login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Download downloads.db from GHCR
run: |
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "Downloading database from ghcr.io/${REPO_LOWER}/downloads-db:latest"
oras pull ghcr.io/${REPO_LOWER}/downloads-db:latest -o .
- name: Verify downloads.db exists
run: |
ls -lh downloads.db
file downloads.db
echo "Checking database contents:"
RELEASE_COUNT=$(sqlite3 downloads.db "SELECT COUNT(*) FROM releases;")
echo "Release count: $RELEASE_COUNT"
if [ "$RELEASE_COUNT" -eq 0 ]; then
echo "ERROR: No releases in database! Sitegen will have nothing to generate."
exit 1
fi
echo "Sample releases:"
sqlite3 downloads.db "SELECT runtime, version, release_tag FROM releases LIMIT 5;"
- name: Generate static site
run: |
set -e # Exit on error
./bin/cdprun --config runtime-registry.yaml --log-level debug sitegen \
--db downloads.db \
--out _site
echo "Site generation completed with exit code: $?"
- name: Verify site generation
run: |
if [ -d "_site" ]; then
echo "Site directory exists"
ls -la _site/
echo "Files in site:"
find _site -type f | head -20
else
echo "ERROR: _site directory was not created!"
echo "This means sitegen failed or had no data to generate"
exit 1
fi
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: _site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4