Files
oraset/.github/workflows/build.yml
T
2026-04-24 23:28:16 +08:00

154 lines
6.1 KiB
YAML

name: Build and Package Oraset
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ created ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, ubuntu-latest]
include:
- os: ubuntu-latest
platform: linux
- os: windows-latest
platform: windows
- os: macos-latest
platform: macos
- os: ubuntu-latest
platform: termux
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
- name: Build with PyInstaller
run: |
pyinstaller --onefile --name oraset oraset.py
- name: Create Debian package (Ubuntu only)
if: matrix.os == 'ubuntu-latest'
run: |
mkdir -p oraset_1.0.0_amd64/usr/bin
cp dist/oraset oraset_1.0.0_amd64/usr/bin/
mkdir -p oraset_1.0.0_amd64/DEBIAN
echo 'Package: oraset' > oraset_1.0.0_amd64/DEBIAN/control
echo 'Version: 1.0.0' >> oraset_1.0.0_amd64/DEBIAN/control
echo 'Section: utils' >> oraset_1.0.0_amd64/DEBIAN/control
echo 'Priority: optional' >> oraset_1.0.0_amd64/DEBIAN/control
echo 'Architecture: amd64' >> oraset_1.0.0_amd64/DEBIAN/control
echo 'Depends: python3' >> oraset_1.0.0_amd64/DEBIAN/control
echo 'Maintainer: Oraset Team <contact@oraset.org>' >> oraset_1.0.0_amd64/DEBIAN/control
echo 'Description: Oraset programming language interpreter' >> oraset_1.0.0_amd64/DEBIAN/control
dpkg-deb --build oraset_1.0.0_amd64
- name: Create DMG package (macOS only)
if: matrix.platform == 'macos'
run: |
mkdir -p Oraset.app/Contents/MacOS
cp dist/oraset Oraset.app/Contents/MacOS/
echo '<?xml version="1.0" encoding="UTF-8"?>' > Oraset.app/Contents/Info.plist
echo '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' >> Oraset.app/Contents/Info.plist
echo '<plist version="1.0">' >> Oraset.app/Contents/Info.plist
echo '<dict>' >> Oraset.app/Contents/Info.plist
echo ' <key>CFBundleExecutable</key>' >> Oraset.app/Contents/Info.plist
echo ' <string>oraset</string>' >> Oraset.app/Contents/Info.plist
echo ' <key>CFBundleName</key>' >> Oraset.app/Contents/Info.plist
echo ' <string>Oraset</string>' >> Oraset.app/Contents/Info.plist
echo ' <key>CFBundleIdentifier</key>' >> Oraset.app/Contents/Info.plist
echo ' <string>org.oraset.interpreter</string>' >> Oraset.app/Contents/Info.plist
echo ' <key>CFBundleVersion</key>' >> Oraset.app/Contents/Info.plist
echo ' <string>1.0.0</string>' >> Oraset.app/Contents/Info.plist
echo '</dict>' >> Oraset.app/Contents/Info.plist
echo '</plist>' >> Oraset.app/Contents/Info.plist
hdiutil create -srcfolder Oraset.app -volname Oraset -ov -format UDZO oraset.dmg
- name: Build for Termux (Ubuntu only)
if: matrix.platform == 'termux'
run: |
# Install Termux build dependencies
sudo apt-get update
sudo apt-get install -y proot-distro
# Create Termux environment
proot-distro install termux
# Build for Termux
proot-distro login termux -- bash -c 'apt update && apt install -y python3 python3-pip python3-dev build-essential
pip install pyinstaller
cd /root
cp -r /root/oraset .
cd oraset
pyinstaller --onefile --name oraset oraset.py
# Create Termux deb package
mkdir -p oraset_1.0.0_all/usr/bin
cp dist/oraset oraset_1.0.0_all/usr/bin/
mkdir -p oraset_1.0.0_all/DEBIAN
echo "Package: oraset" > oraset_1.0.0_all/DEBIAN/control
echo "Version: 1.0.0" >> oraset_1.0.0_all/DEBIAN/control
echo "Section: utils" >> oraset_1.0.0_all/DEBIAN/control
echo "Priority: optional" >> oraset_1.0.0_all/DEBIAN/control
echo "Architecture: all" >> oraset_1.0.0_all/DEBIAN/control
echo "Depends: python3" >> oraset_1.0.0_all/DEBIAN/control
echo "Maintainer: Oraset Team <contact@oraset.org>" >> oraset_1.0.0_all/DEBIAN/control
echo "Description: Oraset programming language interpreter for Termux" >> oraset_1.0.0_all/DEBIAN/control
dpkg-deb --build oraset_1.0.0_all'
# Copy artifacts
cp /root/termux/root/oraset/dist/oraset dist/oraset-termux
cp /root/termux/root/oraset/oraset_1.0.0_all.deb .
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: oraset-${{ matrix.platform }}
path: |
${{ matrix.platform == 'windows' && 'dist/oraset.exe' || '' }}
${{ matrix.platform == 'linux' && 'dist/oraset' || '' }}
${{ matrix.platform == 'linux' && 'oraset_1.0.0_amd64.deb' || '' }}
${{ matrix.platform == 'macos' && 'dist/oraset' || '' }}
${{ matrix.platform == 'macos' && 'oraset.dmg' || '' }}
${{ matrix.platform == 'termux' && 'dist/oraset-termux' || '' }}
${{ matrix.platform == 'termux' && 'oraset_1.0.0_all.deb' || '' }}
release:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v3
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Upload release assets
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
artifacts/oraset-windows/oraset.exe
artifacts/oraset-linux/oraset
artifacts/oraset-linux/oraset_1.0.0_amd64.deb
artifacts/oraset-macos/oraset
artifacts/oraset-macos/oraset.dmg
artifacts/oraset-termux/oraset-termux
artifacts/oraset-termux/oraset_1.0.0_all.deb