diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index d46ea14d5e..0a993f7963 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -7,9 +7,41 @@ on: permissions: contents: write + actions: write # Required for deleting artifacts jobs: + cleanup-artifacts: + runs-on: ubuntu-latest + steps: + - name: Delete old artifacts + env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + run: | + # Calculate the date 14 days ago + cutoff_date=$(date -d "14 days ago" +%Y-%m-%d) + + # List and delete artifacts older than cutoff date + gh api repos/$REPO/actions/artifacts --paginate | \ + jq -r '.artifacts[] | select(.name | startswith("cherry-studio-nightly-")) | select(.created_at < "'$cutoff_date'") | .id' | \ + while read artifact_id; do + echo "Deleting artifact $artifact_id" + gh api repos/$REPO/actions/artifacts/$artifact_id -X DELETE + done + + check-repository: + runs-on: ubuntu-latest + outputs: + should_run: ${{ github.repository == 'CherryHQ/cherry-studio' }} + steps: + - name: Check if running in main repository + run: | + echo "Running in repository: ${{ github.repository }}" + echo "Should run: ${{ github.repository == 'CherryHQ/cherry-studio' }}" + nightly-build: + needs: check-repository + if: needs.check-repository.outputs.should_run == 'true' runs-on: ${{ matrix.os }} strategy: @@ -26,6 +58,11 @@ jobs: with: node-version: 20 + - name: macos-latest dependencies fix + if: matrix.os == 'macos-latest' + run: | + brew install python-setuptools + - name: Install corepack run: corepack enable && corepack prepare yarn@4.6.0 --activate @@ -59,6 +96,7 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} RENDERER_VITE_AIHUBMIX_SECRET: ${{ vars.RENDERER_VITE_AIHUBMIX_SECRET }} + NODE_OPTIONS: --max-old-space-size=8192 - name: Build Mac if: matrix.os == 'macos-latest' @@ -73,16 +111,17 @@ jobs: APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }} RENDERER_VITE_AIHUBMIX_SECRET: ${{ vars.RENDERER_VITE_AIHUBMIX_SECRET }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_OPTIONS: --max-old-space-size=8192 - name: Build Windows if: matrix.os == 'windows-latest' run: | yarn build:npm windows - yarn build:win:x64 - yarn build:win:arm64 + yarn build:win env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} RENDERER_VITE_AIHUBMIX_SECRET: ${{ vars.RENDERER_VITE_AIHUBMIX_SECRET }} + NODE_OPTIONS: --max-old-space-size=8192 - name: Rename artifacts with nightly format shell: bash @@ -93,39 +132,24 @@ jobs: # Windows artifacts - based on actual file naming pattern if [ "${{ matrix.os }}" == "windows-latest" ]; then # Setup installer - find dist -name "*setup.exe" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}-setup.exe \; - - # Portable exe - find dist -name "*portable.exe" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}-portable.exe \; + find dist -name "*-x64-setup.exe" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}-x64-setup.exe \; + find dist -name "*-arm64-setup.exe" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}-arm64-setup.exe \; - # Rename blockmap files to match the new exe names - if [ -f "dist/*setup.exe.blockmap" ]; then - cp dist/*setup.exe.blockmap renamed-artifacts/cherry-studio-nightly-${DATE}-setup.exe.blockmap || true - fi + # Portable exe + find dist -name "*-x64-portable.exe" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}-x64-portable.exe \; + find dist -name "*-arm64-portable.exe" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}-arm64-portable.exe \; fi # macOS artifacts if [ "${{ matrix.os }}" == "macos-latest" ]; then - # 处理arm64架构文件 find dist -name "*-arm64.dmg" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}-arm64.dmg \; - find dist -name "*-arm64.dmg.blockmap" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}-arm64.dmg.blockmap \; - find dist -name "*-arm64.zip" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}-arm64.zip \; - find dist -name "*-arm64.zip.blockmap" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}-arm64.zip.blockmap \; - - # 处理x64架构文件 find dist -name "*-x64.dmg" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}-x64.dmg \; - find dist -name "*-x64.dmg.blockmap" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}-x64.dmg.blockmap \; - find dist -name "*-x64.zip" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}-x64.zip \; - find dist -name "*-x64.zip.blockmap" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}-x64.zip.blockmap \; fi # Linux artifacts if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then - find dist -name "*.AppImage" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}.AppImage \; - find dist -name "*.snap" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}.snap \; - find dist -name "*.deb" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}.deb \; - find dist -name "*.rpm" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}.rpm \; - find dist -name "*.tar.gz" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}.tar.gz \; + find dist -name "*-x86_64.AppImage" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}-x86_64.AppImage \; + find dist -name "*-arm64.AppImage" -exec cp {} renamed-artifacts/cherry-studio-nightly-${DATE}-arm64.AppImage \; fi # Copy update files