Skip to content

Ci experiments (#335) #170

Ci experiments (#335)

Ci experiments (#335) #170

name: Create PR in Homebrew Repo to build binaries
on:
push:
branches:
- main
jobs:
create-pr:
runs-on: macos-latest
permissions:
contents: write
steps:
- name: Checkout Source Repository
uses: actions/checkout@v4
- name: Clone Target Repository
run: |
git clone https://github.com/asymptotic-code/homebrew-sui-prover.git
- name: Make Changes in Target Repo
run: |
cd homebrew-sui-prover/Formula
FORMULA_FILE="sui-prover.rb"
CURRENT_VERSION=$(sed -n 's/version "\(.*\)"/\1/p' "$FORMULA_FILE" | sed 's/^ *//;s/ *$//' | head -n 1)
NEW_VERSION=$(echo "$CURRENT_VERSION" | awk -F. '{print $1"."$2"."$3+1}')
sed -i.bak "s/version \"$CURRENT_VERSION\"/version \"$NEW_VERSION\"/" "$FORMULA_FILE"
rm -f "$FORMULA_FILE.bak"
echo "Updated formula version: $CURRENT_VERSION → $NEW_VERSION"
- name: Push Changes
run: |
cd homebrew-sui-prover
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "sui-prover"
git add .
git commit -m "Automated version update"
git push -f https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/asymptotic-code/homebrew-sui-prover.git sui-prover
- name: Create Pull Request
run: |
gh auth login --with-token <<< "${{ secrets.PAT_TOKEN }}"
gh pr create --repo asymptotic-code/homebrew-sui-prover \
--base main \
--head sui-prover \
--title "Automated version Update" \
--body "This PR was created by a GitHub Action."
wait-for-checks:
needs: create-pr
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Wait for Workflow Runs to Complete
run: |
PR_NUMBER=$(curl -s -H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
"https://api.github.com/repos/asymptotic-code/homebrew-sui-prover/pulls?state=open" | jq -r \
'.[] | select(.head.ref=="sui-prover") | .number')
echo "Waiting for workflows in my-org/target-repo PR #$PR_NUMBER..."
while true; do
STATUS=$(curl -s -H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
"https://api.github.com/repos/asymptotic-code/homebrew-sui-prover/actions/runs" | jq -r \
'.workflow_runs | map(select(.head_branch == "sui-prover")) | map(.status) | unique[]')
echo "Current statuses: $STATUS"
if [[ "$STATUS" == "completed" ]]; then
echo "All checks passed!"
break
fi
echo "Waiting for checks to complete..."
sleep 60
done
add-label:
needs: wait-for-checks
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Add Label to PR
run: |
PR_NUMBER=$(curl -s -H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
"https://api.github.com/repos/asymptotic-code/homebrew-sui-prover/pulls?state=open" | jq -r \
'.[] | select(.head.ref=="sui-prover") | .number')
curl -s -X POST -H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/asymptotic-code/homebrew-sui-prover/issues/$PR_NUMBER/labels" \
-d '{"labels":["pr-pull"]}'