Skip to content

Commit

Permalink
做了部分自动编译修改
Browse files Browse the repository at this point in the history
修改内容:
1.修正原第55行 GITHUB_REF 的语法错误。
2.对于 automatic_release_tag,可以使用 nelonoel/branch-name@v1 这个 action 来获取分支名称,并将其存储在一个变量中,然后使用该变量来生成 automatic_release_tag。
3.使用 actions/download-artifact@v3 下载所有现有的构建工件。
3.使用 softprops/action-gh-release@v1 来创建新的发布,这样可以更好地控制版本和文件。
5.使用 geekyeggo/delete-artifact@v2 来删除旧的构建工件,但在删除之前需要对工件的创建时间进行排序,仅删除除最新的两个以外的旧工件。
  • Loading branch information
dream-pep authored Jan 21, 2025
1 parent b98644f commit d27a0cf
Showing 1 changed file with 29 additions and 33 deletions.
62 changes: 29 additions & 33 deletions .github/workflows/CI-Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,52 +147,48 @@ jobs:
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 Windows-x64 Build
- name: Download all artifacts
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: Get current time
id: time
run: echo "::set-output name=timestamp::$(date +%s)"

- name: Create Release
uses: softprops/action-gh-release@v1
if: github.event_name!= 'pull_request'
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
# 这里修改为包含版本号的标签,假设版本号从 package_version 步骤中获取
automatic_release_tag: AutoBuild_${{ steps.package_version.outputs.version }}
# 这里修改为包含版本号的标题
title: "${{ steps.package_version.outputs.version }} - WonderLab DEV 测试版本(feature)"
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
**/*.zip
**/*.AppImage
# 删除 Delete_Artifacts 步骤,以保留老的发行版本
- 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 }}

# 删除原有的 Delete_Artifacts 步骤
# Delete_Artifacts:
# permissions: write-all
# runs-on: ubuntu-latest
Expand Down

0 comments on commit d27a0cf

Please sign in to comment.