forked from HolmesGPT/holmesgpt
-
Notifications
You must be signed in to change notification settings - Fork 0
255 lines (226 loc) · 9.7 KB
/
build-binaries-and-brew.yaml
File metadata and controls
255 lines (226 loc) · 9.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
name: Build and Release
on:
release:
types: [created]
jobs:
build:
strategy:
matrix:
include:
# Linux AMD64 - build on older Ubuntu for forward compatibility
# See https://pyinstaller.org/en/stable/usage.html?highlight=glibc#making-gnu-linux-apps-forward-compatible
- os: ubuntu-22.04
platform: linux
arch: amd64
# macOS ARM64 (Apple Silicon) - macos-14+ runs on M1/M2
- os: macos-14
platform: darwin
arch: arm64
# Windows AMD64
- os: windows-latest
platform: windows
arch: amd64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Install dependencies (Unix)
if: matrix.platform != 'windows'
run: |
python -m pip install --upgrade pip "setuptools<75" "pyinstaller>=6.11"
curl -sSL https://install.python-poetry.org | python3 - --version 1.4.0
poetry config virtualenvs.create false
poetry install --no-root
- name: Install dependencies (Windows)
if: matrix.platform == 'windows'
run: |
python -m pip install --upgrade pip "setuptools<75" "pyinstaller>=6.11"
curl -sSL https://install.python-poetry.org | python3 - --version 1.4.0
C:\Users\runneradmin\AppData\Roaming\Python\Scripts\poetry config virtualenvs.create false
C:\Users\runneradmin\AppData\Roaming\Python\Scripts\poetry install --no-root
- name: Install dependencies (Linux)
if: matrix.platform == 'linux'
run: |
sudo apt-get install -y binutils
- name: Update package version (Linux)
if: matrix.platform == 'linux'
run: sed -i 's/__version__ = .*/__version__ = "${{ github.ref_name }}"/g' holmes/__init__.py
# mac has BSD style sed command where you specify -i '' and not just -i
- name: Update package version (macOS)
if: matrix.platform == 'darwin'
run: sed -i '' 's/__version__ = .*/__version__ = "${{ github.ref_name }}"/g' holmes/__init__.py
# windows has no sed, so we use powershell
- name: Update package version (Windows)
if: matrix.platform == 'windows'
run: |
$filePath = 'holmes/__init__.py'
(Get-Content $filePath) -replace '__version__ = .+', '__version__ = "${{ github.ref_name }}"' | Set-Content $filePath
shell: pwsh
- name: Install unixODBC (macOS)
if: matrix.platform == 'darwin'
run: brew install unixodbc
# if you change something here, you must also change it in .github/workflows/build-and-test.yaml
- name: Build with PyInstaller
shell: bash
# regarding the tiktoken part of the command, see https://github.com/openai/tiktoken/issues/80
# regarding the litellm part of the command, see https://github.com/pyinstaller/pyinstaller/issues/8620#issuecomment-2186540504
run: |
pyinstaller holmes_cli.py \
--name holmes \
--add-data 'holmes/plugins/runbooks/*:holmes/plugins/runbooks' \
--add-data 'holmes/plugins/prompts/*:holmes/plugins/prompts' \
--add-data 'holmes/plugins/toolsets/*:holmes/plugins/toolsets' \
--add-data 'holmes/plugins/toolsets/coralogix*:holmes/plugins/toolsets/coralogix' \
--add-data 'holmes/plugins/toolsets/grafana*:holmes/plugins/toolsets/grafana' \
--add-data 'holmes/plugins/toolsets/internet*:holmes/plugins/toolsets/internet' \
--add-data 'holmes/plugins/toolsets/elasticsearch*:holmes/plugins/toolsets/elasticsearch' \
--add-data 'holmes/plugins/toolsets/prometheus*:holmes/plugins/toolsets/prometheus' \
--hidden-import=tiktoken_ext.openai_public \
--hidden-import=tiktoken_ext \
--hidden-import=backports \
--hiddenimport litellm.llms.tokenizers \
--hiddenimport litellm.litellm_core_utils.tokenizers \
--collect-data litellm
ls dist
- name: Zip the application (Unix and Mac)
if: matrix.platform != 'windows'
run: |
cd dist
zip -r holmes-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}.zip holmes
mv holmes-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}.zip ../
cd ..
- name: Zip the application (Windows)
if: matrix.platform == 'windows'
run: |
Set-Location -Path dist
Compress-Archive -Path holmes -DestinationPath holmes-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}.zip -Force
Move-Item -Path holmes-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}.zip -Destination ..\
Set-Location -Path ..
- name: Upload Release Asset
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./holmes-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}.zip
asset_name: holmes-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}.zip
asset_content_type: application/octet-stream
- name: Upload build as artifact
uses: actions/upload-artifact@v4
with:
name: holmes-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}
path: ./holmes-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}.zip
check-latest:
needs: build
runs-on: ubuntu-22.04
outputs:
IS_LATEST: ${{ steps.check-latest.outputs.release == github.ref_name }}
steps:
- id: check-latest
uses: pozetroninc/github-action-get-latest-release@v0.7.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
excludes: prerelease, draft
# Define macOS ARM64 hash job (Apple Silicon)
mac-arm64-hash:
needs: check-latest
runs-on: ubuntu-latest
if: needs.check-latest.outputs.IS_LATEST
outputs:
MAC_ARM64_BUILD_HASH: ${{ steps.calc-hash.outputs.MAC_ARM64_BUILD_HASH }}
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Download macOS ARM64 artifact
uses: actions/download-artifact@v4
with:
name: holmes-darwin-arm64-${{ github.ref_name }}
- name: Calculate hash
id: calc-hash
run: echo "MAC_ARM64_BUILD_HASH=$(sha256sum holmes-darwin-arm64-${{ github.ref_name }}.zip | awk '{print $1}')" >> $GITHUB_OUTPUT
# Define Linux hash job
linux-hash:
needs: check-latest
runs-on: ubuntu-latest
if: needs.check-latest.outputs.IS_LATEST
outputs:
LINUX_BUILD_HASH: ${{ steps.calc-hash.outputs.LINUX_BUILD_HASH }}
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Download Linux artifact
uses: actions/download-artifact@v4
with:
name: holmes-linux-amd64-${{ github.ref_name }}
- name: Calculate hash
id: calc-hash
run: echo "LINUX_BUILD_HASH=$(sha256sum holmes-linux-amd64-${{ github.ref_name }}.zip | awk '{print $1}')" >> $GITHUB_OUTPUT
# Update Homebrew formula with new binary URLs and hashes
update-formula:
needs: [mac-arm64-hash, linux-hash]
runs-on: ubuntu-latest
if: ${{ !github.event.release.prerelease }}
steps:
- name: Checkout homebrew-holmesgpt repository
uses: actions/checkout@v2
with:
repository: robusta-dev/homebrew-holmesgpt
token: ${{ secrets.MULTIREPO_GITHUB_TOKEN }}
- name: Update holmesgpt.rb formula
env:
MAC_ARM64_BUILD_HASH: ${{ needs.mac-arm64-hash.outputs.MAC_ARM64_BUILD_HASH }}
LINUX_BUILD_HASH: ${{ needs.linux-hash.outputs.LINUX_BUILD_HASH }}
TAG_NAME: ${{ github.ref_name }}
run: |
# Update URLs and hashes using Python for reliability
python3 << 'PYTHON_SCRIPT'
import os
import re
mac_arm64_hash = os.environ['MAC_ARM64_BUILD_HASH']
linux_hash = os.environ['LINUX_BUILD_HASH']
tag = os.environ['TAG_NAME']
with open('./Formula/holmesgpt.rb', 'r') as f:
content = f.read()
# Update macOS URL (handles both old and new naming)
content = re.sub(
r'(if OS\.mac\?\s+)url "[^"]+"',
rf'\1url "https://github.com/HolmesGPT/holmesgpt/releases/download/{tag}/holmes-darwin-arm64-{tag}.zip"',
content,
flags=re.DOTALL
)
# Update macOS sha256
content = re.sub(
r'(if OS\.mac\?\s+url "[^"]+"\s+)sha256 "[^"]+"',
rf'\1sha256 "{mac_arm64_hash}"',
content,
flags=re.DOTALL
)
# Update Linux URL (handles both old and new naming)
content = re.sub(
r'(elsif OS\.linux\?\s+)url "[^"]+"',
rf'\1url "https://github.com/HolmesGPT/holmesgpt/releases/download/{tag}/holmes-linux-amd64-{tag}.zip"',
content,
flags=re.DOTALL
)
# Update Linux sha256
content = re.sub(
r'(elsif OS\.linux\?\s+url "[^"]+"\s+)sha256 "[^"]+"',
rf'\1sha256 "{linux_hash}"',
content,
flags=re.DOTALL
)
with open('./Formula/holmesgpt.rb', 'w') as f:
f.write(content)
print("Updated formula:")
print(content)
PYTHON_SCRIPT
- name: Commit and push changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -am "Update formula for release ${{ github.ref_name }}"
git push