Skip to content

Commit

Permalink
Update CI-Build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
YangSpring114 committed Jan 23, 2025
1 parent 30f22c9 commit ff70183
Showing 1 changed file with 70 additions and 37 deletions.
107 changes: 70 additions & 37 deletions .github/workflows/CI-Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,46 +143,79 @@ jobs:
with:
name: OSX_arm64
path: 'WonderLab.Desktop/bin/Release/${{ env.target-version }}/publish/osx-arm64/*.zip'

Release:
permissions: write-all
runs-on: ubuntu-latest
env:
GITHUB_REF: $ github.ref
needs: [build_Windows, build_MacOS, build_Linux]
steps:
- uses: nelonoel/branch-name@v1
id: branch_name
- name: Download all artifacts
uses: actions/download-artifact@v3
- name: Get current time
id: time
run: echo "::set-output name=current_timestamp::$(date +%s)"
- name: Create Release
uses: softprops/action-gh-release@v1
if: github.event_name!= 'pull_request'
- uses: nelonoel/branch-name@v1

- name: Download Windows-x64 Build
uses: actions/download-artifact@v3
with:
name: Windows_x64

- name: Download Windows-arm64 Build
uses: actions/download-artifact@v3
with:
name: Windows_arm64

- name: Download AppImage Build
uses: actions/download-artifact@v3
with:
name: AppImage

- name: Download OSX-x64 Build
uses: actions/download-artifact@v3
with:
name: OSX_x64

- name: Download OSX-arm64 Build
uses: actions/download-artifact@v3
with:
name: OSX_arm64

- name: Create Release
if: github.event_name != 'pull_request'
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
automatic_release_tag: AutoBuild_${{ env.BRANCH_NAME }}
title: "${{ env.BRANCH_NAME }} 分支 - 测试渠道"
files: |
*.zip
*.AppImage
Delete_Artifacts:
permissions: write-all
runs-on: ubuntu-latest
needs: [Release]
steps:
- name: Delete Windows-x64 Artifact
uses: geekyeggo/delete-artifact@v2
with:
token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
tag_name: WonderLab DEV版本 自动编译 ${{ steps.branch_name.outputs.branch }}_${{ steps.package_version.outputs.version }}
name: "${{ steps.branch_name.outputs.branch }} - ${{ steps.package_version.outputs.version }} - testing channel"
files: |
**/*.zip
**/*.AppImage
- name: Install gh CLI
run: |
type -p gh || (curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null && sudo apt update && sudo apt install gh -y)
- name: Delete old artifacts
run: |
# 以下是一个简单的 shell 脚本,用于删除除最新的两个以外的旧工件
# 首先列出所有工件并按修改时间排序
artifacts=$(gh api repos/${{ github.repository }}/actions/artifacts --jq '.artifacts | sort_by(.updated_at) |.[] |.name')
# 计算要删除的工件数量
count=$(echo "$artifacts" | wc -l)
to_delete=$((count - 2))
# 删除旧工件
if [ $to_delete -gt 0 ]; then
echo "$artifacts" | head -n $to_delete | while read -r artifact; do
gh api repos/${{ github.repository }}/actions/artifacts/$(gh api repos/${{ github.repository }}/actions/artifacts --jq ".artifacts[] | select(.name == \"$artifact\") |.id") -X DELETE
done
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: Windows_x64

- name: Delete Windows-arm64 Artifact
uses: geekyeggo/delete-artifact@v2
with:
name: Windows_arm64

- name: Delete OSX-x64 Artifact
uses: geekyeggo/delete-artifact@v2
with:
name: OSX_x64

- name: Delete OSX-arm64 Artifact
uses: geekyeggo/delete-artifact@v2
with:
name: OSX_arm64

- name: Delete AppImage Artifact
uses: geekyeggo/delete-artifact@v2
with:
name: AppImage

0 comments on commit ff70183

Please sign in to comment.