-
Notifications
You must be signed in to change notification settings - Fork 137
Fix Homebrew CI and add automated release workflow #1120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9e0bb8b
e3b163e
45403ff
5851233
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,187 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: Update Homebrew Formula on Release | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Triggers when a new version tag is pushed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tags: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 'v*' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+4
to
+7
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| branches: [master] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| paths: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - '.github/workflows/homebrew-release.yml' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inputs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| version: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: 'Version to release (without v prefix, e.g., 5.2.0)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| required: true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dry_run: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: 'Dry run (skip push to homebrew-mfc)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| required: false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| update-homebrew-tap: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: Update homebrew-mfc tap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+24
to
+27
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Determine version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VERSION="${{ inputs.version }}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif [[ "${{ github.event_name }}" == "pull_request" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Use existing version for PR testing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VERSION="5.2.0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "::notice::PR test mode - using version $VERSION" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+35
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Instead of hard-coding the version for pull request tests, dynamically extract the version from the
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Extract version from tag (remove 'v' prefix) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VERSION="${GITHUB_REF#refs/tags/v}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "::error::Invalid version format: $VERSION (expected X.Y.Z)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Version: $VERSION" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Compute SHA256 of release tarball | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: sha256 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VERSION="${{ steps.version.outputs.version }}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| URL="https://github.com/MFlowCode/MFC/archive/refs/tags/v${VERSION}.tar.gz" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+52
to
+56
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Add
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Downloading tarball from: $URL" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Verify URL is reachable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HTTP_CODE=$(curl -sI -w "%{http_code}" -o /dev/null "$URL") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$HTTP_CODE" != "200" && "$HTTP_CODE" != "302" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "::error::Release tarball not found at $URL (HTTP $HTTP_CODE)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "::error::Make sure the tag v${VERSION} exists and the release is published" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Compute SHA256 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SHA256=$(curl -sL "$URL" | sha256sum | awk '{print $1}') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ -z "$SHA256" || "$SHA256" == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "::error::Failed to compute SHA256 (empty file or download failed)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "sha256=$SHA256" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "SHA256: $SHA256" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: PR test summary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: ${{ github.event_name == 'pull_request' }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "## PR Test Mode" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Validated:" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "- Version parsing: v${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "- SHA256 computation: \`${{ steps.sha256.outputs.sha256 }}\`" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Skipped (secrets not available for fork PRs):" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "- Checkout homebrew-mfc" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "- Update formula" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "- Push to tap" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "The full workflow will run when a \`v*\` tag is pushed after merge." >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Checkout homebrew-mfc tap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: ${{ github.event_name != 'pull_request' }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| repository: MFlowCode/homebrew-mfc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| token: ${{ secrets.TAP_REPO_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| path: homebrew-mfc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Update formula | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: ${{ github.event_name != 'pull_request' }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VERSION="${{ steps.version.outputs.version }}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SHA256="${{ steps.sha256.outputs.sha256 }}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FORMULA="homebrew-mfc/Formula/mfc.rb" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Updating formula to v${VERSION}..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Update URL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sed -i "s|url \"https://github.com/MFlowCode/MFC/archive/refs/tags/v[^\"]*\.tar\.gz\"|url \"https://github.com/MFlowCode/MFC/archive/refs/tags/v${VERSION}.tar.gz\"|" "$FORMULA" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Update SHA256 (the one right after url, not bottle SHAs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # This uses awk to only update the first sha256 after the url line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| awk -v newsha="$SHA256" ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /^ url "https:\/\/github.com\/MFlowCode\/MFC/ { found_url=1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| found_url && /^ sha256 "/ && !updated { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sub(/sha256 "[^"]*"/, "sha256 \"" newsha "\"") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| updated=1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { print } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ' "$FORMULA" > "$FORMULA.tmp" && mv "$FORMULA.tmp" "$FORMULA" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Remove existing bottle block (new bottles will be built by bottle.yml) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # This removes everything between "bottle do" and the matching "end" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| awk ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /^ bottle do/ { in_bottle=1; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| in_bottle && /^ end/ { in_bottle=0; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| !in_bottle { print } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ' "$FORMULA" > "$FORMULA.tmp" && mv "$FORMULA.tmp" "$FORMULA" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+128
to
+132
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Updated formula:" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| head -30 "$FORMULA" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Validate updated formula | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: ${{ github.event_name != 'pull_request' }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd homebrew-mfc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Checking Ruby syntax..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ruby -c Formula/mfc.rb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Verifying URL and SHA256 were updated..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| grep -q "v${{ steps.version.outputs.version }}.tar.gz" Formula/mfc.rb || (echo "::error::URL not updated"; exit 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| grep -q "${{ steps.sha256.outputs.sha256 }}" Formula/mfc.rb || (echo "::error::SHA256 not updated"; exit 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Formula validation passed!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Commit and push to homebrew-mfc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: ${{ github.event_name != 'pull_request' && github.event.inputs.dry_run != 'true' }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd homebrew-mfc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VERSION="${{ steps.version.outputs.version }}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git config user.name "github-actions[bot]" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git add Formula/mfc.rb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git commit -m "Update MFC to v${VERSION}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Pushing to homebrew-mfc..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git push origin main | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Successfully pushed formula update!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "The bottle.yml workflow in homebrew-mfc will now build bottles automatically." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+150
to
+166
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Instead of pushing directly to the
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Dry run summary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'true' }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "::notice::DRY RUN - skipped push to homebrew-mfc" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Would have committed the following changes:" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd homebrew-mfc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git diff Formula/mfc.rb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+174
to
+175
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd homebrew-mfc | |
| git diff Formula/mfc.rb | |
| if [ -d homebrew-mfc ]; then | |
| cd homebrew-mfc | |
| git diff Formula/mfc.rb | |
| else | |
| echo "::notice::homebrew-mfc tap directory not found; nothing to diff." | |
| fi |
Copilot
AI
Feb 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Summary step (lines 177-187) will run even in dry-run mode because its condition is github.event_name != 'pull_request', which includes workflow_dispatch dry runs. This will display "Homebrew Formula Updated" even though nothing was actually pushed in dry-run mode. Consider updating the condition to also exclude dry runs: github.event_name != 'pull_request' && github.event.inputs.dry_run != 'true'
| if: ${{ github.event_name != 'pull_request' }} | |
| if: ${{ github.event_name != 'pull_request' && github.event.inputs.dry_run != 'true' }} |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix this, explicitly set least‑privilege GITHUB_TOKEN permissions in the workflow. This workflow does not need to write to the current repository or to issues/PRs; it only needs to read repository contents (and uses a separate PAT secret for pushing to homebrew-mfc). Therefore, the safest fix is to add a top‑level permissions: block with contents: read. Placing it at the root (next to name and on) applies to all jobs, including update-homebrew-tap, without changing any behavior.
Concretely:
-
Edit
.github/workflows/homebrew-release.yml. -
After the existing
name: Update Homebrew Formula on Releaseline, insert:permissions: contents: read
No additional methods, imports, or other definitions are needed; this is a pure configuration change in the workflow file.
-
Copy modified lines R2-R3
| @@ -1,4 +1,6 @@ | ||
| name: Update Homebrew Formula on Release | ||
| permissions: | ||
| contents: read | ||
|
|
||
| # Triggers when a new version tag is pushed | ||
| on: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading summary output during dry run mode
Low Severity
The "Summary" step runs when dry_run=true because its condition only checks github.event_name != 'pull_request', not the dry_run flag. This causes the job summary to incorrectly state "Homebrew Formula Updated" and "The bottle.yml workflow will now build bottles for this release" even though the push was skipped. The condition at line 178 needs to also exclude dry runs, similar to the commit/push step at line 151.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -209,51 +209,57 @@ jobs: | |||||||||||||||||
| - name: Test MFC installation | ||||||||||||||||||
| run: | | ||||||||||||||||||
| echo "=== Testing MFC Installation ===" | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| # Use the full tap-qualified name since we installed from mflowcode/test | ||||||||||||||||||
| MFC_PREFIX="$(brew --prefix mflowcode/test/mfc)" | ||||||||||||||||||
| echo "MFC prefix: $MFC_PREFIX" | ||||||||||||||||||
|
|
||||||||||||||||||
| echo "1. Checking binaries exist and are executable..." | ||||||||||||||||||
| test -f $(brew --prefix)/bin/mfc && test -x $(brew --prefix)/bin/mfc | ||||||||||||||||||
|
Comment on lines
+214
to
218
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: In the test step, replace
Suggested change
|
||||||||||||||||||
| test -f $(brew --prefix)/bin/pre_process && test -x $(brew --prefix)/bin/pre_process | ||||||||||||||||||
| test -f $(brew --prefix)/bin/simulation && test -x $(brew --prefix)/bin/simulation | ||||||||||||||||||
| test -f $(brew --prefix)/bin/post_process && test -x $(brew --prefix)/bin/post_process | ||||||||||||||||||
| echo " ✓ All binaries exist and are executable" | ||||||||||||||||||
|
|
||||||||||||||||||
| echo "2. Verifying installation structure..." | ||||||||||||||||||
| test -f $(brew --prefix mfc)/libexec/mfc.sh | ||||||||||||||||||
| test -d $(brew --prefix mfc)/toolchain | ||||||||||||||||||
| test -f "$MFC_PREFIX/libexec/mfc.sh" | ||||||||||||||||||
| test -d "$MFC_PREFIX/toolchain" | ||||||||||||||||||
| echo " ✓ Installation structure verified" | ||||||||||||||||||
|
|
||||||||||||||||||
| echo "3. Checking Python venv..." | ||||||||||||||||||
| test -d $(brew --prefix mfc)/libexec/venv | ||||||||||||||||||
| test -f $(brew --prefix mfc)/libexec/venv/bin/python | ||||||||||||||||||
| test -f $(brew --prefix mfc)/libexec/venv/bin/pip | ||||||||||||||||||
| test -d "$MFC_PREFIX/libexec/venv" | ||||||||||||||||||
| test -f "$MFC_PREFIX/libexec/venv/bin/python" | ||||||||||||||||||
| test -f "$MFC_PREFIX/libexec/venv/bin/pip" | ||||||||||||||||||
| echo " ✓ Python venv exists" | ||||||||||||||||||
|
|
||||||||||||||||||
| echo "4. Checking examples..." | ||||||||||||||||||
| test -d $(brew --prefix mfc)/examples | ||||||||||||||||||
| test -f $(brew --prefix mfc)/examples/1D_sodshocktube/case.py | ||||||||||||||||||
| test -d "$MFC_PREFIX/examples" | ||||||||||||||||||
| test -f "$MFC_PREFIX/examples/1D_sodshocktube/case.py" | ||||||||||||||||||
| echo " ✓ Examples installed" | ||||||||||||||||||
|
|
||||||||||||||||||
| echo "5. Testing mfc wrapper..." | ||||||||||||||||||
| mfc --help | ||||||||||||||||||
| echo " ✓ mfc --help succeeded" | ||||||||||||||||||
|
|
||||||||||||||||||
| echo "=== All tests passed! ===" | ||||||||||||||||||
|
|
||||||||||||||||||
| - name: Run MFC test case | ||||||||||||||||||
| run: | | ||||||||||||||||||
| echo "Running a simple test case (1D Sod shock tube)..." | ||||||||||||||||||
| MFC_PREFIX="$(brew --prefix mflowcode/test/mfc)" | ||||||||||||||||||
| TESTDIR=$(mktemp -d) | ||||||||||||||||||
| cp $(brew --prefix mfc)/examples/1D_sodshocktube/case.py "$TESTDIR/" | ||||||||||||||||||
| cp "$MFC_PREFIX/examples/1D_sodshocktube/case.py" "$TESTDIR/" | ||||||||||||||||||
|
|
||||||||||||||||||
| echo "Running with $(sysctl -n hw.ncpu) processors..." | ||||||||||||||||||
| # Use absolute path and shorthand syntax (mfc auto-detects and prepends 'run') | ||||||||||||||||||
| mfc "$TESTDIR/case.py" -j $(sysctl -n hw.ncpu) | ||||||||||||||||||
|
|
||||||||||||||||||
| echo "Test case completed successfully!" | ||||||||||||||||||
|
|
||||||||||||||||||
| - name: Uninstall and cleanup | ||||||||||||||||||
| if: always() | ||||||||||||||||||
| run: | | ||||||||||||||||||
| echo "Cleaning up..." | ||||||||||||||||||
| brew uninstall mfc || true | ||||||||||||||||||
| brew uninstall mflowcode/test/mfc || true | ||||||||||||||||||
| brew untap mflowcode/test || true | ||||||||||||||||||
| brew cleanup | ||||||||||||||||||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High-level Suggestion
Replace the brittle
sedandawkcommands used for modifying the Homebrew formula with a more robust Ruby script. This makes the release automation less likely to fail due to future formatting changes in the formula file. [High-level, importance: 8]Solution Walkthrough:
Before:
After: