|
76 | 76 |
|
77 | 77 | - name: Upload release assets |
78 | 78 | run: gh release upload "${{ github.ref_name }}" createos-* --clobber |
| 79 | + |
| 80 | + update-homebrew: |
| 81 | + needs: release |
| 82 | + runs-on: ubuntu-latest |
| 83 | + steps: |
| 84 | + - name: Download SHA256 files |
| 85 | + env: |
| 86 | + GH_TOKEN: ${{ github.token }} |
| 87 | + run: | |
| 88 | + VERSION="${{ github.ref_name }}" |
| 89 | + VERSION_NUM="${VERSION#v}" |
| 90 | + BASE="https://github.com/NodeOps-app/createos-cli/releases/download/${VERSION}" |
| 91 | +
|
| 92 | + for target in darwin-arm64 darwin-amd64 linux-arm64 linux-amd64; do |
| 93 | + curl -sL "${BASE}/createos-${target}.sha256" > "sha256-${target}.txt" |
| 94 | + done |
| 95 | +
|
| 96 | + SHA_DARWIN_ARM64=$(cat sha256-darwin-arm64.txt) |
| 97 | + SHA_DARWIN_AMD64=$(cat sha256-darwin-amd64.txt) |
| 98 | + SHA_LINUX_ARM64=$(cat sha256-linux-arm64.txt) |
| 99 | + SHA_LINUX_AMD64=$(cat sha256-linux-amd64.txt) |
| 100 | +
|
| 101 | + cat > createos.rb << FORMULA |
| 102 | + class Createos < Formula |
| 103 | + desc "CreateOS CLI - Deploy APIs, manage infrastructure, and monetize Skills" |
| 104 | + homepage "https://github.com/NodeOps-app/createos-cli" |
| 105 | + version "${VERSION_NUM}" |
| 106 | + license "MIT" |
| 107 | +
|
| 108 | + on_macos do |
| 109 | + on_arm do |
| 110 | + url "https://github.com/NodeOps-app/createos-cli/releases/download/v#{version}/createos-darwin-arm64" |
| 111 | + sha256 "${SHA_DARWIN_ARM64}" |
| 112 | + end |
| 113 | +
|
| 114 | + on_intel do |
| 115 | + url "https://github.com/NodeOps-app/createos-cli/releases/download/v#{version}/createos-darwin-amd64" |
| 116 | + sha256 "${SHA_DARWIN_AMD64}" |
| 117 | + end |
| 118 | + end |
| 119 | +
|
| 120 | + on_linux do |
| 121 | + on_arm do |
| 122 | + url "https://github.com/NodeOps-app/createos-cli/releases/download/v#{version}/createos-linux-arm64" |
| 123 | + sha256 "${SHA_LINUX_ARM64}" |
| 124 | + end |
| 125 | +
|
| 126 | + on_intel do |
| 127 | + url "https://github.com/NodeOps-app/createos-cli/releases/download/v#{version}/createos-linux-amd64" |
| 128 | + sha256 "${SHA_LINUX_AMD64}" |
| 129 | + end |
| 130 | + end |
| 131 | +
|
| 132 | + def install |
| 133 | + binary = Dir["createos-*"].first || "createos" |
| 134 | + bin.install binary => "createos" |
| 135 | + end |
| 136 | +
|
| 137 | + test do |
| 138 | + assert_match "createos", shell_output("#{bin}/createos version 2>&1") |
| 139 | + end |
| 140 | + end |
| 141 | + FORMULA |
| 142 | +
|
| 143 | + # Remove leading whitespace from heredoc |
| 144 | + sed -i 's/^ //' createos.rb |
| 145 | +
|
| 146 | + - name: Push to Homebrew tap |
| 147 | + env: |
| 148 | + GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} |
| 149 | + run: | |
| 150 | + VERSION="${{ github.ref_name }}" |
| 151 | + git clone https://x-access-token:${GH_TOKEN}@github.com/NodeOps-app/homebrew-createos.git tap |
| 152 | + cp createos.rb tap/Formula/createos.rb |
| 153 | + cd tap |
| 154 | + git config user.name "github-actions[bot]" |
| 155 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 156 | + git add Formula/createos.rb |
| 157 | + git diff --cached --quiet && echo "No changes" && exit 0 |
| 158 | + git commit -m "Update createos to ${VERSION}" |
| 159 | + git push |
0 commit comments