|
| 1 | +name: Release Homebrew Package |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: macos-14 |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout code |
| 14 | + uses: actions/checkout@v3 |
| 15 | + |
| 16 | + - name: Set up Python |
| 17 | + uses: actions/setup-python@v4 |
| 18 | + with: |
| 19 | + python-version: '3.9' |
| 20 | + |
| 21 | + - name: Install dependencies |
| 22 | + run: | |
| 23 | + brew install gmp bazelisk |
| 24 | + pip3 install cpplint pytest numpy sympy==1.12.1 cairo-lang==0.12.0 |
| 25 | +
|
| 26 | + - name: Build binaries |
| 27 | + run: | |
| 28 | + chmod +x ./build.sh |
| 29 | + ./build.sh |
| 30 | +
|
| 31 | + - name: Test binaries |
| 32 | + run: | |
| 33 | + chmod +x ./test.sh |
| 34 | + ./test.sh |
| 35 | +
|
| 36 | + - name: Copy and rename binaries for Homebrew |
| 37 | + run: | |
| 38 | + cp /tmp/stone-prover/build/bazelbin/src/starkware/main/cpu/cpu_air_prover ./cpu_air_prover-arm64 |
| 39 | + cp /tmp/stone-prover/build/bazelbin/src/starkware/main/cpu/cpu_air_verifier ./cpu_air_verifier-arm64 |
| 40 | + chmod +x cpu_air_prover-arm64 cpu_air_verifier-arm64 |
| 41 | +
|
| 42 | + - name: Package binaries |
| 43 | + run: tar -czvf stone-prover-macos-arm64.tar.gz cpu_air_prover-arm64 cpu_air_verifier-arm64 |
| 44 | + |
| 45 | + - name: Compute SHA256 |
| 46 | + id: compute_sha |
| 47 | + run: | |
| 48 | + SHA256=$(shasum -a 256 stone-prover-macos-arm64.tar.gz | awk '{ print $1 }') |
| 49 | + echo "${SHA256}" > sha256_arm64.txt |
| 50 | +
|
| 51 | + - name: Upload binaries |
| 52 | + uses: actions/upload-artifact@v3 |
| 53 | + with: |
| 54 | + name: stone-prover-macos-arm64 |
| 55 | + path: | |
| 56 | + stone-prover-macos-arm64.tar.gz |
| 57 | +
|
| 58 | + - name: Upload sha256 |
| 59 | + uses: actions/upload-artifact@v3 |
| 60 | + with: |
| 61 | + name: sha256_arm64 |
| 62 | + path: | |
| 63 | + sha256_arm64.txt |
| 64 | +
|
| 65 | + release: |
| 66 | + needs: build |
| 67 | + runs-on: ubuntu-latest |
| 68 | + steps: |
| 69 | + - name: Download binaries and SHA256 artifacts for arm64 |
| 70 | + uses: actions/download-artifact@v3 |
| 71 | + with: |
| 72 | + name: stone-prover-macos-arm64 |
| 73 | + path: ./release_assets/arm64 |
| 74 | + |
| 75 | + - name: Create GitHub Release |
| 76 | + uses: softprops/action-gh-release@v2 |
| 77 | + with: |
| 78 | + files: | |
| 79 | + ./release_assets/arm64/stone-prover-macos-arm64.tar.gz |
| 80 | + env: |
| 81 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + |
| 83 | + update_formula: |
| 84 | + needs: release |
| 85 | + runs-on: ubuntu-latest |
| 86 | + steps: |
| 87 | + - name: Checkout Homebrew Formula Repository |
| 88 | + uses: actions/checkout@v3 |
| 89 | + with: |
| 90 | + repository: dipdup-io/homebrew-stone-prover |
| 91 | + token: ${{ secrets.HOMEBREW_ACCESS_TOKEN }} |
| 92 | + path: homebrew-stone-prover |
| 93 | + |
| 94 | + - name: Set up Git |
| 95 | + working-directory: homebrew-stone-prover |
| 96 | + run: | |
| 97 | + git config user.name "GitHub Actions" |
| 98 | + git config user.email "actions@github.com" |
| 99 | +
|
| 100 | + - name: Download arm64 SHA256 Artifact |
| 101 | + uses: actions/download-artifact@v3 |
| 102 | + with: |
| 103 | + name: sha256_arm64 |
| 104 | + path: ./release_assets/arm64 |
| 105 | + |
| 106 | + - name: Read SHA256 |
| 107 | + run: | |
| 108 | + SHA256_arm64=$(cat ./release_assets/arm64/sha256_arm64.txt) |
| 109 | + echo "SHA256_arm64=${SHA256_arm64}" >> $GITHUB_ENV |
| 110 | +
|
| 111 | + - name: Update Homebrew Formula |
| 112 | + working-directory: homebrew-stone-prover |
| 113 | + run: | |
| 114 | + VERSION=${GITHUB_REF#refs/tags/v} |
| 115 | + ROOT_URL="https://github.com/dipdup-io/stone-packaging/releases/download/v${VERSION}" |
| 116 | +
|
| 117 | + sed -i "s|version \".*\"|version \"${VERSION}\"|" Formula/stone-prover.rb |
| 118 | + sed -i "s|url \".*\"|url \"${ROOT_URL}/stone-prover-macos-arm64.tar.gz\"|" Formula/stone-prover.rb |
| 119 | + sed -i "s|sha256 \".*\"|sha256 \"${SHA256_arm64}\"|" Formula/stone-prover.rb |
| 120 | +
|
| 121 | + git add Formula/stone-prover.rb |
| 122 | + git commit -m "Update Stone Prover to version ${VERSION} for arm64 and x86_64" || echo "No changes to commit" |
| 123 | + git push origin main |
0 commit comments