Skip to content

add more simulation gates for newbies #32

add more simulation gates for newbies

add more simulation gates for newbies #32

Workflow file for this run

name: Build and Release
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types: [created, published]
workflow_dispatch:
inputs:
tag:
description: 'Tag name for release (e.g., v6.3.0)'
required: true
type: string
jobs:
build:
name: Build ${{ matrix.artifact }}
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- os: macos
runner: macos-latest
artifact: chipmunk-macos-arm64
- os: macos
runner: macos-15-intel
artifact: chipmunk-macos-intel
- os: linux
runner: ubuntu-latest
artifact: chipmunk-linux-x86_64
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Install macOS dependencies
if: matrix.os == 'macos'
run: |
# Install XQuartz for X11 (provides headers, libraries, and fonts)
brew install --cask xquartz
# Install GCC compiler
brew install gcc
- name: Install Linux dependencies
if: matrix.os == 'linux'
run: |
sudo apt-get update
# Install X11 development libraries
sudo apt-get install -y libx11-dev
# Install required X11 fonts (6x10 and 8x13)
# Without these fonts, Chipmunk will fail with X_OpenFont errors
sudo apt-get install -y xfonts-base xfonts-75dpi xfonts-100dpi
# Install GCC compiler
sudo apt-get install -y gcc build-essential
- name: Build
run: |
# Set CC to use homebrew GCC on macOS (required for nested functions support)
if [ "${{ matrix.os }}" = "macos" ]; then
GCC_VERSION=$(brew list --versions gcc | awk '{print $2}' | cut -d '.' -f1)
export CC=$(brew --prefix gcc)/bin/gcc-${GCC_VERSION}
echo "Using compiler: $CC"
$CC --version
fi
make clean
make
- name: Verify binary
run: |
echo "Checking diglog binary type:"
file bin/diglog
echo "Checking diglog is executable:"
ls -lh bin/diglog
set +e
echo "Testing binary can be executed:"
if [ "${{ matrix.os }}" = "macos" ]; then
# macOS: Use perl-based timeout (perl is pre-installed)
OUTPUT=$(perl -e 'alarm shift @ARGV; exec @ARGV' 2 bin/diglog 2>&1)
else
# Linux: Use standard timeout command
OUTPUT=$(timeout 2 bin/diglog 2>&1)
fi
set -e
echo "$OUTPUT"
# Success if we see either startup screen OR display error (both prove binary executed)
if echo "$OUTPUT" | grep -qE "(Chipmunk|Could not open display)"; then
echo "✓ Binary executed successfully"
else
echo "✗ Binary failed to execute properly"
exit 1
fi
- name: Create distribution package
run: |
mkdir -p dist
# Create a temporary directory with the artifact name as root
TMPDIR=$(mktemp -d)
RELEASE_DIR="${TMPDIR}/${{ matrix.artifact }}"
mkdir -p "${RELEASE_DIR}"
# Copy files into the release directory
cp -r bin/ log/lib/ lib/ lessons/ "${RELEASE_DIR}/" 2>/dev/null || true
# Create tarball from the temp directory so it includes the artifact name folder
cd "${TMPDIR}"
tar -czf "${GITHUB_WORKSPACE}/dist/${{ matrix.artifact }}.tar.gz" "${{ matrix.artifact }}"
# Cleanup
rm -rf "${TMPDIR}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: dist/${{ matrix.artifact }}.tar.gz
retention-days: 30
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Upload to release
uses: softprops/action-gh-release@v1
with:
files: ./artifacts/**/*.tar.gz
tag_name: ${{ github.event.inputs.tag || github.ref_name || github.event.release.tag_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}