Skip to content

Commit

Permalink
Refactor Homebrew update workflow to trigger on successful completion…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
ygsgdbd committed Dec 10, 2024
1 parent 73a2dc9 commit 5fb7f8b
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/update-homebrew.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
name: Update Homebrew Tap

on:
release:
types: [published, edited, released]
push:
tags:
- 'v*'
workflow_run:
workflows: ["Release"]
types:
- completed
branches:
- main

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

0 comments on commit 5fb7f8b

Please sign in to comment.