|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + build-and-release: |
| 10 | + name: Build and Release |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + - os: ubuntu-latest |
| 16 | + target: x86_64-unknown-linux-gnu |
| 17 | + archive: tar.gz |
| 18 | + - os: macos-latest |
| 19 | + target: x86_64-apple-darwin |
| 20 | + archive: tar.gz |
| 21 | + - os: macos-latest |
| 22 | + target: aarch64-apple-darwin |
| 23 | + archive: tar.gz |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout code |
| 27 | + uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Setup Rust |
| 30 | + uses: dtolnay/rust-toolchain@stable |
| 31 | + with: |
| 32 | + targets: ${{ matrix.target }} |
| 33 | + |
| 34 | + - name: Build release |
| 35 | + run: cargo build --release --target ${{ matrix.target }} |
| 36 | + |
| 37 | + - name: Package artifacts |
| 38 | + run: | |
| 39 | + mkdir -p package |
| 40 | + cp target/${{ matrix.target }}/release/CacheCLI package/aeron-cache-cli |
| 41 | + cp README.md package/ || true |
| 42 | + cd package |
| 43 | + tar -czf ../aeron-cache-cli-${{ matrix.target }}.tar.gz * |
| 44 | +
|
| 45 | + - name: Make Release |
| 46 | + uses: softprops/action-gh-release@v2 |
| 47 | + with: |
| 48 | + files: aeron-cache-cli-${{ matrix.target }}.tar.gz |
| 49 | + env: |
| 50 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + |
| 52 | + update-homebrew-tap: |
| 53 | + name: Update Homebrew Tap |
| 54 | + needs: build-and-release |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - name: Update Formula |
| 58 | + env: |
| 59 | + # Create an access token (PAT) with repo scope and set it as TAP_GITHUB_TOKEN in aeron-cache-cli repo secrets |
| 60 | + TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }} |
| 61 | + run: | |
| 62 | + VERSION=${GITHUB_REF#refs/tags/v} |
| 63 | + MAC_INTEL_URL="https://github.com/${{ github.repository }}/releases/download/v${VERSION}/aeron-cache-cli-x86_64-apple-darwin.tar.gz" |
| 64 | + MAC_ARM_URL="https://github.com/${{ github.repository }}/releases/download/v${VERSION}/aeron-cache-cli-aarch64-apple-darwin.tar.gz" |
| 65 | + LINUX_URL="https://github.com/${{ github.repository }}/releases/download/v${VERSION}/aeron-cache-cli-x86_64-unknown-linux-gnu.tar.gz" |
| 66 | +
|
| 67 | + # Function to get sha256 |
| 68 | + get_sha() { |
| 69 | + curl -sL "$1" | shasum -a 256 | awk '{print $1}' |
| 70 | + } |
| 71 | +
|
| 72 | + MAC_INTEL_SHA=$(get_sha $MAC_INTEL_URL) |
| 73 | + MAC_ARM_SHA=$(get_sha $MAC_ARM_URL) |
| 74 | + LINUX_SHA=$(get_sha $LINUX_URL) |
| 75 | +
|
| 76 | + cat << EOF > aeron-cache-cli.rb |
| 77 | + class AeronCacheCli < Formula |
| 78 | + desc "Aeron Cache Command Line Interface" |
| 79 | + homepage "https://github.com/${{ github.repository }}" |
| 80 | + version "${VERSION}" |
| 81 | +
|
| 82 | + on_macos do |
| 83 | + if Hardware::CPU.intel? |
| 84 | + url "${MAC_INTEL_URL}" |
| 85 | + sha256 "${MAC_INTEL_SHA}" |
| 86 | + elsif Hardware::CPU.arm? |
| 87 | + url "${MAC_ARM_URL}" |
| 88 | + sha256 "${MAC_ARM_SHA}" |
| 89 | + end |
| 90 | + end |
| 91 | +
|
| 92 | + on_linux do |
| 93 | + if Hardware::CPU.intel? |
| 94 | + url "${LINUX_URL}" |
| 95 | + sha256 "${LINUX_SHA}" |
| 96 | + end |
| 97 | + end |
| 98 | +
|
| 99 | + def install |
| 100 | + bin.install "aeron-cache-cli" => "CacheCLI" |
| 101 | + end |
| 102 | +
|
| 103 | + test do |
| 104 | + system "#{bin}/CacheCLI", "--version" |
| 105 | + end |
| 106 | + end |
| 107 | + EOF |
| 108 | +
|
| 109 | + # Commit to tap repo |
| 110 | + git clone https://x-access-token:${TAP_GITHUB_TOKEN}@github.com/${{ github.repository_owner }}/homebrew-aeron-cache-cli.git |
| 111 | + cd homebrew-aeron-cache-cli |
| 112 | + mkdir -p Formula |
| 113 | + cp ../aeron-cache-cli.rb Formula/aeron-cache-cli.rb |
| 114 | + git config user.name "github-actions[bot]" |
| 115 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 116 | + git add Formula/aeron-cache-cli.rb |
| 117 | + git commit -m "Update aeron-cache-cli to ${VERSION}" |
| 118 | + git push |
0 commit comments