mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 04:51:10 +00:00
Update conda-pack-build.yml
This commit is contained in:
135
.github/workflows/conda-pack-build.yml
vendored
135
.github/workflows/conda-pack-build.yml
vendored
@@ -41,11 +41,13 @@ jobs:
|
|||||||
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: bash -l {0}
|
# Windows needs PowerShell for conda/mamba, Unix uses bash
|
||||||
|
shell: ${{ matrix.platform == 'win-64' && 'pwsh' || 'bash -el {0}' }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check if platform should be built
|
- name: Check if platform should be built
|
||||||
id: should_build
|
id: should_build
|
||||||
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [[ -z "${{ github.event.inputs.platforms }}" ]]; then
|
if [[ -z "${{ github.event.inputs.platforms }}" ]]; then
|
||||||
echo "should_build=true" >> $GITHUB_OUTPUT
|
echo "should_build=true" >> $GITHUB_OUTPUT
|
||||||
@@ -86,9 +88,8 @@ jobs:
|
|||||||
if: steps.should_build.outputs.should_build == 'true'
|
if: steps.should_build.outputs.should_build == 'true'
|
||||||
id: msgs_version
|
id: msgs_version
|
||||||
run: |
|
run: |
|
||||||
INSTALLED_VERSION=$(conda list ros-humble-unilabos-msgs | grep ros-humble-unilabos-msgs | awk '{print $2}')
|
echo "Checking installed ros-humble-unilabos-msgs version..."
|
||||||
echo "installed_version=$INSTALLED_VERSION" >> $GITHUB_OUTPUT
|
python scripts/get_package_version.py ros-humble-unilabos-msgs
|
||||||
echo "Installed ros-humble-unilabos-msgs version: $INSTALLED_VERSION"
|
|
||||||
|
|
||||||
- name: Check for newer ros-humble-unilabos-msgs
|
- name: Check for newer ros-humble-unilabos-msgs
|
||||||
if: steps.should_build.outputs.should_build == 'true'
|
if: steps.should_build.outputs.should_build == 'true'
|
||||||
@@ -149,8 +150,39 @@ jobs:
|
|||||||
echo "Pack file created:"
|
echo "Pack file created:"
|
||||||
ls -lh unilab-env-${{ matrix.platform }}.tar.gz
|
ls -lh unilab-env-${{ matrix.platform }}.tar.gz
|
||||||
|
|
||||||
- name: Prepare distribution package (scripts + environment)
|
- name: Prepare Windows distribution package
|
||||||
if: steps.should_build.outputs.should_build == 'true'
|
if: steps.should_build.outputs.should_build == 'true' && matrix.platform == 'win-64'
|
||||||
|
run: |
|
||||||
|
Write-Host "=========================================="
|
||||||
|
Write-Host "Creating distribution package..."
|
||||||
|
Write-Host "Platform: ${{ matrix.platform }}"
|
||||||
|
Write-Host "=========================================="
|
||||||
|
New-Item -ItemType Directory -Force -Path dist-package | Out-Null
|
||||||
|
|
||||||
|
# Copy packed environment
|
||||||
|
Write-Host "Adding: unilab-env-${{ matrix.platform }}.tar.gz"
|
||||||
|
Copy-Item unilab-env-${{ matrix.platform }}.tar.gz dist-package/
|
||||||
|
|
||||||
|
# Copy installation script
|
||||||
|
Write-Host "Adding: install_unilab.bat"
|
||||||
|
Copy-Item scripts/install_unilab.bat dist-package/
|
||||||
|
|
||||||
|
# Copy verification script
|
||||||
|
Write-Host "Adding: verify_installation.py"
|
||||||
|
Copy-Item scripts/verify_installation.py dist-package/
|
||||||
|
|
||||||
|
# Create README using Python script
|
||||||
|
Write-Host "Creating: README.txt"
|
||||||
|
python scripts/create_readme.py ${{ matrix.platform }} ${{ github.event.inputs.branch }} dist-package/README.txt
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Distribution package contents:"
|
||||||
|
Get-ChildItem dist-package | Format-Table Name, Length
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
- name: Prepare Unix/Linux distribution package
|
||||||
|
if: steps.should_build.outputs.should_build == 'true' && matrix.platform != 'win-64'
|
||||||
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "=========================================="
|
echo "=========================================="
|
||||||
echo "Creating distribution package..."
|
echo "Creating distribution package..."
|
||||||
@@ -162,104 +194,67 @@ jobs:
|
|||||||
echo "Adding: unilab-env-${{ matrix.platform }}.tar.gz"
|
echo "Adding: unilab-env-${{ matrix.platform }}.tar.gz"
|
||||||
cp unilab-env-${{ matrix.platform }}.tar.gz dist-package/
|
cp unilab-env-${{ matrix.platform }}.tar.gz dist-package/
|
||||||
|
|
||||||
# Copy installation script (platform specific)
|
# Copy installation script
|
||||||
if [ "${{ matrix.platform }}" == "win-64" ]; then
|
|
||||||
echo "Adding: install_unilab.bat"
|
|
||||||
cp scripts/install_unilab.bat dist-package/
|
|
||||||
else
|
|
||||||
echo "Adding: install_unilab.sh"
|
echo "Adding: install_unilab.sh"
|
||||||
cp scripts/install_unilab.sh dist-package/
|
cp scripts/install_unilab.sh dist-package/
|
||||||
chmod +x dist-package/install_unilab.sh
|
chmod +x dist-package/install_unilab.sh
|
||||||
fi
|
|
||||||
|
|
||||||
# Copy verification script
|
# Copy verification script
|
||||||
echo "Adding: verify_installation.py"
|
echo "Adding: verify_installation.py"
|
||||||
cp scripts/verify_installation.py dist-package/
|
cp scripts/verify_installation.py dist-package/
|
||||||
|
|
||||||
# Create README
|
# Create README using Python script
|
||||||
echo "Creating: README.txt"
|
echo "Creating: README.txt"
|
||||||
cat > dist-package/README.txt << 'EOFREADME'
|
python scripts/create_readme.py ${{ matrix.platform }} ${{ github.event.inputs.branch }} dist-package/README.txt
|
||||||
UniLabOS Conda-Pack Environment
|
|
||||||
================================
|
|
||||||
|
|
||||||
This package contains a pre-built UniLabOS environment.
|
|
||||||
|
|
||||||
Installation Instructions:
|
|
||||||
--------------------------
|
|
||||||
|
|
||||||
Windows:
|
|
||||||
1. Extract unilab-pack-win-64.zip
|
|
||||||
2. Double-click install_unilab.bat (or run in cmd)
|
|
||||||
3. Follow the prompts
|
|
||||||
|
|
||||||
macOS/Linux:
|
|
||||||
1. Extract unilab-pack-{platform}.tar.gz
|
|
||||||
2. Run: bash install_unilab.sh
|
|
||||||
3. Follow the prompts
|
|
||||||
|
|
||||||
The installation script will:
|
|
||||||
- Automatically find your conda installation
|
|
||||||
- Extract the environment to conda's envs/unilab directory
|
|
||||||
- Run conda-unpack to finalize setup
|
|
||||||
|
|
||||||
After installation:
|
|
||||||
conda activate unilab
|
|
||||||
python verify_installation.py
|
|
||||||
|
|
||||||
Package Contents:
|
|
||||||
- install_unilab script (automatic installation)
|
|
||||||
- unilab-env-{platform}.tar.gz (packed environment)
|
|
||||||
- verify_installation.py (verification tool)
|
|
||||||
- README.txt (this file)
|
|
||||||
|
|
||||||
Branch: ${{ github.event.inputs.branch }}
|
|
||||||
Platform: ${{ matrix.platform }}
|
|
||||||
Python: 3.11.11
|
|
||||||
Build Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
|
|
||||||
EOFREADME
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Distribution package contents:"
|
echo "Distribution package contents:"
|
||||||
ls -lh dist-package/
|
ls -lh dist-package/
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
- name: Create final distribution archive (ZIP/TAR.GZ)
|
- name: Create Windows ZIP archive
|
||||||
if: steps.should_build.outputs.should_build == 'true'
|
if: steps.should_build.outputs.should_build == 'true' && matrix.platform == 'win-64'
|
||||||
run: |
|
run: |
|
||||||
echo "=========================================="
|
Write-Host "=========================================="
|
||||||
if [ "${{ matrix.platform }}" == "win-64" ]; then
|
Write-Host "Creating Windows ZIP archive (ZIP64 support for large files)..."
|
||||||
echo "Creating Windows ZIP archive (ZIP64 support for large files)..."
|
Write-Host "Archive: unilab-pack-${{ matrix.platform }}.zip"
|
||||||
echo "Archive: unilab-pack-win-64.zip"
|
Write-Host "Contents: install_unilab.bat + unilab-env-${{ matrix.platform }}.tar.gz + extras"
|
||||||
echo "Contents: install_unilab.bat + unilab-env-win-64.tar.gz + extras"
|
Write-Host ""
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Use Python script with ZIP64 support instead of PowerShell Compress-Archive
|
# Use Python script with ZIP64 support instead of PowerShell Compress-Archive
|
||||||
# PowerShell Compress-Archive has a 2GB limitation
|
# PowerShell Compress-Archive has a 2GB limitation
|
||||||
python scripts/create_zip_archive.py dist-package unilab-pack-${{ matrix.platform }}.zip
|
python scripts/create_zip_archive.py dist-package unilab-pack-${{ matrix.platform }}.zip
|
||||||
else
|
|
||||||
|
Write-Host "=========================================="
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Final package created:"
|
||||||
|
Get-ChildItem unilab-pack-* | Format-Table Name, Length
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Users can now:"
|
||||||
|
Write-Host " 1. Download unilab-pack-${{ matrix.platform }}.zip"
|
||||||
|
Write-Host " 2. Extract it"
|
||||||
|
Write-Host " 3. Run install_unilab.bat"
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
- name: Create Unix/Linux TAR.GZ archive
|
||||||
|
if: steps.should_build.outputs.should_build == 'true' && matrix.platform != 'win-64'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "=========================================="
|
||||||
echo "Creating Unix/Linux TAR.GZ archive..."
|
echo "Creating Unix/Linux TAR.GZ archive..."
|
||||||
echo "Archive: unilab-pack-${{ matrix.platform }}.tar.gz"
|
echo "Archive: unilab-pack-${{ matrix.platform }}.tar.gz"
|
||||||
echo "Contents: install_unilab.sh + unilab-env-${{ matrix.platform }}.tar.gz + extras"
|
echo "Contents: install_unilab.sh + unilab-env-${{ matrix.platform }}.tar.gz + extras"
|
||||||
tar -czf unilab-pack-${{ matrix.platform }}.tar.gz -C dist-package .
|
tar -czf unilab-pack-${{ matrix.platform }}.tar.gz -C dist-package .
|
||||||
fi
|
|
||||||
echo "=========================================="
|
echo "=========================================="
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Final package created:"
|
echo "Final package created:"
|
||||||
ls -lh unilab-pack-*
|
ls -lh unilab-pack-*
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
if [ "${{ matrix.platform }}" == "win-64" ]; then
|
|
||||||
echo "Users can now:"
|
|
||||||
echo " 1. Download unilab-pack-win-64.zip"
|
|
||||||
echo " 2. Extract it"
|
|
||||||
echo " 3. Run install_unilab.bat"
|
|
||||||
else
|
|
||||||
echo "Users can now:"
|
echo "Users can now:"
|
||||||
echo " 1. Download unilab-pack-${{ matrix.platform }}.tar.gz"
|
echo " 1. Download unilab-pack-${{ matrix.platform }}.tar.gz"
|
||||||
echo " 2. Extract it: tar -xzf unilab-pack-${{ matrix.platform }}.tar.gz"
|
echo " 2. Extract it: tar -xzf unilab-pack-${{ matrix.platform }}.tar.gz"
|
||||||
echo " 3. Run: bash install_unilab.sh"
|
echo " 3. Run: bash install_unilab.sh"
|
||||||
fi
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
- name: Upload distribution package
|
- name: Upload distribution package
|
||||||
|
|||||||
185
scripts/create_readme.py
Normal file
185
scripts/create_readme.py
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Create Distribution Package README
|
||||||
|
===================================
|
||||||
|
|
||||||
|
Generate README.txt for conda-pack distribution packages.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
python create_readme.py <platform> <branch> <output_file>
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
platform: Platform identifier (win-64, linux-64, osx-64, osx-arm64)
|
||||||
|
branch: Git branch name
|
||||||
|
output_file: Output file path (e.g., dist-package/README.txt)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
python create_readme.py win-64 dev dist-package/README.txt
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def get_readme_content(platform: str, branch: str) -> str:
|
||||||
|
"""
|
||||||
|
Generate README content for the specified platform.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
platform: Platform identifier
|
||||||
|
branch: Git branch name
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: README content
|
||||||
|
"""
|
||||||
|
# Get current UTC time
|
||||||
|
build_date = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")
|
||||||
|
|
||||||
|
# Determine platform-specific content
|
||||||
|
is_windows = platform == "win-64"
|
||||||
|
|
||||||
|
if is_windows:
|
||||||
|
archive_ext = "zip"
|
||||||
|
install_script = "install_unilab.bat"
|
||||||
|
platform_instructions = """Windows:
|
||||||
|
1. Extract unilab-pack-win-64.zip
|
||||||
|
2. Double-click install_unilab.bat (or run in cmd)
|
||||||
|
3. Follow the prompts"""
|
||||||
|
else:
|
||||||
|
archive_ext = "tar.gz"
|
||||||
|
install_script = "install_unilab.sh"
|
||||||
|
platform_name = {"linux-64": "linux-64", "osx-64": "osx-64", "osx-arm64": "osx-arm64"}.get(platform, platform)
|
||||||
|
platform_instructions = f"""macOS/Linux:
|
||||||
|
1. Extract unilab-pack-{platform_name}.tar.gz
|
||||||
|
2. Run: bash install_unilab.sh
|
||||||
|
3. Follow the prompts"""
|
||||||
|
|
||||||
|
# Generate README content
|
||||||
|
readme = f"""UniLabOS Conda-Pack Environment
|
||||||
|
================================
|
||||||
|
|
||||||
|
This package contains a pre-built UniLabOS environment.
|
||||||
|
|
||||||
|
Installation Instructions:
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
{platform_instructions}
|
||||||
|
|
||||||
|
The installation script will:
|
||||||
|
- Automatically find your conda installation
|
||||||
|
- Extract the environment to conda's envs/unilab directory
|
||||||
|
- Run conda-unpack to finalize setup
|
||||||
|
|
||||||
|
After installation:
|
||||||
|
conda activate unilab
|
||||||
|
python verify_installation.py
|
||||||
|
|
||||||
|
Verification:
|
||||||
|
-------------
|
||||||
|
|
||||||
|
The verify_installation.py script will check:
|
||||||
|
- Python version (3.11.11)
|
||||||
|
- ROS2 rclpy installation
|
||||||
|
- UniLabOS installation and dependencies
|
||||||
|
|
||||||
|
If all checks pass, you're ready to use UniLabOS!
|
||||||
|
|
||||||
|
Package Contents:
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
- {install_script} (automatic installation script)
|
||||||
|
- unilab-env-{platform}.tar.gz (packed conda environment)
|
||||||
|
- verify_installation.py (environment verification tool)
|
||||||
|
- README.txt (this file)
|
||||||
|
|
||||||
|
Build Information:
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Branch: {branch}
|
||||||
|
Platform: {platform}
|
||||||
|
Python: 3.11.11
|
||||||
|
Date: {build_date}
|
||||||
|
|
||||||
|
Troubleshooting:
|
||||||
|
----------------
|
||||||
|
|
||||||
|
If installation fails:
|
||||||
|
|
||||||
|
1. Ensure conda or mamba is installed
|
||||||
|
Check: conda --version
|
||||||
|
|
||||||
|
2. Verify you have sufficient disk space
|
||||||
|
Required: ~5-10 GB after extraction
|
||||||
|
|
||||||
|
3. Check installation permissions
|
||||||
|
You need write access to conda's envs directory
|
||||||
|
|
||||||
|
4. For detailed logs, run the install script from terminal
|
||||||
|
|
||||||
|
For more help:
|
||||||
|
- Documentation: docs/user_guide/installation.md
|
||||||
|
- Quick Start: QUICK_START_CONDA_PACK.md
|
||||||
|
- Issues: https://github.com/dptech-corp/Uni-Lab-OS/issues
|
||||||
|
|
||||||
|
License:
|
||||||
|
--------
|
||||||
|
|
||||||
|
UniLabOS is licensed under GPL-3.0-only.
|
||||||
|
See LICENSE file for details.
|
||||||
|
|
||||||
|
Repository: https://github.com/dptech-corp/Uni-Lab-OS
|
||||||
|
"""
|
||||||
|
|
||||||
|
return readme
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Main entry point."""
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Generate README.txt for conda-pack distribution",
|
||||||
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||||
|
epilog="""
|
||||||
|
Examples:
|
||||||
|
python create_readme.py win-64 dev dist-package/README.txt
|
||||||
|
python create_readme.py linux-64 main dist-package/README.txt
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument("platform", choices=["win-64", "linux-64", "osx-64", "osx-arm64"], help="Platform identifier")
|
||||||
|
|
||||||
|
parser.add_argument("branch", help="Git branch name")
|
||||||
|
|
||||||
|
parser.add_argument("output_file", help="Output file path")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Generate README content
|
||||||
|
readme_content = get_readme_content(args.platform, args.branch)
|
||||||
|
|
||||||
|
# Create output directory if needed
|
||||||
|
output_path = Path(args.output_file)
|
||||||
|
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
# Write README file
|
||||||
|
with open(output_path, "w", encoding="utf-8") as f:
|
||||||
|
f.write(readme_content)
|
||||||
|
|
||||||
|
print(f"✓ README.txt created: {output_path}")
|
||||||
|
print(f" Platform: {args.platform}")
|
||||||
|
print(f" Branch: {args.branch}")
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error creating README: {e}", file=sys.stderr)
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
traceback.print_exc()
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
68
scripts/get_package_version.py
Normal file
68
scripts/get_package_version.py
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Get Conda Package Version
|
||||||
|
==========================
|
||||||
|
|
||||||
|
Get the installed version of a conda package and output it for GitHub Actions.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
python get_package_version.py <package_name>
|
||||||
|
|
||||||
|
Example:
|
||||||
|
python get_package_version.py ros-humble-unilabos-msgs
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def get_package_version(package_name: str) -> str:
|
||||||
|
"""
|
||||||
|
Get the installed version of a conda package.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
package_name: Name of the package to check
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: Version string or 'not-found'
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
# Use conda list with JSON output for reliable parsing
|
||||||
|
result = subprocess.run(["conda", "list", package_name, "--json"], capture_output=True, text=True, check=True)
|
||||||
|
|
||||||
|
packages = json.loads(result.stdout)
|
||||||
|
|
||||||
|
if packages:
|
||||||
|
version = packages[0]["version"]
|
||||||
|
return version
|
||||||
|
else:
|
||||||
|
return "not-found"
|
||||||
|
|
||||||
|
except (subprocess.CalledProcessError, json.JSONDecodeError, KeyError, IndexError) as e:
|
||||||
|
print(f"Error getting package version: {e}", file=sys.stderr)
|
||||||
|
return "error"
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Main entry point."""
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print(f"Usage: {sys.argv[0]} <package_name>", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
package_name = sys.argv[1]
|
||||||
|
version = get_package_version(package_name)
|
||||||
|
|
||||||
|
# Output for GitHub Actions
|
||||||
|
github_output = os.getenv("GITHUB_OUTPUT")
|
||||||
|
if github_output:
|
||||||
|
with open(github_output, "a") as f:
|
||||||
|
f.write(f"installed_version={version}\n")
|
||||||
|
|
||||||
|
# Also print for logs
|
||||||
|
print(f"Installed {package_name} version: {version}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user