fix: 清理旧的压缩文件,确保在处理发布资产时不会出现冲突 #35
Workflow file for this run
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: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write # Grant write access to repository contents | |
| jobs: | |
| build-docker-images: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: amd64 | |
| runner: ubuntu-22.04 | |
| - arch: arm64 | |
| runner: ubuntu-22.04-arm | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Clean up disk space | |
| run: | | |
| df -h | |
| docker image prune -f | |
| docker container prune -f | |
| docker volume prune -f | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
| df -h | |
| - name: Build sandbox Docker image for ${{ matrix.arch }} | |
| run: | | |
| cd sandbox | |
| docker buildx build \ | |
| --platform linux/${{ matrix.arch }} \ | |
| --tag e2b-sandbox:latest \ | |
| --load \ | |
| . | |
| - name: Save Docker image to tar.gz | |
| run: | | |
| docker save e2b-sandbox:latest | gzip -1 > e2b-sandbox-${{ matrix.arch }}.tar.gz | |
| ls -lh e2b-sandbox-${{ matrix.arch }}.tar.gz | |
| - name: Cache Docker image | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: e2b-sandbox-${{ matrix.arch }}.tar.gz | |
| key: docker-image-${{ matrix.arch }}-${{ github.run_id }} | |
| enableCrossOsArchive: true | |
| release: | |
| needs: build-docker-images | |
| continue-on-error: true | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # macOS (Intel & Apple Silicon) | |
| - runner: macos-13 | |
| artifact_name: EdgeBox-macos-x64 | |
| artifact_path: | | |
| out/make/**/*.dmg | |
| out/make/**/*.zip | |
| arch: amd64 | |
| - runner: macos-14 | |
| artifact_name: EdgeBox-macos-arm64 | |
| artifact_path: | | |
| out/make/**/*.dmg | |
| out/make/**/*.zip | |
| arch: arm64 | |
| # Windows (x64 & ARM64) | |
| - runner: windows-latest | |
| artifact_name: EdgeBox-windows-x64 | |
| artifact_path: | | |
| out/make/**/*.exe | |
| out/make/**/*.msi | |
| arch: amd64 | |
| # - runner: windows-11-arm | |
| # artifact_name: EdgeBox-windows-arm64 | |
| # artifact_path: | | |
| # out/make/**/*.exe | |
| # out/make/**/*.msi | |
| # arch: arm64 | |
| # Linux (x64 & ARM64) | |
| - runner: ubuntu-22.04 | |
| artifact_name: EdgeBox-linux-x64 | |
| artifact_path: | | |
| out/make/**/*.AppImage | |
| out/make/**/*.deb | |
| out/make/**/*.rpm | |
| arch: amd64 | |
| - runner: ubuntu-22.04-arm | |
| artifact_name: EdgeBox-linux-arm64 | |
| artifact_path: | | |
| out/make/**/*.AppImage | |
| out/make/**/*.deb | |
| out/make/**/*.rpm | |
| arch: arm64 | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - name: Clean up disk space | |
| if: runner.os == 'Linux' | |
| run: | | |
| df -h | |
| docker image prune -f | |
| docker container prune -f | |
| docker volume prune -f | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
| df -h | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Restore Docker image from cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: e2b-sandbox-${{ matrix.arch }}.tar.gz | |
| key: docker-image-${{ matrix.arch }}-${{ github.run_id }} | |
| enableCrossOsArchive: true | |
| - name: Create sandbox_images directory and rename Docker image | |
| shell: bash | |
| run: | | |
| mkdir -p sandbox_images | |
| mv e2b-sandbox-${{ matrix.arch }}.tar.gz sandbox_images/e2b-sandbox-latest.tar.gz | |
| - name: Make application | |
| run: pnpm run make | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact_name }} | |
| path: ${{ matrix.artifact_path }} | |
| create-release: | |
| needs: release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download application artifacts only | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: EdgeBox-* | |
| path: artifacts | |
| - name: Create Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| release_name: Release ${{ github.ref_name }} | |
| draft: false | |
| prerelease: false | |
| - name: Prepare release assets with 7zip split | |
| run: | | |
| echo "=== Initial disk usage ===" | |
| df -h . | |
| # Create release_assets directory | |
| mkdir -p release_assets | |
| # Clean up any existing split files first | |
| rm -f release_assets/*.7z.* release_assets/*.zip.* | |
| echo "=== Processing artifacts ===" | |
| find artifacts -type f | while read artifact; do | |
| asset_name=$(basename "$artifact") | |
| echo "Processing: $asset_name" | |
| # Create a clean file name for 7zip (remove spaces and special chars) | |
| clean_name=$(echo "$asset_name" | sed 's/[^a-zA-Z0-9._-]/_/g') | |
| # Check file size in GB | |
| file_size_gb=$(($(stat -c%s "$artifact") / 1024 / 1024 / 1024)) | |
| if [ $file_size_gb -ge 2 ]; then | |
| echo "File larger than 2GB, splitting into volumes..." | |
| # Ensure no leftover old files | |
| rm -f "release_assets/${clean_name%.*}.zip" "release_assets/${clean_name%.*}.zip.*" | |
| # Split into 1.9GB parts (1900MB) to stay well under 2GB limit | |
| 7z a -tzip -v1900m -aoa "release_assets/${clean_name%.*}.zip" "$artifact" | |
| echo "Created parts for $asset_name:" | |
| ls -lh "release_assets/${clean_name%.*}.zip".* | |
| # Delete original large file immediately after splitting to free space | |
| echo "Removing original large file: $artifact" | |
| rm -f "$artifact" | |
| echo "=== Disk usage after processing $asset_name ===" | |
| df -h . | |
| else | |
| echo "File is under 2GB, moving to release_assets" | |
| # 确保目标目录没有旧文件 | |
| rm -f "release_assets/$clean_name" | |
| mv "$artifact" "release_assets/$clean_name" | |
| fi | |
| done | |
| echo "=== Final disk usage ===" | |
| df -h . | |
| - name: Upload Release Assets | |
| run: | | |
| find release_assets -type f | while read asset; do | |
| echo "Uploading $(basename "$asset")" | |
| gh release upload "${{ github.ref_name }}" "$asset" --clobber --repo "${{ github.repository }}" | |
| done | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |