Skip to content

Commit 5fb7f8b

Browse files
committed
Refactor Homebrew update workflow to trigger on successful completion of the Release workflow. Update version retrieval to fetch the latest release information from GitHub API and construct the download URL dynamically. This enhances the automation of the Homebrew tap update process.
1 parent 73a2dc9 commit 5fb7f8b

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

.github/workflows/update-homebrew.yml

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
name: Update Homebrew Tap
22

33
on:
4-
release:
5-
types: [published, edited, released]
6-
push:
7-
tags:
8-
- 'v*'
4+
workflow_run:
5+
workflows: ["Release"]
6+
types:
7+
- completed
8+
branches:
9+
- main
910

1011
jobs:
1112
update-tap:
1213
runs-on: macos-latest
14+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1315
steps:
1416
- name: Checkout tap
1517
uses: actions/checkout@v4
@@ -21,13 +23,14 @@ jobs:
2123
- name: Get release info
2224
id: release
2325
run: |
24-
# 获取版本号(移除 v 前缀如果存在)
25-
VERSION=${GITHUB_REF#refs/tags/}
26-
VERSION=${VERSION#v}
26+
# 获取最新的 release 信息
27+
RELEASE_INFO=$(curl -s https://api.github.com/repos/ygsgdbd/DanceKunKun/releases/latest)
28+
VERSION=$(echo "$RELEASE_INFO" | jq -r .tag_name | sed 's/^v//')
29+
DOWNLOAD_URL=$(echo "$RELEASE_INFO" | jq -r '.assets[] | select(.name=="DanceKunKun.dmg") | .browser_download_url')
30+
2731
echo "version=$VERSION" >> $GITHUB_OUTPUT
2832
29-
# 构建下载 URL 并验证文件是否存在
30-
DOWNLOAD_URL="https://github.com/ygsgdbd/DanceKunKun/releases/download/${GITHUB_REF#refs/tags/}/DanceKunKun.dmg"
33+
# 下载并验证文件
3134
HTTP_STATUS=$(curl -L -s -o DanceKunKun.dmg -w "%{http_code}" "$DOWNLOAD_URL")
3235
3336
if [ "$HTTP_STATUS" != "200" ]; then

0 commit comments

Comments
 (0)