Skip to content

chore: update mdctl to v0.0.8 #4

chore: update mdctl to v0.0.8

chore: update mdctl to v0.0.8 #4

Workflow file for this run

name: PR Review
on:
pull_request:
types: [opened, synchronize]
paths:
- 'Casks/**'
- 'Formula/**'
jobs:
verify-sha256:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v40
with:
files: |
Formula/**
Casks/**
- name: Verify SHA256
if: steps.changed-files.outputs.all_changed_files != ''
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [[ $file == Formula/* ]] || [[ $file == Casks/* ]]; then
echo "Verifying SHA256 for $file"
# 提取 url 和 sha256
while IFS= read -r line; do
if [[ $line =~ url[[:space:]]*\"([^\"]*)\" ]]; then
url="${BASH_REMATCH[1]}"
# 如果 URL 包含变量,跳过验证
if [[ $url != *"#{version}"* && $url != *"#{arch}"* ]]; then
echo "Checking URL: $url"
actual_sha256=$(curl -sL "$url" | shasum -a 256 | cut -d ' ' -f 1)
# 获取文件中声明的 sha256
next_line=$(sed -n "$((NR+1))p" <<< "$(cat "$file")")
if [[ $next_line =~ sha256[[:space:]]*\"([^\"]*)\" ]]; then
declared_sha256="${BASH_REMATCH[1]}"
if [[ "$actual_sha256" != "$declared_sha256" ]]; then
echo "::error::SHA256 mismatch in $file"
echo "::error::Declared: $declared_sha256"
echo "::error::Actual: $actual_sha256"
exit 1
fi
fi
fi
fi
done < "$file"
fi
done
test-install:
needs: verify-sha256
runs-on: macos-latest
steps:
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v40
with:
files: |
Casks/**
Formula/**
- name: Setup Homebrew
run: |
brew update
brew tap samzong/tap https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
cd $(brew --repository samzong/tap)
git checkout ${{ github.event.pull_request.head.sha }}
- name: Test installation
if: steps.changed-files.outputs.all_changed_files != ''
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [[ $file == Casks/* ]]; then
APP_NAME=$(basename "$file" .rb)
echo "Testing cask: $APP_NAME"
brew install --cask samzong/tap/$APP_NAME || {
echo "::error::Failed to install cask: $APP_NAME"
exit 1
}
elif [[ $file == Formula/* ]]; then
APP_NAME=$(basename "$file" .rb)
echo "Testing formula: $APP_NAME"
brew install samzong/tap/$APP_NAME || {
echo "::error::Failed to install formula: $APP_NAME"
exit 1
}
fi
done
- name: Add PR comment
if: always()
uses: actions/github-script@v7
with:
script: |
const outcome = '${{ job.status }}' === 'success' ? '✅' : '❌';
const body = `### 安装测试结果: ${outcome}
测试环境:macOS Latest
测试时间:${new Date().toISOString()}
${outcome === '✅' ? '所有应用安装测试通过!' : '安装测试失败,请检查日志。'}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.name,
body: body
});