Update Homebrew Formula #56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Homebrew Formula | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release_tag: | |
| description: 'Release tag (e.g. v0.6.3)' | |
| required: false | |
| workflow_call: | |
| inputs: | |
| release_tag: | |
| description: 'Release tag passed from caller workflow' | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-homebrew: | |
| name: Update Homebrew Formula | |
| runs-on: macos-latest | |
| environment: packaging | |
| if: github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' | |
| steps: | |
| - name: Checkout this repository | |
| uses: actions/checkout@v4 | |
| - name: Install gnu-sed | |
| run: brew install gnu-sed | |
| - name: Determine version tag | |
| id: get_version | |
| run: | | |
| # Check workflow_dispatch input first, then workflow_call input | |
| INPUT_TAG="${{ github.event.inputs.release_tag || inputs.release_tag }}" | |
| if [ -n "$INPUT_TAG" ]; then | |
| echo "VERSION=$INPUT_TAG" >> $GITHUB_ENV | |
| else | |
| # Get the latest official (non-pre-release) release | |
| TAG=$(gh release view --json tagName --jq .tagName) | |
| echo "VERSION=$TAG" >> $GITHUB_ENV | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Clone Homebrew tap repository | |
| run: | | |
| git clone https://x-access-token:${{ secrets.HOMEBREW_TAP_TOKEN }}@github.com/lablup/homebrew-tap.git | |
| cd homebrew-tap | |
| git config user.name "GitHub Action" | |
| git config user.email "actions@github.com" | |
| - name: Download release artifacts and calculate SHA256 | |
| run: | | |
| cd homebrew-tap | |
| RAW_VERSION="${{ env.VERSION }}" | |
| VERSION="${RAW_VERSION#v}" # Remove leading 'v' | |
| echo "VERSION_NO_V=$VERSION" >> $GITHUB_ENV # Export version without 'v' to GitHub env | |
| # bssh URLs | |
| MAC_URL="https://github.com/lablup/bssh/releases/download/v${VERSION}/bssh-macos-aarch64.zip" | |
| LINUX_ARM_URL="https://github.com/lablup/bssh/releases/download/v${VERSION}/bssh-linux-aarch64.tar.gz" | |
| LINUX_X86_URL="https://github.com/lablup/bssh/releases/download/v${VERSION}/bssh-linux-x86_64.tar.gz" | |
| # bssh-server URLs | |
| SERVER_MAC_URL="https://github.com/lablup/bssh/releases/download/v${VERSION}/bssh-server-macos-aarch64.zip" | |
| SERVER_LINUX_ARM_URL="https://github.com/lablup/bssh/releases/download/v${VERSION}/bssh-server-linux-aarch64.tar.gz" | |
| SERVER_LINUX_X86_URL="https://github.com/lablup/bssh/releases/download/v${VERSION}/bssh-server-linux-x86_64.tar.gz" | |
| # bssh-keygen URLs | |
| KEYGEN_MAC_URL="https://github.com/lablup/bssh/releases/download/v${VERSION}/bssh-keygen-macos-aarch64.zip" | |
| KEYGEN_LINUX_ARM_URL="https://github.com/lablup/bssh/releases/download/v${VERSION}/bssh-keygen-linux-aarch64.tar.gz" | |
| KEYGEN_LINUX_X86_URL="https://github.com/lablup/bssh/releases/download/v${VERSION}/bssh-keygen-linux-x86_64.tar.gz" | |
| mkdir -p tmp | |
| # Download bssh artifacts | |
| curl -Ls "$MAC_URL" -o tmp/mac.zip | |
| curl -Ls "$LINUX_ARM_URL" -o tmp/linux-arm.tar.gz | |
| curl -Ls "$LINUX_X86_URL" -o tmp/linux-x86.tar.gz | |
| # Download bssh-server artifacts | |
| curl -Ls "$SERVER_MAC_URL" -o tmp/server-mac.zip | |
| curl -Ls "$SERVER_LINUX_ARM_URL" -o tmp/server-linux-arm.tar.gz | |
| curl -Ls "$SERVER_LINUX_X86_URL" -o tmp/server-linux-x86.tar.gz | |
| # Download bssh-keygen artifacts | |
| curl -Ls "$KEYGEN_MAC_URL" -o tmp/keygen-mac.zip | |
| curl -Ls "$KEYGEN_LINUX_ARM_URL" -o tmp/keygen-linux-arm.tar.gz | |
| curl -Ls "$KEYGEN_LINUX_X86_URL" -o tmp/keygen-linux-x86.tar.gz | |
| # Export bssh URLs and checksums | |
| echo "mac_url=$MAC_URL" >> $GITHUB_ENV | |
| echo "linux_arm_url=$LINUX_ARM_URL" >> $GITHUB_ENV | |
| echo "linux_x86_url=$LINUX_X86_URL" >> $GITHUB_ENV | |
| echo "mac_sha=$(shasum -a 256 tmp/mac.zip | awk '{print $1}')" >> $GITHUB_ENV | |
| echo "linux_arm_sha=$(shasum -a 256 tmp/linux-arm.tar.gz | awk '{print $1}')" >> $GITHUB_ENV | |
| echo "linux_x86_sha=$(shasum -a 256 tmp/linux-x86.tar.gz | awk '{print $1}')" >> $GITHUB_ENV | |
| # Export bssh-server URLs and checksums | |
| echo "server_mac_url=$SERVER_MAC_URL" >> $GITHUB_ENV | |
| echo "server_linux_arm_url=$SERVER_LINUX_ARM_URL" >> $GITHUB_ENV | |
| echo "server_linux_x86_url=$SERVER_LINUX_X86_URL" >> $GITHUB_ENV | |
| echo "server_mac_sha=$(shasum -a 256 tmp/server-mac.zip | awk '{print $1}')" >> $GITHUB_ENV | |
| echo "server_linux_arm_sha=$(shasum -a 256 tmp/server-linux-arm.tar.gz | awk '{print $1}')" >> $GITHUB_ENV | |
| echo "server_linux_x86_sha=$(shasum -a 256 tmp/server-linux-x86.tar.gz | awk '{print $1}')" >> $GITHUB_ENV | |
| # Export bssh-keygen URLs and checksums | |
| echo "keygen_mac_url=$KEYGEN_MAC_URL" >> $GITHUB_ENV | |
| echo "keygen_linux_arm_url=$KEYGEN_LINUX_ARM_URL" >> $GITHUB_ENV | |
| echo "keygen_linux_x86_url=$KEYGEN_LINUX_X86_URL" >> $GITHUB_ENV | |
| echo "keygen_mac_sha=$(shasum -a 256 tmp/keygen-mac.zip | awk '{print $1}')" >> $GITHUB_ENV | |
| echo "keygen_linux_arm_sha=$(shasum -a 256 tmp/keygen-linux-arm.tar.gz | awk '{print $1}')" >> $GITHUB_ENV | |
| echo "keygen_linux_x86_sha=$(shasum -a 256 tmp/keygen-linux-x86.tar.gz | awk '{print $1}')" >> $GITHUB_ENV | |
| - name: Update bssh formula | |
| run: | | |
| cd homebrew-tap | |
| VERSION="${{ env.VERSION_NO_V }}" # Use version without 'v' | |
| gsed -i "s/^ version .*/ version \"${VERSION}\"/" Formula/bssh.rb | |
| gsed -i "s|https://github.com/.*/bssh-macos-aarch64.zip|${mac_url}|" Formula/bssh.rb | |
| gsed -i "/macos-aarch64.zip\"/!b;n;c\ sha256 \"${mac_sha}\"" Formula/bssh.rb | |
| gsed -i "s|https://github.com/.*/bssh-linux-aarch64.tar.gz|${linux_arm_url}|" Formula/bssh.rb | |
| gsed -i "/linux-aarch64.tar.gz\"/!b;n;c\ sha256 \"${linux_arm_sha}\"" Formula/bssh.rb | |
| gsed -i "s|https://github.com/.*/bssh-linux-x86_64.tar.gz|${linux_x86_url}|" Formula/bssh.rb | |
| gsed -i "/linux-x86_64.tar.gz\"/!b;n;c\ sha256 \"${linux_x86_sha}\"" Formula/bssh.rb | |
| - name: Update bssh-server formula | |
| run: | | |
| cd homebrew-tap | |
| VERSION="${{ env.VERSION_NO_V }}" | |
| # Check if bssh-server formula exists | |
| if [ -f "Formula/bssh-server.rb" ]; then | |
| gsed -i "s/^ version .*/ version \"${VERSION}\"/" Formula/bssh-server.rb | |
| gsed -i "s|https://github.com/.*/bssh-server-macos-aarch64.zip|${server_mac_url}|" Formula/bssh-server.rb | |
| gsed -i "/bssh-server-macos-aarch64.zip\"/!b;n;c\ sha256 \"${server_mac_sha}\"" Formula/bssh-server.rb | |
| gsed -i "s|https://github.com/.*/bssh-server-linux-aarch64.tar.gz|${server_linux_arm_url}|" Formula/bssh-server.rb | |
| gsed -i "/bssh-server-linux-aarch64.tar.gz\"/!b;n;c\ sha256 \"${server_linux_arm_sha}\"" Formula/bssh-server.rb | |
| gsed -i "s|https://github.com/.*/bssh-server-linux-x86_64.tar.gz|${server_linux_x86_url}|" Formula/bssh-server.rb | |
| gsed -i "/bssh-server-linux-x86_64.tar.gz\"/!b;n;c\ sha256 \"${server_linux_x86_sha}\"" Formula/bssh-server.rb | |
| else | |
| echo "Warning: Formula/bssh-server.rb not found, skipping server formula update" | |
| fi | |
| - name: Update bssh-keygen formula | |
| run: | | |
| cd homebrew-tap | |
| VERSION="${{ env.VERSION_NO_V }}" | |
| # Check if bssh-keygen formula exists | |
| if [ -f "Formula/bssh-keygen.rb" ]; then | |
| gsed -i "s/^ version .*/ version \"${VERSION}\"/" Formula/bssh-keygen.rb | |
| gsed -i "s|https://github.com/.*/bssh-keygen-macos-aarch64.zip|${keygen_mac_url}|" Formula/bssh-keygen.rb | |
| gsed -i "/bssh-keygen-macos-aarch64.zip\"/!b;n;c\ sha256 \"${keygen_mac_sha}\"" Formula/bssh-keygen.rb | |
| gsed -i "s|https://github.com/.*/bssh-keygen-linux-aarch64.tar.gz|${keygen_linux_arm_url}|" Formula/bssh-keygen.rb | |
| gsed -i "/bssh-keygen-linux-aarch64.tar.gz\"/!b;n;c\ sha256 \"${keygen_linux_arm_sha}\"" Formula/bssh-keygen.rb | |
| gsed -i "s|https://github.com/.*/bssh-keygen-linux-x86_64.tar.gz|${keygen_linux_x86_url}|" Formula/bssh-keygen.rb | |
| gsed -i "/bssh-keygen-linux-x86_64.tar.gz\"/!b;n;c\ sha256 \"${keygen_linux_x86_sha}\"" Formula/bssh-keygen.rb | |
| else | |
| echo "Warning: Formula/bssh-keygen.rb not found, skipping keygen formula update" | |
| fi | |
| - name: Commit and push changes to tap | |
| run: | | |
| cd homebrew-tap | |
| git add Formula/bssh.rb | |
| if [ -f "Formula/bssh-server.rb" ]; then | |
| git add Formula/bssh-server.rb | |
| fi | |
| if [ -f "Formula/bssh-keygen.rb" ]; then | |
| git add Formula/bssh-keygen.rb | |
| fi | |
| git commit -m "bump: bssh, bssh-server, and bssh-keygen to v${{ env.VERSION_NO_V }}" | |
| git push origin main |