Skip to content

Commit

Permalink
fix: homebrew support (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
smrz2001 authored Jul 2, 2024
1 parent 3379fa7 commit 0bc988e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
32 changes: 17 additions & 15 deletions .github/workflows/update-homebrew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,45 @@ name: Update Homebrew Formula

on:
release:
types: [released]
workflow_dispatch:

jobs:
update-homebrew-formula:
name: Update Homebrew Formula
runs-on: ubuntu-latest
if: ${{ github.event.action == 'released' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Get Latest Release
id: release
run: |
# Download files from the latest release and calculate their SHA256 checksums
gh release view --json tagName,assets > release.json
echo "X86_URL=$(jq -r '.assets[] | select(.name | contains("x86_64-apple-darwin")) | .url' release.json)" >> $GITHUB_OUTPUT
echo "ARM_URL=$(jq -r '.assets[] | select(.name | contains("aarch64-apple-darwin")) | .url' release.json)" >> $GITHUB_OUTPUT
gh release download -p '*apple-darwin*'
echo "X86_SHA256=$(sha256sum ceramic-one_x86_64-apple-darwin.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
echo "ARM_SHA256=$(sha256sum ceramic-one_aarch64-apple-darwin.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
echo "VERSION=$(jq -r '.tagName' release.json)" >> $GITHUB_OUTPUT
echo "X86_URL=$(jq -r '.assets[] | select(.name | contains("x86_64-apple-darwin")) | .url' release.json)" >> $GITHUB_OUTPUT
echo "ARM_URL=$(jq -r '.assets[] | select(.name | contains("aarch64-apple-darwin")) | .url' release.json)" >> $GITHUB_OUTPUT
echo "X86_SHA=$(sha256sum ceramic-one_x86_64-apple-darwin.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
echo "ARM_SHA=$(sha256sum ceramic-one_aarch64-apple-darwin.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
- name: Checkout Homebrew Tap
uses: actions/checkout@v2
with:
repository: ceramicnetwork/homebrew-tap
path: homebrew-tap
- name: Update Homebrew Formula
run: |
sed -i.bak -E "s|(url \".*_x86_64-apple-darwin.*\")|url \"${steps.release.outputs.X86_URL}\"|" homebrew-tap/Formula/ceramic-one.rb
sed -i '' '/CPU.intel?/,/sha256/ s/sha256 "[^"]*"/sha256 "${steps.release.outputs.X86_SHA}"/' homebrew-tap/Formula/ceramic-one.rb
sed -i.bak -E "s|(url \".*_aarch64-apple-darwin.*\")|url \"${steps.release.outputs.ARM_URL}\"|" homebrew-tap/Formula/ceramic-one.rb
sed -i '' '/CPU.arm?/,/sha256/ s/sha256 "[^"]*"/sha256 "${steps.release.outputs.ARM_SHA}"/' homebrew-tap/Formula/ceramic-one.rb
cd homebrew-tap
sed -i -E "s|(url \".*ceramic-one_x86_64-apple-darwin.*\")|url \"${{ steps.release.outputs.X86_URL }}\"|" Formula/ceramic-one.rb
sed -i -E "/CPU.intel?/,/sha256/ s/sha256 \"[^\"]*\"/sha256 \"${{ steps.release.outputs.X86_SHA }}\"/" Formula/ceramic-one.rb
sed -i -E "s|(url \".*ceramic-one_aarch64-apple-darwin.*\")|url \"${{ steps.release.outputs.ARM_URL }}\"|" Formula/ceramic-one.rb
sed -i -E "/CPU.arm?/,/sha256/ s/sha256 \"[^\"]*\"/sha256 \"${{ steps.release.outputs.ARM_SHA }}\"/" Formula/ceramic-one.rb
- name: Commit and Push changes
run: |
cd homebrew-tap
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add Formula/rust-ceramic.rb
git diff
git commit -m "Update rust-ceramic formula to ${{ steps.release.outputs.VERSION }}"
# git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
git add Formula/ceramic-one.rb
git commit -m "Update ceramic-one formula to ${{ steps.release.outputs.VERSION }}"
git push
3 changes: 1 addition & 2 deletions ci-scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ echo "Building artifacts for "$TARGET

cargo build --release --locked --target $TARGET


if [ "$EXT" = "bin" ]; then
echo "Compressing package for $TARGET"
tar -cvzf $ARTIFACTS_DIR/ceramic-one_$TARGET.tar.gz $BIN_DIR/ceramic-one
tar -cvzf ceramic-one_$TARGET.tar.gz -C $BIN_DIR ceramic-one
else
echo "Building package for $TARGET"
fpm --fpm-options-file $CONFIG_FILE -C $BIN_DIR -v $PKG_VERSION -p $OUT_PATH ceramic-one=$INSTALL_DIR/ceramic-one
Expand Down

0 comments on commit 0bc988e

Please sign in to comment.