Homebrew CLI Release #6
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: Homebrew Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Release tag (e.g. v0.3.36)" | |
| required: true | |
| permissions: | |
| contents: read | |
| env: | |
| REPO: smbcloudXYZ/smbcloud-cli | |
| jobs: | |
| update-homebrew-tap: | |
| name: Update Homebrew tap | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Resolve tag and version | |
| id: release | |
| shell: bash | |
| run: | | |
| TAG="${{ github.event.inputs.tag }}" | |
| VERSION="${TAG#v}" | |
| echo "tag=${TAG}" >> "$GITHUB_OUTPUT" | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Read SHA256 checksums from release | |
| id: sha | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| shell: bash | |
| run: | | |
| mkdir -p artifacts | |
| gh release download "${{ steps.release.outputs.tag }}" \ | |
| --repo "${{ env.REPO }}" \ | |
| --pattern "smb-macos-*.tar.gz.sha256" \ | |
| --dir artifacts/ | |
| ARM64_SHA=$(cat artifacts/smb-macos-arm64.tar.gz.sha256) | |
| AMD64_SHA=$(cat artifacts/smb-macos-amd64.tar.gz.sha256) | |
| echo "arm64=${ARM64_SHA}" >> "$GITHUB_OUTPUT" | |
| echo "amd64=${AMD64_SHA}" >> "$GITHUB_OUTPUT" | |
| echo "ARM64 SHA256: ${ARM64_SHA}" | |
| echo "AMD64 SHA256: ${AMD64_SHA}" | |
| - name: Checkout Homebrew tap | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: smbcloudXYZ/homebrew-tap | |
| token: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| path: homebrew-tap | |
| - name: Generate formula | |
| shell: bash | |
| run: | | |
| VERSION="${{ steps.release.outputs.version }}" | |
| TAG="${{ steps.release.outputs.tag }}" | |
| ARM64_SHA="${{ steps.sha.outputs.arm64 }}" | |
| AMD64_SHA="${{ steps.sha.outputs.amd64 }}" | |
| mkdir -p homebrew-tap/Formula | |
| cat > homebrew-tap/Formula/cli.rb <<FORMULA | |
| # frozen_string_literal: true | |
| # Homebrew formula for the smbCloud CLI (\`smb\` binary). | |
| class Cli < Formula | |
| desc 'smbCloud command line interface' | |
| homepage 'https://github.com/${REPO}' | |
| version '${VERSION}' | |
| license 'Apache-2.0' | |
| on_macos do | |
| on_arm do | |
| url 'https://github.com/${REPO}/releases/download/${TAG}/smb-macos-arm64.tar.gz' | |
| sha256 '${ARM64_SHA}' | |
| end | |
| on_intel do | |
| url 'https://github.com/${REPO}/releases/download/${TAG}/smb-macos-amd64.tar.gz' | |
| sha256 '${AMD64_SHA}' | |
| end | |
| end | |
| def install | |
| bin.install 'smb' | |
| end | |
| test do | |
| system "#{bin}/smb", '--help' | |
| end | |
| end | |
| FORMULA | |
| echo "Generated formula:" | |
| cat homebrew-tap/Formula/cli.rb | |
| - name: Commit and push | |
| shell: bash | |
| run: | | |
| VERSION="${{ steps.release.outputs.version }}" | |
| cd homebrew-tap | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add Formula/cli.rb | |
| git diff --cached --quiet && echo "No changes to commit" && exit 0 | |
| git commit -m "Update smb to ${VERSION}" | |
| git push |