Skip to content

Commit 99f3908

Browse files
authored
Automatically Generate Releases for Mac, Linux, Windows (#81)
* trying to build for arm * cross compiling? * only mac * gh actions * fix * fixing dash * ensure that its executable * adding back windows * unindent * typo * oops * runs on * more release stuff * more release stuff * fix workflow * adding back linux builds * conditional stuff
1 parent 2cbe796 commit 99f3908

File tree

2 files changed

+94
-235
lines changed

2 files changed

+94
-235
lines changed

.github/workflows/build.yml

Lines changed: 87 additions & 235 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,18 @@ jobs:
3636
run: |
3737
make
3838
39+
- name: Zip executables
40+
run: zip alpaca-linux.zip chat
41+
3942
- name: Archive production artifacts
4043
uses: actions/upload-artifact@v3
4144
with:
42-
name: ubuntu
45+
name: linux
4346
path: |
44-
chat
47+
alpaca-linux.zip
4548
4649
47-
macOS-latest:
50+
macos-latest:
4851
runs-on: macOS-latest
4952

5053
steps:
@@ -60,39 +63,45 @@ jobs:
6063
- name: Build
6164
id: make_build
6265
run: |
63-
make
66+
make chat_mac
67+
68+
- name: Codesign executable
69+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
70+
env:
71+
MACOS_CERTIFICATE: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
72+
MACOS_CERTIFICATE_PWD: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
73+
KEYCHAIN_PWD: ${{ secrets.KEYCHAIN_PASSWORD }}
74+
MACOS_CERT_ID: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_ID }}
75+
76+
run: |
77+
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
78+
security create-keychain -p $KEYCHAIN_PWD build.keychain
79+
security default-keychain -s build.keychain
80+
security unlock-keychain -p $KEYCHAIN_PWD build.keychain
81+
security import certificate.p12 -k build.keychain -P $MACOS_CERTIFICATE_PWD -T /usr/bin/codesign
82+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $KEYCHAIN_PWD build.keychain
83+
/usr/bin/codesign --options runtime --force -s $MACOS_CERT_ID ./chat_mac -v
84+
85+
- name: Zip executables
86+
run: zip alpaca-mac.zip chat_mac
87+
88+
- name: Notarize executables
89+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
90+
env:
91+
PROD_MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.AC_USERNAME }}
92+
PROD_MACOS_NOTARIZATION_PWD: ${{ secrets.AC_PASSWORD }}
93+
PROD_MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
94+
run: |
95+
xcrun notarytool store-credentials "notarytool-profile" --apple-id "$PROD_MACOS_NOTARIZATION_APPLE_ID" --team-id "$PROD_MACOS_NOTARIZATION_TEAM_ID" --password "$PROD_MACOS_NOTARIZATION_PWD"
96+
xcrun notarytool submit "alpaca-mac.zip" --keychain-profile "notarytool-profile" --wait
6497
6598
- name: Archive production artifacts
6699
uses: actions/upload-artifact@v3
67100
with:
68101
name: macos
69102
path: |
70-
chat
71-
72-
# macos-arm64:
73-
# runs-on: macos-arm64
74-
75-
# steps:
76-
# - name: Clone
77-
# id: checkout
78-
# uses: actions/checkout@v1
79-
80-
# - name: Dependencies
81-
# id: depends
82-
# run: |
83-
# brew update
84-
85-
# - name: Build
86-
# id: make_build
87-
# run: |
88-
# make
103+
alpaca-mac.zip
89104
90-
# - name: Archive production artifacts
91-
# uses: actions/upload-artifact@v3
92-
# with:
93-
# name: macos
94-
# path: |
95-
# chat
96105
97106
windows-latest:
98107
runs-on: windows-latest
@@ -110,227 +119,70 @@ jobs:
110119
cmake ..
111120
cmake --build . --config Release
112121
113-
- name: Set commit hash variables
114-
id: commit
115-
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
116-
uses: pr-mpt/actions-commit-hash@v2
117-
118122
- name: Pack artifacts
119123
id: pack_artifacts
120-
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
121124
run: |
122-
7z a alpaca-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-x64.zip .\build\Release\*
125+
7z a alpaca-win.zip .\build\Release\*
126+
127+
- name: Archive production artifacts
128+
uses: actions/upload-artifact@v3
129+
with:
130+
name: windows
131+
path: |
132+
alpaca-win.zip
133+
134+
135+
release:
136+
runs-on: ubuntu-latest
137+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
138+
needs:
139+
- windows-latest
140+
- macos-latest
141+
- ubuntu-latest
142+
143+
steps:
144+
- name: Download all workflow run artifacts
145+
uses: actions/download-artifact@v3
146+
147+
- name: Set commit hash variables
148+
id: commit
149+
uses: pr-mpt/actions-commit-hash@v2
123150

124151
- name: Create release
125152
id: create_release
126-
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
127153
uses: zendesk/action-create-release@v1
128154
env:
129155
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130156
with:
131-
tag_name: ${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}
157+
tag_name: ${{ steps.commit.outputs.short }}
132158

133-
- name: Upload release
134-
id: upload_release
135-
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
159+
- name: Upload windows release
136160
uses: actions/upload-release-asset@v1
137161
env:
138162
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
139163
with:
140164
upload_url: ${{ steps.create_release.outputs.upload_url }}
141-
asset_path: .\alpaca-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-x64.zip
142-
asset_name: alpaca-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-x64.zip
165+
asset_path: windows/alpaca-win.zip
166+
asset_name: alpaca-win.zip
143167
asset_content_type: application/octet-stream
144168

145-
# ubuntu-latest-gcc:
146-
# runs-on: ubuntu-latest
147-
#
148-
# strategy:
149-
# matrix:
150-
# build: [Debug, Release]
151-
#
152-
# steps:
153-
# - name: Clone
154-
# uses: actions/checkout@v1
155-
#
156-
# - name: Dependencies
157-
# run: |
158-
# sudo apt-get update
159-
# sudo apt-get install build-essential
160-
# sudo apt-get install cmake
161-
#
162-
# - name: Configure
163-
# run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
164-
#
165-
# - name: Build
166-
# run: |
167-
# make
168-
#
169-
# ubuntu-latest-clang:
170-
# runs-on: ubuntu-latest
171-
#
172-
# strategy:
173-
# matrix:
174-
# build: [Debug, Release]
175-
#
176-
# steps:
177-
# - name: Clone
178-
# uses: actions/checkout@v1
179-
#
180-
# - name: Dependencies
181-
# run: |
182-
# sudo apt-get update
183-
# sudo apt-get install build-essential
184-
# sudo apt-get install cmake
185-
#
186-
# - name: Configure
187-
# run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
188-
#
189-
# - name: Build
190-
# run: |
191-
# make
192-
#
193-
# ubuntu-latest-gcc-sanitized:
194-
# runs-on: ubuntu-latest
195-
#
196-
# strategy:
197-
# matrix:
198-
# sanitizer: [ADDRESS, THREAD, UNDEFINED]
199-
#
200-
# steps:
201-
# - name: Clone
202-
# uses: actions/checkout@v1
203-
#
204-
# - name: Dependencies
205-
# run: |
206-
# sudo apt-get update
207-
# sudo apt-get install build-essential
208-
# sudo apt-get install cmake
209-
#
210-
# - name: Configure
211-
# run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
212-
#
213-
# - name: Build
214-
# run: |
215-
# make
216-
#
217-
# windows:
218-
# runs-on: windows-latest
219-
#
220-
# strategy:
221-
# matrix:
222-
# build: [Release]
223-
# arch: [Win32, x64]
224-
# include:
225-
# - arch: Win32
226-
# s2arc: x86
227-
# - arch: x64
228-
# s2arc: x64
229-
#
230-
# steps:
231-
# - name: Clone
232-
# uses: actions/checkout@v1
233-
#
234-
# - name: Add msbuild to PATH
235-
# uses: microsoft/setup-msbuild@v1
236-
#
237-
# - name: Configure
238-
# run: >
239-
# cmake -S . -B ./build -A ${{ matrix.arch }}
240-
# -DCMAKE_BUILD_TYPE=${{ matrix.build }}
241-
#
242-
# - name: Build
243-
# run: |
244-
# cd ./build
245-
# msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
246-
#
247-
# - name: Upload binaries
248-
# uses: actions/upload-artifact@v1
249-
# with:
250-
# name: llama-bin-${{ matrix.arch }}
251-
# path: build/bin/${{ matrix.build }}
252-
#
253-
# windows-blas:
254-
# runs-on: windows-latest
255-
#
256-
# strategy:
257-
# matrix:
258-
# build: [Release]
259-
# arch: [Win32, x64]
260-
# blas: [ON]
261-
# include:
262-
# - arch: Win32
263-
# obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
264-
# s2arc: x86
265-
# - arch: x64
266-
# obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
267-
# s2arc: x64
268-
#
269-
# steps:
270-
# - name: Clone
271-
# uses: actions/checkout@v1
272-
#
273-
# - name: Add msbuild to PATH
274-
# uses: microsoft/setup-msbuild@v1
275-
#
276-
# - name: Fetch OpenBLAS
277-
# if: matrix.blas == 'ON'
278-
# run: |
279-
# C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
280-
# 7z x blas.zip -oblas -y
281-
# copy blas/include/cblas.h .
282-
# copy blas/include/openblas_config.h .
283-
# echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
284-
#
285-
# - name: Configure
286-
# run: >
287-
# cmake -S . -B ./build -A ${{ matrix.arch }}
288-
# -DCMAKE_BUILD_TYPE=${{ matrix.build }}
289-
# -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
290-
# -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
291-
#
292-
# - name: Build
293-
# run: |
294-
# cd ./build
295-
# msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
296-
#
297-
# - name: Copy libopenblas.dll
298-
# if: matrix.blas == 'ON'
299-
# run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
300-
#
301-
# - name: Upload binaries
302-
# if: matrix.blas == 'ON'
303-
# uses: actions/upload-artifact@v1
304-
# with:
305-
# name: llama-blas-bin-${{ matrix.arch }}
306-
# path: build/bin/${{ matrix.build }}
307-
#
308-
# emscripten:
309-
# runs-on: ubuntu-latest
310-
#
311-
# strategy:
312-
# matrix:
313-
# build: [Release]
314-
#
315-
# steps:
316-
# - name: Clone
317-
# uses: actions/checkout@v1
318-
#
319-
# - name: Dependencies
320-
# run: |
321-
# wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
322-
# tar -xvf master.tar.gz
323-
# emsdk-master/emsdk update
324-
# emsdk-master/emsdk install latest
325-
# emsdk-master/emsdk activate latest
326-
#
327-
# - name: Configure
328-
# run: echo "tmp"
329-
#
330-
# - name: Build
331-
# run: |
332-
# pushd emsdk-master
333-
# source ./emsdk_env.sh
334-
# popd
335-
# emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
336-
# make
169+
- name: Upload mac release
170+
uses: actions/upload-release-asset@v1
171+
env:
172+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
173+
with:
174+
upload_url: ${{ steps.create_release.outputs.upload_url }}
175+
asset_path: macos/alpaca-mac.zip
176+
asset_name: alpaca-mac.zip
177+
asset_content_type: application/octet-stream
178+
179+
- name: Upload linux release
180+
181+
uses: actions/upload-release-asset@v1
182+
env:
183+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
184+
with:
185+
upload_url: ${{ steps.create_release.outputs.upload_url }}
186+
asset_path: linux/alpaca-linux.zip
187+
asset_name: alpaca-linux.zip
188+
asset_content_type: application/octet-stream

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ clean:
194194
chat: chat.cpp ggml.o utils.o
195195
$(CXX) $(CXXFLAGS) chat.cpp ggml.o utils.o -o chat $(LDFLAGS)
196196

197+
chat_mac: chat.cpp ggml.c utils.cpp
198+
$(CC) $(CFLAGS) -c ggml.c -o ggml_x86.o -target x86_64-apple-macos
199+
$(CC) $(CFLAGS) -c ggml.c -o ggml_arm.o -target arm64-apple-macos
200+
201+
$(CXX) $(CXXFLAGS) chat.cpp ggml_x86.o utils.cpp -o chat_x86 $(LDFLAGS) -target x86_64-apple-macos
202+
$(CXX) $(CXXFLAGS) chat.cpp ggml_arm.o utils.cpp -o chat_arm $(LDFLAGS) -target arm64-apple-macos
203+
lipo -create -output chat_mac chat_x86 chat_arm
197204

198205
quantize: quantize.cpp ggml.o utils.o
199206
$(CXX) $(CXXFLAGS) quantize.cpp ggml.o utils.o -o quantize $(LDFLAGS)

0 commit comments

Comments
 (0)