@@ -107,31 +107,28 @@ jobs:
107107 - name : Update formula in homebrew-tap
108108 env :
109109 GH_TOKEN : ${{ secrets.HOMEBREW_TAP_TOKEN }}
110- VERSION : ${{ github.ref_name }}
111110 run : |
112- VERSION="${VERSION#v}"
113-
114- # Fetch current formula
115- CONTENT=$(gh api repos/AlphaWaveSystems/homebrew-tap/contents/Formula/probe.rb \
116- --jq '{sha: .sha, content: (.content | @base64d)}')
117- FILE_SHA=$(echo "$CONTENT" | jq -r '.sha')
118-
119- # Update version and checksums using Python for reliable multi-line editing
120- FORMULA=$(echo "$CONTENT" | jq -r '.content' | python3 - <<PYEOF
121- import sys, re
122-
123- text = sys.stdin.read()
124- text = re.sub(r'version "\d+\.\d+\.\d+"', f'version "${VERSION}"', text)
125- text = re.sub(r'(probe-darwin-arm64"\n\s+sha256 )"[a-f0-9]+"', r'\g<1>"${{ steps.sha.outputs.darwin_arm64 }}"', text)
126- text = re.sub(r'(probe-darwin-amd64"\n\s+sha256 )"[a-f0-9]+"', r'\g<1>"${{ steps.sha.outputs.darwin_amd64 }}"', text)
127- text = re.sub(r'(probe-linux-amd64"\n\s+sha256 )"[a-f0-9]+"', r'\g<1>"${{ steps.sha.outputs.linux_amd64 }}"', text)
128- print(text, end="")
129- PYEOF
130- )
131-
132- # Push updated formula
133- gh api repos/AlphaWaveSystems/homebrew-tap/contents/Formula/probe.rb \
134- --method PUT \
135- --field message="chore : update probe to v${VERSION}" \
136- --field content="$(echo "$FORMULA" | base64)" \
137- --field sha="$FILE_SHA"
111+ VERSION="${GITHUB_REF_NAME#v}"
112+ SHA_ARM64="${{ steps.sha.outputs.darwin_arm64 }}"
113+ SHA_AMD64="${{ steps.sha.outputs.darwin_amd64 }}"
114+ SHA_LINUX="${{ steps.sha.outputs.linux_amd64 }}"
115+
116+ git clone "https://x-access-token:${GH_TOKEN}@github.com/AlphaWaveSystems/homebrew-tap.git"
117+ cd homebrew-tap
118+ git config user.name "Patrick Bertsch"
119+ git config user.email "patrick@alphawavesystems.com"
120+
121+ # Update version
122+ sed -i "s/version \"[0-9.]*\"/version \"${VERSION}\"/" Formula/probe.rb
123+
124+ # Update SHA256s — find asset URL line, update the sha256 on the next line
125+ awk -v arm64="$SHA_ARM64" -v amd64="$SHA_AMD64" -v linux="$SHA_LINUX" '
126+ /probe-darwin-arm64/ { print; getline; gsub(/sha256 "[a-f0-9]+"/, "sha256 \"" arm64 "\""); print; next }
127+ /probe-darwin-amd64/ { print; getline; gsub(/sha256 "[a-f0-9]+"/, "sha256 \"" amd64 "\""); print; next }
128+ /probe-linux-amd64/ { print; getline; gsub(/sha256 "[a-f0-9]+"/, "sha256 \"" linux "\""); print; next }
129+ { print }
130+ ' Formula/probe.rb > Formula/probe.rb.tmp && mv Formula/probe.rb.tmp Formula/probe.rb
131+
132+ git add Formula/probe.rb
133+ git commit -m "chore: update probe to v${VERSION}"
134+ git push
0 commit comments