diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index dceb266..912da70 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -74,121 +74,9 @@ jobs: fi shell: bash - # Job 2: Compile using matrix for different platforms - compile: - needs: validate_and_tag - if: ${{ needs.validate_and_tag.outputs.version != '' }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - include: - - os: ubuntu-latest - python-version: "3.x" - - os: windows-latest - python-version: "3.x" - architecture: "x64" - - os: macos-latest - python-version: "3.x" - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - architecture: ${{ matrix.architecture || '' }} - - - name: Install Dependencies - if: runner.os != 'Windows' - run: | - if [ -f requirements.txt ]; then - pip install -r requirements.txt - fi - shell: bash - - - name: Install Dependencies (Windows) - if: runner.os == 'Windows' - run: | - if (Test-Path -Path requirements.txt) { - pip install -r requirements.txt - } - shell: pwsh - - - name: Install PyInstaller - run: | - pip install pyinstaller - - - name: Compile for Linux and macOS - if: runner.os != 'Windows' - run: | - # 直接在项目根目录下执行 PyInstaller - pyinstaller --onefile $GITHUB_WORKSPACE/sub_adjust.py - pyinstaller --onefile $GITHUB_WORKSPACE/sub_converter.py - - # 找到当前工作目录 - current_dir=$GITHUB_WORKSPACE - echo "Current directory: $current_dir" - - # 假设工作目录为 /home/runner/work/sub-adjust/sub-adjust/ - # dist 文件夹应位于 ${current_dir}/dist - - # 移动编译后的文件到对应的 build 目录 - if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then - mkdir -p $GITHUB_WORKSPACE/build/linux - if [ -f "$GITHUB_WORKSPACE/dist/sub_adjust" ]; then - mv "$GITHUB_WORKSPACE/dist/sub_adjust" "$GITHUB_WORKSPACE/build/linux/" - else - echo "Error: sub_adjust not found in dist/ after PyInstaller run." - fi - if [ -f "$GITHUB_WORKSPACE/dist/sub_converter" ]; then - mv "$GITHUB_WORKSPACE/dist/sub_converter" "$GITHUB_WORKSPACE/build/linux/" - else - echo "Error: sub_converter not found in dist/ after PyInstaller run." - fi - elif [ "${{ matrix.os }}" == "macos-latest" ]; then - mkdir -p $GITHUB_WORKSPACE/build/macos - if [ -f "$GITHUB_WORKSPACE/dist/sub_adjust" ]; then - mv "$GITHUB_WORKSPACE/dist/sub_adjust" "$GITHUB_WORKSPACE/build/macos/" - else - echo "Error: sub_adjust not found in dist/ after PyInstaller run." - fi - if [ -f "$GITHUB_WORKSPACE/dist/sub_converter" ]; then - mv "$GITHUB_WORKSPACE/dist/sub_converter" "$GITHUB_WORKSPACE/build/macos/" - else - echo "Error: sub_converter not found in dist/ after PyInstaller run." - fi - fi - shell: bash - - - name: Compile for Windows - if: runner.os == 'Windows' - run: | - # 直接在项目根目录下执行 PyInstaller - pyinstaller --onefile $env:GITHUB_WORKSPACE\sub_adjust.py - pyinstaller --onefile $env:GITHUB_WORKSPACE\sub_converter.py - - # 确保存在 build/windows 目录并移动编译后的文件 - mkdir -p $env:GITHUB_WORKSPACE\build\windows - if (Test-Path "$env:GITHUB_WORKSPACE\dist\sub_adjust.exe") { - Move-Item "$env:GITHUB_WORKSPACE\dist\sub_adjust.exe" "$env:GITHUB_WORKSPACE\build\windows\" - } - else { - Write-Output "Error: sub_adjust.exe not found in dist/ after PyInstaller run." - } - if (Test-Path "$env:GITHUB_WORKSPACE\dist\sub_converter.exe") { - Move-Item "$env:GITHUB_WORKSPACE\dist\sub_converter.exe" "$env:GITHUB_WORKSPACE\build\windows\" - } - else { - Write-Output "Error: sub_converter.exe not found in dist/ after PyInstaller run." - } - shell: pwsh - - # Job 3: Create release + # Job 2: Create release create_release: - needs: [validate_and_tag, compile] + needs: validate_and_tag if: ${{ needs.validate_and_tag.outputs.version != '' }} runs-on: ubuntu-latest @@ -196,104 +84,6 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - # Tar Linux binaries - - name: Tar Linux binaries - if: runner.os == 'Linux' - run: | - echo "Finding all generated binaries in the workspace:" - find "$GITHUB_WORKSPACE" -type f -name "sub_adjust" -o -name "sub_converter" - - # 确保存在 build 目录,并移动编译后的文件 - mkdir -p "$GITHUB_WORKSPACE/build/linux" - - # 查找编译后的文件路径并移动 - adjust_binary=$(find "$GITHUB_WORKSPACE" -type f -name "sub_adjust" | head -n 1) - converter_binary=$(find "$GITHUB_WORKSPACE" -type f -name "sub_converter" | head -n 1) - - if [ -z "$adjust_binary" ]; then - echo "Error: sub_adjust binary not found in workspace" - exit 1 - fi - - if [ -z "$converter_binary" ]; then - echo "Error: sub_converter binary not found in workspace" - exit 1 - fi - - echo "Moving sub_adjust to build directory: $adjust_binary" - mv "$adjust_binary" "$GITHUB_WORKSPACE/build/linux/" - - echo "Moving sub_converter to build directory: $converter_binary" - mv "$converter_binary" "$GITHUB_WORKSPACE/build/linux/" - - echo "Creating tarball for Linux binaries." - tar -czvf "$GITHUB_WORKSPACE/sub_adjust-${{ needs.validate_and_tag.outputs.version }}-linux-x64.tar.gz" -C "$GITHUB_WORKSPACE/build/linux" . - - # Tar macOS binaries - - name: Tar macOS binaries - if: runner.os == 'macOS' - run: | - echo "Finding all generated binaries in the workspace:" - find "$GITHUB_WORKSPACE" -type f -name "sub_adjust" -o -name "sub_converter" - - # 确保存在 build 目录,并移动编译后的文件 - mkdir -p "$GITHUB_WORKSPACE/build/macos" - - # 查找编译后的文件路径并移动 - adjust_binary=$(find "$GITHUB_WORKSPACE" -type f -name "sub_adjust" | head -n 1) - converter_binary=$(find "$GITHUB_WORKSPACE" -type f -name "sub_converter" | head -n 1) - - if [ -z "$adjust_binary" ]; then - echo "Error: sub_adjust binary not found in workspace" - exit 1 - fi - - if [ -z "$converter_binary" ]; then - echo "Error: sub_converter binary not found in workspace" - exit 1 - fi - - echo "Moving sub_adjust to build directory: $adjust_binary" - mv "$adjust_binary" "$GITHUB_WORKSPACE/build/macos/" - - echo "Moving sub_converter to build directory: $converter_binary" - mv "$converter_binary" "$GITHUB_WORKSPACE/build/macos/" - - echo "Creating tarball for macOS binaries." - tar -czvf "$GITHUB_WORKSPACE/sub_adjust-${{ needs.validate_and_tag.outputs.version }}-macos-x64.tar.gz" -C "$GITHUB_WORKSPACE/build/macos" . - - # Zip Windows binaries - - name: Zip Windows binaries - if: runner.os == 'Windows' - run: | - # 查找 Windows 编译结果 - Write-Output "Finding all generated binaries in the workspace:" - Get-ChildItem -Path "$env:GITHUB_WORKSPACE" -Recurse -Filter "sub_adjust.exe", "sub_converter.exe" - - # 查找编译后的文件路径 - $adjustBinary = Get-ChildItem -Path "$env:GITHUB_WORKSPACE" -Recurse -Filter "sub_adjust.exe" | Select-Object -First 1 - $converterBinary = Get-ChildItem -Path "$env:GITHUB_WORKSPACE" -Recurse -Filter "sub_converter.exe" | Select-Object -First 1 - - if (-not $adjustBinary) { - Write-Output "Error: sub_adjust.exe binary not found in workspace" - exit 1 - } - - if (-not $converterBinary) { - Write-Output "Error: sub_converter.exe binary not found in workspace" - exit 1 - } - - # 确保存在 build/windows 目录并移动编译后的文件 - mkdir -p "$env:GITHUB_WORKSPACE\build\windows" - Move-Item -Path $adjustBinary.FullName -Destination "$env:GITHUB_WORKSPACE\build\windows\" - Move-Item -Path $converterBinary.FullName -Destination "$env:GITHUB_WORKSPACE\build\windows\" - - # 打包 Windows 二进制文件 - Write-Output "Creating zip file for Windows binaries." - Compress-Archive -Path "$env:GITHUB_WORKSPACE\build\windows\*" -DestinationPath "$env:GITHUB_WORKSPACE\sub_adjust-${{ needs.validate_and_tag.outputs.version }}-win-x64.zip" - shell: pwsh - # Create GitHub release - name: Create GitHub release id: create_release_step @@ -309,30 +99,6 @@ jobs: draft: false prerelease: false - - name: Upload Linux binaries tar.gz file to release - uses: actions/upload-release-asset@v1 - with: - upload_url: ${{ steps.create_release_step.outputs.upload_url }} - asset_path: "$GITHUB_WORKSPACE/sub_adjust-${{ needs.validate_and_tag.outputs.version }}-linux-x64.tar.gz" - asset_name: "sub_adjust-${{ needs.validate_and_tag.outputs.version }}-linux-x64.tar.gz" - asset_content_type: application/gzip - - - name: Upload macOS binaries tar.gz file to release - uses: actions/upload-release-asset@v1 - with: - upload_url: ${{ steps.create_release_step.outputs.upload_url }} - asset_path: "$GITHUB_WORKSPACE/sub_adjust-${{ needs.validate_and_tag.outputs.version }}-macos-x64.tar.gz" - asset_name: "sub_adjust-${{ needs.validate_and_tag.outputs.version }}-macos-x64.tar.gz" - asset_content_type: application/gzip - - - name: Upload Windows binaries zip file to release - uses: actions/upload-release-asset@v1 - with: - upload_url: ${{ steps.create_release_step.outputs.upload_url }} - asset_path: "$GITHUB_WORKSPACE/sub_adjust-${{ needs.validate_and_tag.outputs.version }}-win-x64.zip" - asset_name: "sub_adjust-${{ needs.validate_and_tag.outputs.version }}-win-x64.zip" - asset_content_type: application/zip - # Upload source zip file to release - name: Upload source zip file to release uses: actions/upload-release-asset@v1