11name : Push to Homebrew Tap
22
3- # 支持手动触发,带有参数控制是否执行推送
3+ # Support manual trigger with parameters to control whether to execute push
44on :
55 workflow_dispatch :
66 inputs :
1515 type : string
1616 default : ' '
1717
18- # 权限设置
18+ # Permission settings
1919permissions :
2020 contents : read
2121 actions : read
2222
23- # 环境变量
23+ # Environment variables
2424env :
25- HOMEBREW_TAP_REPO : ' homebrew-agb' # 目标仓库名称
26- SOURCE_RB_PATH : ' homebrew/agb.rb' # 源rb文件路径
27- TARGET_RB_PATH : ' Formula/agb.rb' # 目标rb文件路径
25+ HOMEBREW_TAP_REPO : ' homebrew-agb' # Target repository name
26+ SOURCE_RB_PATH : ' homebrew/agb.rb' # Source rb file path
27+ TARGET_RB_PATH : ' Formula/agb.rb' # Target rb file path
2828
2929jobs :
3030 push-to-homebrew-tap :
3131 name : Push Formula to Homebrew Tap
3232 runs-on : ubuntu-latest
3333 timeout-minutes : 15
3434
35- # 只有当参数为true时才执行
35+ # Only execute when parameter is true
3636 if : ${{ github.event.inputs.push_to_tap == 'true' }}
3737
3838 steps :
6767 INPUT_VERSION="${{ github.event.inputs.version }}"
6868 echo "Validating input version: $INPUT_VERSION"
6969
70- # 验证版本是否在GitHub releases中存在
70+ # Verify if version exists in GitHub releases
7171 RELEASE_EXISTS=$(gh api repos/${{ github.repository }}/releases/tags/v$INPUT_VERSION --silent 2>/dev/null && echo "true" || echo "false")
7272
7373 if [[ "$RELEASE_EXISTS" == "true" ]]; then
@@ -80,15 +80,15 @@ jobs:
8080 exit 1
8181 fi
8282 else
83- # 从rb文件中读取当前版本号
83+ # Read current version number from rb file
8484 echo "Reading version from rb file: ${{ env.SOURCE_RB_PATH }}"
8585
8686 if [[ ! -f "${{ env.SOURCE_RB_PATH }}" ]]; then
8787 echo "❌ Source rb file not found: ${{ env.SOURCE_RB_PATH }}"
8888 exit 1
8989 fi
9090
91- # 从rb文件中提取版本号 (寻找 url "...v1.2.3.tar.gz" 格式 )
91+ # Extract version number from rb file (looking for url "...v1.2.3.tar.gz" format )
9292 VERSION=$(grep -o 'tags/v[0-9]\+\.[0-9]\+\.[0-9]\+' "${{ env.SOURCE_RB_PATH }}" | head -1 | sed 's/tags\/v//')
9393
9494 if [[ -z "$VERSION" ]]; then
@@ -106,18 +106,18 @@ jobs:
106106 echo "Final version: $VERSION"
107107
108108 - name : Update rb file with current version
109- # 只有当用户手动输入了版本号时才执行更新操作
109+ # Only execute update operation when user manually inputs version number
110110 if : ${{ github.event.inputs.version != '' }}
111111 run : |
112112 echo "Updating rb file with version $VERSION..."
113113
114- # 创建临时文件来更新版本信息
114+ # Create temporary file to update version information
115115 cp "${{ env.SOURCE_RB_PATH }}" /tmp/agb.rb.tmp
116116
117- # 更新版本号(如果rb文件中有版本信息)
117+ # Update version number (if rb file contains version information)
118118 sed -i "s/version \"[^\"]*\"/version \"$VERSION\"/g" /tmp/agb.rb.tmp
119119
120- # 更新URL中的版本标签
120+ # Update version tag in URL
121121 sed -i "s|/tags/v[^/]*/|/tags/v$VERSION/|g" /tmp/agb.rb.tmp
122122
123123 echo "Updated rb file content:"
@@ -126,13 +126,13 @@ jobs:
126126 echo "========================"
127127
128128 - name : Use existing rb file (no version update)
129- # 当用户没有输入版本号时,直接使用现有的rb文件
129+ # When user doesn't input version number, directly use existing rb file
130130 if : ${{ github.event.inputs.version == '' }}
131131 run : |
132132 echo "Using existing rb file without version update..."
133133 echo "Version will be read from existing rb file: $VERSION"
134134
135- # 直接复制现有的rb文件
135+ # Directly copy existing rb file
136136 cp "${{ env.SOURCE_RB_PATH }}" /tmp/agb.rb.tmp
137137
138138 echo "Existing rb file content:"
@@ -147,12 +147,12 @@ jobs:
147147 echo "Cloning homebrew-agb repository..."
148148 echo "Repository URL: https://github.com/agbcloud/${{ env.HOMEBREW_TAP_REPO }}.git"
149149
150- # 克隆目标仓库
150+ # Clone target repository
151151 git clone "https://x-access-token:${{ secrets.HOMEBREW_TAP_TOKEN }}@github.com/agbcloud/${{ env.HOMEBREW_TAP_REPO }}.git" homebrew-tap
152152
153153 echo "✅ Successfully cloned homebrew-agb repository"
154154
155- # 显示仓库信息
155+ # Display repository information
156156 cd homebrew-tap
157157 echo "Current branch: $(git branch --show-current)"
158158 echo "Repository structure:"
@@ -165,7 +165,7 @@ jobs:
165165
166166 cd homebrew-tap
167167
168- # 检查Formula目录是否存在
168+ # Check if Formula directory exists
169169 if [[ -d "Formula" ]]; then
170170 echo "✅ Formula directory already exists"
171171 else
@@ -174,18 +174,18 @@ jobs:
174174 echo "✅ Formula directory created successfully"
175175 fi
176176
177- # 验证Formula目录确实存在
177+ # Verify Formula directory actually exists
178178 if [[ ! -d "Formula" ]]; then
179179 echo "❌ Failed to create Formula directory"
180180 exit 1
181181 fi
182182
183- # 复制更新后的rb文件到目标位置
183+ # Copy updated rb file to target location
184184 cp /tmp/agb.rb.tmp "${{ env.TARGET_RB_PATH }}"
185185
186186 echo "✅ Formula file updated at ${{ env.TARGET_RB_PATH }}"
187187
188- # 显示文件内容确认
188+ # Display file content for confirmation
189189 echo "Updated Formula content:"
190190 echo "========================"
191191 cat "${{ env.TARGET_RB_PATH }}"
@@ -199,10 +199,10 @@ jobs:
199199
200200 echo "📝 Preparing to commit and push Formula file..."
201201
202- # 添加变更(无论是否有实际变更)
202+ # Add changes (regardless of whether there are actual changes)
203203 git add "${{ env.TARGET_RB_PATH }}"
204204
205- # 创建提交信息
205+ # Create commit message
206206 COMMIT_MSG="Update agb formula to version $VERSION
207207
208208 - Updated from source repository: ${{ github.repository }}
@@ -212,11 +212,11 @@ jobs:
212212 - Workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
213213 - Timestamp: $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
214214
215- # 提交变更(允许空提交)
215+ # Commit changes (allow empty commit)
216216 git commit -m "$COMMIT_MSG" --allow-empty
217217 echo "✅ Formula committed successfully"
218218
219- # 推送到远程仓库
219+ # Push to remote repository
220220 echo "Pushing changes to homebrew-agb repository..."
221221 if git push origin main 2>/dev/null || git push origin master 2>/dev/null; then
222222 echo "✅ Successfully pushed Formula to homebrew-agb repository"
@@ -245,7 +245,7 @@ jobs:
245245 echo "🔗 Repository URL:"
246246 echo " https://github.com/agbcloud/${{ env.HOMEBREW_TAP_REPO }}"
247247
248- # 当参数为false时显示跳过信息
248+ # Show skip information when parameter is false
249249 skip-push :
250250 name : Skip Push (Parameter is false)
251251 runs-on : ubuntu-latest
0 commit comments