@@ -52,116 +52,3 @@ jobs:
5252 env :
5353 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
5454 run : npm publish --provenance --access public
55-
56- formula :
57- name : open Homebrew formula PR
58- needs : publish
59- runs-on : ubuntu-latest
60- continue-on-error : true
61- env :
62- VERSION : ${{ needs.publish.outputs.version }}
63- steps :
64- - uses : actions/checkout@v6
65- with :
66- ref : main
67- fetch-depth : 0
68-
69- - uses : actions/setup-node@v6
70- with :
71- node-version : " 20"
72- registry-url : " https://registry.npmjs.org"
73-
74- - name : Wait for tarball + compute sha256
75- id : tarball
76- run : |
77- set -euo pipefail
78- v="${VERSION}"
79- pkg="@openagentlock/cli"
80-
81- deadline=$(( $(date +%s) + 300 ))
82- tarball=""
83- integrity=""
84- while [ "$(date +%s)" -lt "$deadline" ]; do
85- tarball=$(npm view "${pkg}@${v}" dist.tarball 2>/dev/null || true)
86- integrity=$(npm view "${pkg}@${v}" dist.integrity 2>/dev/null || true)
87- if [ -n "$tarball" ] && [ -n "$integrity" ]; then
88- if curl -fLsS --retry 3 --retry-delay 3 --max-time 30 \
89- -o /tmp/cli.tgz "$tarball"; then
90- break
91- fi
92- fi
93- echo "tarball not ready yet; retrying in 15s..."
94- sleep 15
95- tarball=""
96- done
97-
98- if [ -z "$tarball" ] || [ ! -s /tmp/cli.tgz ]; then
99- echo "::error::Tarball for ${pkg}@${v} not available after 5 minutes" >&2
100- exit 1
101- fi
102-
103- want_sha512=$(printf '%s' "$integrity" | sed -E 's|^sha512-||' \
104- | base64 -d 2>/dev/null | xxd -p -c 256 | tr -d '\n')
105- got_sha512=$(shasum -a 512 /tmp/cli.tgz | awk '{print $1}')
106- if [ "$want_sha512" != "$got_sha512" ]; then
107- echo "::error::Integrity mismatch: registry=${want_sha512} got=${got_sha512}" >&2
108- exit 1
109- fi
110-
111- sha256=$(shasum -a 256 /tmp/cli.tgz | awk '{print $1}')
112- echo "tarball=$tarball" >> "$GITHUB_OUTPUT"
113- echo "sha256=$sha256" >> "$GITHUB_OUTPUT"
114- {
115- echo "### Tarball"
116- echo ""
117- echo "- url: \`$tarball\`"
118- echo "- sha256: \`$sha256\`"
119- } >> "$GITHUB_STEP_SUMMARY"
120-
121- - name : Edit Formula
122- env :
123- SHA256 : ${{ steps.tarball.outputs.sha256 }}
124- run : |
125- set -euo pipefail
126- v="${VERSION}"
127- sed -i -E \
128- -e "s|cli-[0-9]+\.[0-9]+\.[0-9]+\.tgz|cli-${v}.tgz|" \
129- -e "s|sha256 \"[^\"]+\"|sha256 \"${SHA256}\"|" \
130- -e "s|version \"[^\"]+\"|version \"${v}\"|" \
131- Formula/agentlock.rb
132- if git diff --quiet -- Formula/agentlock.rb; then
133- echo "Formula already at v${v}; nothing to do." \
134- >> "$GITHUB_STEP_SUMMARY"
135- echo "NO_CHANGES=1" >> "$GITHUB_ENV"
136- fi
137-
138- - name : Open PR
139- if : env.NO_CHANGES != '1'
140- env :
141- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
142- run : |
143- set -euo pipefail
144- v="${VERSION}"
145- branch="formula/v${v}"
146- git config user.name "github-actions[bot]"
147- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
148-
149- # Recreate the branch cleanly (delete any stale remote copy first).
150- git push origin --delete "$branch" 2>/dev/null || true
151- git checkout -B "$branch"
152- git add Formula/agentlock.rb
153- git commit -m "Formula: pin v${v} sha256"
154- git push -u origin "$branch"
155-
156- existing=$(gh pr list --head "$branch" --state open \
157- --json number --jq '.[0].number' || true)
158- if [ -n "$existing" ]; then
159- echo "PR #$existing already open for $branch" \
160- >> "$GITHUB_STEP_SUMMARY"
161- else
162- gh pr create \
163- --base main \
164- --head "$branch" \
165- --title "Formula: pin v${v} sha256" \
166- --body "Automated formula bump after publishing \`@openagentlock/cli@${v}\` to npm."
167- fi
0 commit comments