Fix macOS DMG creation by simplifying approach to avoid ImageMagick i… #20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release Flex | |
on: | |
push: | |
branches: [ main, master ] | |
tags: | |
- 'v*' # Run when tag is pushed (for versioned releases) | |
jobs: | |
build: | |
name: Build Flex for ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
include: | |
- os: ubuntu-latest | |
output_name: flex | |
asset_name: flex-linux | |
- os: windows-latest | |
output_name: flex.exe | |
asset_name: flex-windows | |
- os: macos-latest | |
output_name: flex | |
asset_name: flex-macos | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pyinstaller | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
shell: bash | |
- name: Run tests | |
run: | | |
cd src | |
python -m unittest discover -s flex_tester | |
shell: bash | |
- name: Build executable with PyInstaller | |
run: | | |
cd src | |
pyinstaller --onefile main.py -n flex | |
shell: bash | |
# Windows NSIS Installer | |
- name: Create Windows Installer | |
if: runner.os == 'Windows' | |
run: | | |
choco install nsis -y | |
mkdir -p installer | |
copy src\dist\flex.exe installer\ | |
xcopy src\flex_tester installer\examples\ /E /I | |
copy README.md installer\ | |
# Create a simple NSIS script file | |
( | |
echo !include "MUI2.nsh" | |
echo Name "Flex Programming Language" | |
echo OutFile "flex-windows-installer.exe" | |
echo InstallDir "$PROGRAMFILES\Flex" | |
echo RequestExecutionLevel admin | |
echo !insertmacro MUI_PAGE_WELCOME | |
echo !insertmacro MUI_PAGE_DIRECTORY | |
echo !insertmacro MUI_PAGE_INSTFILES | |
echo !insertmacro MUI_PAGE_FINISH | |
echo !insertmacro MUI_LANGUAGE "English" | |
echo Section | |
echo SetOutPath "$INSTDIR" | |
echo File /r "installer\*.*" | |
echo WriteUninstaller "$INSTDIR\uninstall.exe" | |
echo CreateDirectory "$SMPROGRAMS\Flex" | |
echo CreateShortcut "$SMPROGRAMS\Flex\Flex.lnk" "$INSTDIR\flex.exe" | |
echo CreateShortcut "$SMPROGRAMS\Flex\Uninstall.lnk" "$INSTDIR\uninstall.exe" | |
echo SectionEnd | |
echo Section "Uninstall" | |
echo Delete "$INSTDIR\uninstall.exe" | |
echo RMDir /r "$INSTDIR" | |
echo RMDir /r "$SMPROGRAMS\Flex" | |
echo SectionEnd | |
) > installer.nsi | |
# Compile the installer without PATH manipulation (which requires EnvVarUpdate.nsh) | |
makensis installer.nsi | |
shell: cmd | |
# macOS DMG Package | |
- name: Create macOS DMG | |
if: runner.os == 'macOS' | |
run: | | |
# Install required tools first | |
brew install create-dmg imagemagick | |
# Verify tools installation | |
echo "Checking for ImageMagick..." | |
which convert || echo "Warning: convert command not found" | |
# Create app bundle structure | |
mkdir -p Flex.app/Contents/{MacOS,Resources} | |
cp src/dist/flex Flex.app/Contents/MacOS/ | |
cp -r src/flex_tester Flex.app/Contents/Resources/examples | |
cp README.md Flex.app/Contents/Resources/ | |
# Create Info.plist | |
cat > Flex.app/Contents/Info.plist << EOF | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>CFBundleExecutable</key> | |
<string>flex</string> | |
<key>CFBundleIconFile</key> | |
<string>flex.icns</string> | |
<key>CFBundleIdentifier</key> | |
<string>org.flex-lang.flex</string> | |
<key>CFBundleName</key> | |
<string>Flex</string> | |
<key>CFBundlePackageType</key> | |
<string>APPL</string> | |
<key>CFBundleVersion</key> | |
<string>1.0</string> | |
<key>NSHighResolutionCapable</key> | |
<true/> | |
</dict> | |
</plist> | |
EOF | |
# Create a simple icon without relying on ImageMagick | |
echo "Creating a basic application icon..." | |
mkdir -p Flex.app/Contents/Resources | |
# Try to use simple native tools instead of ImageMagick if possible | |
# Create a basic DMG without custom graphics if we run into issues | |
if command -v create-dmg &> /dev/null; then | |
# Create DMG with basic settings | |
create-dmg \ | |
--volname "Flex Installer" \ | |
--window-pos 200 120 \ | |
--window-size 800 400 \ | |
--icon-size 100 \ | |
--icon "Flex.app" 200 190 \ | |
--hide-extension "Flex.app" \ | |
--app-drop-link 600 185 \ | |
"flex-macos.dmg" \ | |
"Flex.app" | |
else | |
echo "Failed to create DMG - create-dmg tool not available" | |
# Create a zip file as fallback | |
ditto -c -k --keepParent Flex.app flex-macos.zip | |
fi | |
shell: bash | |
continue-on-error: true # DMG creation might fail if dependencies are missing | |
# Linux AppImage | |
- name: Create Linux AppImage | |
if: runner.os == 'Linux' | |
run: | | |
# Install required tools | |
sudo apt-get update | |
sudo apt-get install -y wget fuse libfuse2 | |
# Download AppImage tools | |
wget -q https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool | |
chmod +x appimagetool | |
# Create AppDir structure | |
mkdir -p AppDir/usr/{bin,share/applications,share/icons/hicolor/256x256/apps,share/flex/examples} | |
cp src/dist/flex AppDir/usr/bin/ | |
cp -r src/flex_tester/* AppDir/usr/share/flex/examples/ | |
cp README.md AppDir/usr/share/flex/ | |
# Create desktop file | |
cat > AppDir/usr/share/applications/flex.desktop << EOF | |
[Desktop Entry] | |
Name=Flex | |
Comment=Flex Programming Language | |
Exec=flex | |
Icon=flex | |
Type=Application | |
Categories=Development; | |
Terminal=true | |
EOF | |
# Copy desktop file to root (required by AppImage) | |
cp AppDir/usr/share/applications/flex.desktop AppDir/ | |
# Create AppRun script | |
cat > AppDir/AppRun << EOF | |
#!/bin/sh | |
SELF=\$(readlink -f "\$0") | |
HERE=\${SELF%/*} | |
export PATH="\${HERE}/usr/bin:\${PATH}" | |
exec "\${HERE}/usr/bin/flex" "\$@" | |
EOF | |
chmod +x AppDir/AppRun | |
# Create AppImage | |
ARCH=x86_64 ./appimagetool AppDir flex-linux.AppImage | |
shell: bash | |
continue-on-error: true # Some parts might fail if dependencies are missing | |
# Package distribution (Unix) - keep this as backup for Linux | |
- name: Package distribution (Unix) | |
if: runner.os != 'Windows' | |
run: | | |
mkdir -p dist/flex | |
cp src/dist/flex dist/flex/ | |
cp -r src/flex_tester dist/flex/examples | |
cp README.md dist/flex/ | |
tar -czf flex-${{ matrix.asset_name }}.tar.gz -C dist flex | |
shell: bash | |
# Package distribution (Windows) - keep this as backup for Windows | |
- name: Package distribution (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
mkdir -p dist\flex | |
copy src\dist\flex.exe dist\flex\ | |
xcopy src\flex_tester dist\flex\examples\ /E /I | |
copy README.md dist\flex\ | |
powershell Compress-Archive -Path dist\flex -DestinationPath flex-${{ matrix.asset_name }}.zip | |
shell: cmd | |
- name: Debug - List files before upload | |
run: | | |
if [ "$RUNNER_OS" == "Windows" ]; then | |
echo "=== Current directory files ===" | |
dir | |
echo "=== src/dist directory files ===" | |
dir src\dist || echo "Directory not found" | |
echo "=== Current directory - find all flex files ===" | |
dir /s /b flex* 2>nul || echo "No files found" | |
else | |
echo "=== Current directory files ===" | |
ls -la | |
echo "=== src/dist directory files ===" | |
ls -la src/dist || true | |
echo "=== Current directory - find all flex files ===" | |
find . -name "flex*" -type f || true | |
fi | |
shell: bash | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: flex-${{ matrix.asset_name }} | |
path: | | |
flex-${{ matrix.asset_name }}.tar.gz | |
flex-${{ matrix.asset_name }}.zip | |
flex-windows-installer.exe | |
flex-macos.dmg | |
flex-linux.AppImage | |
src/dist/* | |
if-no-files-found: warn | |
release: | |
name: Create Release | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: Prepare release assets | |
run: | | |
mkdir -p release_assets | |
# Find and copy all relevant files to release_assets directory | |
echo "=== Copying artifacts to release directory ===" | |
find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" -o -name "*.exe" -o -name "*.dmg" -o -name "*.AppImage" \) -exec cp {} release_assets/ \; || true | |
# For standalone executables that might be in specific directories | |
find artifacts -type f \( -name "flex" -o -name "flex.exe" \) -exec cp {} release_assets/ \; || true | |
echo "=== Files in release_assets ===" | |
ls -la release_assets/ | |
shell: bash | |
- name: List downloaded files | |
run: | | |
echo "=== Root directory ===" | |
find . -type f | sort | |
echo "=== All flex files ===" | |
find . -name "flex*" | sort | |
echo "=== All artifacts directories ===" | |
find artifacts -type d | sort | |
echo "=== All artifact files ===" | |
find artifacts -type f | sort | |
shell: bash | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: ${{ startsWith(github.ref, 'refs/tags/') && format('Flex {0}', github.ref_name) || 'Flex Latest Build' }} | |
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest' }} | |
draft: false | |
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
files: release_assets/* | |
body: | | |
# Flex Programming Language ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'Latest Build' }} | |
Cross-platform executable releases of the Flex programming language. | |
## Installation | |
### Windows | |
- Option 1: Download and run `flex-windows-installer.exe` for a full installer with start menu shortcuts | |
- Option 2: Download and extract `flex-windows.zip`, then run `flex.exe` | |
### macOS | |
- Option 1: Download `flex-macos.dmg`, open and drag to Applications folder | |
- Option 2: Download and extract `flex-macos.tar.gz`, then run `flex` | |
### Linux | |
- Option 1: Download `flex-linux.AppImage`, make executable with `chmod +x flex-linux.AppImage` and run | |
- Option 2: Download and extract `flex-linux.tar.gz`, then run `flex` | |
## Examples | |
Example code is included in the examples directory. | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |