Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 66 additions & 8 deletions .github/workflows/validate-homebrew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ on:

jobs:
validate-homebrew:
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'Update Homebrew formula')
if: >-
github.event.pull_request.merged == true &&
(startsWith(github.event.pull_request.title, 'Update Homebrew formula') ||
startsWith(github.event.pull_request.title, 'Update Homebrew distribution'))

permissions:
contents: read
Expand All @@ -33,16 +36,40 @@ jobs:
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@d482da0e602890d3160aade42e72c8556103bf04 # 2026.10.26.1

- name: Select Homebrew package type
id: package
run: |
if [[ "${{ runner.os }}" == "macOS" && -f Casks/modernize.rb ]]; then
package_type=cask
definition=Casks/modernize.rb
verify_runtime=true
else
package_type=formula
definition=Formula/modernize.rb
if [[ "${{ runner.os }}" == "macOS" ]]; then
verify_runtime=false
echo "Using legacy macOS Formula validation because no Cask definition exists."
else
verify_runtime=true
fi
fi

{
echo "type=$package_type"
echo "definition=$definition"
echo "verify_runtime=$verify_runtime"
} >> "$GITHUB_OUTPUT"

- name: Tap and install modernize
run: |
brew tap ${{ github.repository }} https://github.com/${{ github.repository }}
brew trust ${{ github.repository }}
brew install modernize
brew install --${{ steps.package.outputs.type }} modernize

- name: Extract expected version from formula
id: formula
- name: Extract expected version
id: version
run: |
version=$(grep '^ version ' Formula/modernize.rb | sed 's/.*"\(.*\)".*/\1/')
version=$(grep '^ version ' "${{ steps.package.outputs.definition }}" | sed 's/.*"\(.*\)".*/\1/')
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Expected version: $version"

Expand All @@ -51,10 +78,41 @@ jobs:
run: |
output=$(modernize --version)
echo "Version output: $output"
if echo "$output" | grep -q "${{ steps.formula.outputs.version }}"; then
if echo "$output" | grep -q "${{ steps.version.outputs.version }}"; then
echo "Version verified successfully"
else
echo "::error::Version mismatch. Expected '${{ steps.formula.outputs.version }}' in output but got: $output"
echo "::error::Version mismatch. Expected '${{ steps.version.outputs.version }}' in output but got: $output"
exit 1
fi

- name: Verify bundled Copilot runtime
if: steps.package.outputs.verify_runtime == 'true'
run: |
if [[ "${{ steps.package.outputs.type }}" == "cask" ]]; then
runtime_root="$(brew --caskroom modernize)"
else
runtime_root="$(brew --prefix modernize)/libexec"
fi

runtime=$(find "$runtime_root" -path '*/native/copilot' -type f | head -1)
runtime_node=$(find "$runtime_root" -path '*/native/runtime.node' -type f | head -1)
test -n "$runtime"
test -n "$runtime_node"

if [[ "${{ runner.os }}" == "macOS" ]]; then
codesign --verify --strict --verbose=4 "$runtime"
codesign --verify --strict --verbose=4 "$runtime_node"

runtime_team=$(codesign -dv --verbose=4 "$runtime" 2>&1 | sed -n 's/^TeamIdentifier=//p')
node_team=$(codesign -dv --verbose=4 "$runtime_node" 2>&1 | sed -n 's/^TeamIdentifier=//p')
test -n "$runtime_team"
test "$runtime_team" = "$node_team"
fi

runtime_stderr=$(mktemp)
"$runtime" --headless --no-auto-update --stdio </dev/null >/dev/null 2>"$runtime_stderr"
if grep -Eqi 'failed to load runtime|dlopen failed|Library Validation failed' "$runtime_stderr"; then
cat "$runtime_stderr" >&2
exit 1
fi

Expand All @@ -67,7 +125,7 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
title: `Homebrew validation failed on ${{ matrix.name }}`,
body: `Homebrew installation validation failed for **${{ matrix.name }}**.\n\n**PR:** #${{ github.event.pull_request.number }}\n**Expected version:** ${{ steps.formula.outputs.version }}\n**Workflow run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n\nPlease investigate the failure.`,
body: `Homebrew installation validation failed for **${{ matrix.name }}**.\n\n**PR:** #${{ github.event.pull_request.number }}\n**Expected version:** ${{ steps.version.outputs.version }}\n**Workflow run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n\nPlease investigate the failure.`,
labels: ['homebrew', 'validation-failure'],
assignees: ['galiacheng']
});
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,34 @@ Minimum requirements:
### Linux / macOS

**Option 1 — Homebrew:**

First, add and trust the Modernize tap:

```bash
brew tap microsoft/modernize https://github.com/microsoft/modernize-cli
brew trust microsoft/modernize
brew install modernize
```

On Linux, install the formula:

```bash
brew install --formula modernize
```

On macOS, install the cask:

```bash
brew install --cask modernize
```

> [!IMPORTANT]
> If you previously installed Modernize on macOS using the formula, migrate to the cask once:
>
> ```bash
> brew uninstall --formula modernize
> brew install --cask modernize
> ```

**Option 2 — Shell script:**
```bash
curl -fsSL https://raw.githubusercontent.com/microsoft/modernize-cli/main/scripts/install.sh | sh
Expand Down