Merge branch 'main' into windows #39
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: CI | |
| on: [push] | |
| jobs: | |
| # macOS向けRustバインディングをビルド | |
| build_macos_rust_binding: | |
| name: Build macOS ai-deno bindings | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: aarch64-apple-darwin | |
| - name: Install dependencies | |
| run: | | |
| rustup target add aarch64-apple-darwin | |
| - name: Restore Cargo cache | |
| id: cargo-cache-restore | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Restore build artifacts cache | |
| id: build-cache-restore | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: ${{ github.workspace }}/pkgs/ai-deno/target | |
| key: ${{ runner.os }}-macos-target-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', 'pkgs/ai-deno/src/**/*.rs') }} | |
| restore-keys: | | |
| ${{ runner.os }}-macos-target- | |
| - name: Build for macOS (aarch64) | |
| working-directory: ${{ github.workspace }}/pkgs/ai-deno | |
| run: | | |
| cargo build --release --target aarch64-apple-darwin | |
| - name: Create directories for artifacts | |
| run: | | |
| mkdir -p ${{ github.workspace }}/pkgs/ai-deno/target/macos/includes | |
| # macOSのバイナリとヘッダーをコピー | |
| cp ${{ github.workspace }}/pkgs/ai-deno/target/aarch64-apple-darwin/release/libai_deno.a ${{ github.workspace }}/pkgs/ai-deno/target/macos/ | |
| # ヘッダーファイルをコピー | |
| cp ${{ github.workspace }}/pkgs/ai-deno/include/libai_deno.h ${{ github.workspace }}/pkgs/ai-deno/target/macos/includes/ | |
| # ビルドが失敗してもCargoキャッシュを保存 | |
| - name: Save Cargo cache | |
| if: always() && steps.cargo-cache-restore.outputs.cache-hit != 'true' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| key: ${{ steps.cargo-cache-restore.outputs.cache-primary-key || runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| # ビルドが成功した場合のみビルド成果物をキャッシュ | |
| - name: Save build artifacts cache | |
| if: success() && steps.build-cache-restore.outputs.cache-hit != 'true' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: ${{ github.workspace }}/pkgs/ai-deno/target | |
| key: ${{ steps.build-cache-restore.outputs.cache-primary-key || runner.os }}-macos-target-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', 'pkgs/ai-deno/src/**/*.rs') }} | |
| - name: Upload macOS binding artifact | |
| id: upload-macos-binding | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ai-deno-macos | |
| path: | | |
| ${{ github.workspace }}/pkgs/ai-deno/target/macos/libai_deno.a | |
| ${{ github.workspace }}/pkgs/ai-deno/target/macos/includes/ | |
| retention-days: 1 | |
| compression-level: 3 | |
| if-no-files-found: error | |
| # Windows向けRustバインディングをビルド | |
| build_windows_rust_binding: | |
| name: Build Windows ai-deno bindings | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Restore Cargo cache | |
| id: cargo-cache-restore | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Restore build artifacts cache | |
| id: build-cache-restore | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: ${{ github.workspace }}/pkgs/ai-deno/target | |
| key: ${{ runner.os }}-windows-target-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', 'pkgs/ai-deno/src/**/*.rs') }} | |
| restore-keys: | | |
| ${{ runner.os }}-windows-target- | |
| - name: Build for Windows | |
| working-directory: ${{ github.workspace }}/pkgs/ai-deno | |
| run: | | |
| cargo build --release | |
| - name: Create directories for artifacts | |
| run: | | |
| mkdir -p ${{ github.workspace }}/pkgs/ai-deno/target/windows/includes | |
| # Windowsのバイナリとヘッダーをコピー | |
| cp ${{ github.workspace }}/pkgs/ai-deno/target/release/ai_deno.lib ${{ github.workspace }}/pkgs/ai-deno/target/windows/ | |
| # ヘッダーファイルをコピー | |
| cp ${{ github.workspace }}/pkgs/ai-deno/include/libai_deno.h ${{ github.workspace }}/pkgs/ai-deno/target/windows/includes/ | |
| # ビルドが失敗してもCargoキャッシュを保存 | |
| - name: Save Cargo cache | |
| if: always() && steps.cargo-cache-restore.outputs.cache-hit != 'true' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| key: ${{ steps.cargo-cache-restore.outputs.cache-primary-key || runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| # ビルドが成功した場合のみビルド成果物をキャッシュ | |
| - name: Save build artifacts cache | |
| if: success() && steps.build-cache-restore.outputs.cache-hit != 'true' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: ${{ github.workspace }}/pkgs/ai-deno/target | |
| key: ${{ steps.build-cache-restore.outputs.cache-primary-key || runner.os }}-windows-target-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', 'pkgs/ai-deno/src/**/*.rs') }} | |
| - name: Upload Windows binding artifact | |
| id: upload-windows-binding | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ai-deno-windows | |
| path: | | |
| ${{ github.workspace }}/pkgs/ai-deno/target/windows/ai_deno.lib | |
| ${{ github.workspace }}/pkgs/ai-deno/target/windows/includes/ | |
| retention-days: 1 | |
| compression-level: 3 | |
| if-no-files-found: error | |
| # ステップ2: macOS版プラグインをビルド | |
| build_macos_plugin: | |
| needs: build_macos_rust_binding | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Checkout Illustrator SDK | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: "hanakla/illustrator-sdk" | |
| path: illustrator-sdk | |
| - name: Download macOS Rust binding artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ai-deno-macos | |
| path: ${{ github.workspace }}/pkgs/ai-deno/target/release/ | |
| - name: Select Xcode version | |
| run: sudo xcode-select -s '/Applications/Xcode_16.0.app/Contents/Developer' | |
| - name: Show Xcode version | |
| run: xcodebuild -version | |
| - name: Build with Xcode | |
| working-directory: ${{ github.workspace }}/pkgs/plugin | |
| run: | | |
| # Xcodeでビルド - PIPL生成はXcodeのビルドフェーズで行われる | |
| xcodebuild -project AiDenoPlugin.xcodeproj -scheme AiDenoPlugin -configuration Release build | |
| - name: Upload macOS plugin artifact | |
| id: upload-macos-artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: illustrator-deno-macos | |
| path: ${{ github.workspace }}/pkgs/plugin/output/mac/release/IllustratorDeno.aip | |
| compression-level: 1 | |
| if-no-files-found: error | |
| - name: Output artifact info | |
| if: success() | |
| run: | | |
| echo "macOS artifact ID: ${{ steps.upload-macos-artifact.outputs.artifact-id }}" | |
| echo "Download URL: ${{ steps.upload-macos-artifact.outputs.artifact-url }}" | |
| echo "SHA-256: ${{ steps.upload-macos-artifact.outputs.artifact-digest }}" | |
| # ステップ3: Windows版プラグインをビルド | |
| build_windows_plugin: | |
| needs: build_windows_rust_binding | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Checkout Illustrator SDK | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: "hanakla/illustrator-sdk" | |
| path: illustrator-sdk | |
| - name: Download Windows Rust binding artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ai-deno-windows | |
| path: ${{ github.workspace }}/pkgs/ai-deno/target/release/ | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.x" | |
| - name: Setup Deno | |
| uses: denoland/setup-deno@v1 | |
| with: | |
| deno-version: v1.x | |
| - name: Add MSBuild to PATH | |
| uses: microsoft/setup-msbuild@v2 | |
| - name: Setup Visual Studio Developer Command Prompt | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| - name: Create skeleton structure for build | |
| working-directory: ${{ github.workspace }}/pkgs/plugin | |
| run: | | |
| # 正しくディレクトリを作成 | |
| New-Item -Path "Source" -ItemType Directory -Force | |
| New-Item -Path "deps\imgui\misc\cpp" -ItemType Directory -Force | |
| New-Item -Path "Resources\Win" -ItemType Directory -Force | |
| New-Item -Path "output\win\release" -ItemType Directory -Force | |
| New-Item -Path "build\temp\obj" -ItemType Directory -Force | |
| New-Item -Path "output\win\release\IllustratorDeno.aip\Contents\Resources\pipl" -ItemType Directory -Force | |
| # Create minimal resource files if they don't exist | |
| if (-Not (Test-Path "Resources\Win\HelloWorld.rc")) { | |
| $rcContent = @' | |
| #include "resource.h" | |
| 16000 PiPL DISCARDABLE | |
| BEGIN | |
| 0x0001, | |
| 0L, | |
| 4L, | |
| 'ADBE', 'kind', 0L, 4L, 'SPEA', | |
| 'ADBE', 'ivrs', 0L, 4L, 2L, | |
| 'ADBE', 'wx86', 0L, 12L, "PluginMain\0\0", | |
| 'ADBE', 'pinm', 0L, 12L, "IllustratorDeno" | |
| END | |
| '@ | |
| Set-Content -Path "Resources\Win\HelloWorld.rc" -Value $rcContent | |
| } | |
| if (-Not (Test-Path "Resources\Win\resource.h")) { | |
| $resourcehContent = @' | |
| // Resource header file | |
| '@ | |
| Set-Content -Path "Resources\Win\resource.h" -Value $resourcehContent | |
| } | |
| # Create minimal source files for build testing | |
| if (-Not (Test-Path "Source\AiDenoPlugin.cpp")) { | |
| $sourceContent = @' | |
| // Placeholder for AiDenoPlugin.cpp | |
| #include <stdio.h> | |
| extern "C" __declspec(dllexport) void PluginMain() { | |
| // Plugin entry point | |
| } | |
| '@ | |
| Set-Content -Path "Source\AiDenoPlugin.cpp" -Value $sourceContent | |
| } | |
| # PIPL署名を生成 | |
| python -c "import sys, json; sys.path.append('..\..\illustrator-sdk\tools\pipl'); from create_pipl import create_pipl; create_pipl('[{\"name\":\"IllustratorDeno\"}, {\"entry_point\":\"PluginMain\"}]')" | |
| # PIPLファイルが存在しない場合は作成 | |
| if (-Not (Test-Path "plugin.pipl")) { | |
| $piplContent = @' | |
| // PIPL | |
| { | |
| "name": "IllustratorDeno", | |
| "entry_point": "PluginMain" | |
| } | |
| '@ | |
| Set-Content -Path "plugin.pipl" -Value $piplContent | |
| } | |
| shell: pwsh | |
| - name: Build with Deno script | |
| working-directory: ${{ github.workspace }}/pkgs/plugin | |
| run: | | |
| # 環境変数を使ってVisual Studioのパスを設定 | |
| $env:VS_PATH = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" | |
| $env:SDK_PATH = "..\illustrator-sdk" | |
| # ビルドスクリプトを実行 | |
| deno run --allow-run --allow-read --allow-write --allow-env build-win.ts --release | |
| # PIPLファイルをリソースディレクトリにコピー | |
| Copy-Item -Path "plugin.pipl" -Destination "output\win\release\IllustratorDeno.aip\Contents\Resources\pipl\plugin.pipl" -Force | |
| shell: pwsh | |
| - name: Upload Windows plugin artifact | |
| id: upload-windows-artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: illustrator-deno-windows | |
| path: ${{ github.workspace }}/pkgs/plugin/output/win/release/IllustratorDeno.aip | |
| compression-level: 1 | |
| if-no-files-found: error | |
| - name: Output artifact info | |
| if: success() | |
| run: | | |
| echo "Windows artifact ID: ${{ steps.upload-windows-artifact.outputs.artifact-id }}" | |
| echo "Download URL: ${{ steps.upload-windows-artifact.outputs.artifact-url }}" | |
| echo "SHA-256: ${{ steps.upload-windows-artifact.outputs.artifact-digest }}" |