-
Notifications
You must be signed in to change notification settings - Fork 56
229 lines (196 loc) · 9.14 KB
/
build-and-deploy.yml
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
# Name of the GitHub Actions workflow
name: Build and Deploy
# Trigger the workflow on push to the specified branch
on:
push:
branches:
- main
# Define the jobs to be run
jobs:
# Define the build job
build:
# Specify the runner environment
runs-on: macos-latest
# Define the steps to be performed in the build job
steps:
# Add the target architecture for building MacOS Silicon apps
- name: Add target architecture
run: rustup target add aarch64-apple-darwin
# Check out the repository code to the runner
- name: Checkout code
uses: actions/checkout@v4
# Set up the required Node.js version
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20.x"
# Set up the Rust toolchain
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
# Check if there is a cache of the pnpm modules and restore it
- name: Cache pnpm modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
# Install pnpm (a fast, disk space efficient package manager)
- name: Install pnpm
run: npm install -g pnpm
# Install project dependencies
- name: Install dependencies
run: pnpm i
# Build the project for MacOS Silicon
- name: Build for MacOS Silicon
run: pnpm build:app:silicon
# Archive the MacOS Silicon build artifacts
- name: Archive MacOS Silicon artifacts
uses: actions/upload-artifact@v3
with:
name: macos-silicon
# The current path is very specific and might need adjustments with any changes in the file name or structure. A more generalized path (e.g., src-tauri/target/release/bundle/dmg/*.dmg) would be preferable as it's more flexible and resilient to such changes.
path: src-tauri/target/aarch64-apple-darwin/release/bundle/dmg/*.dmg
if-no-files-found: error # or 'warn' or 'ignore'
# Build the project for MacOS Intel
- name: Build for MacOS Intel
run: pnpm build:app:intell
# Archive the MacOS Intel build artifacts
- name: Archive MacOS Intel artifacts
uses: actions/upload-artifact@v3
with:
name: macos-intel
# The current path is very specific and might need adjustments with any changes in the file name or structure. A more generalized path (e.g., src-tauri/target/release/bundle/dmg/*.dmg) would be preferable as it's more flexible and resilient to such changes.
path: src-tauri/target/x86_64-apple-darwin/release/bundle/dmg/*.dmg
if-no-files-found: error # or 'warn' or 'ignore'
# Build the project for MacOS Universal (both Silicon and Intel)
- name: Build for MacOS Universal
run: pnpm build:app:universal
# Archive the MacOS Universal build artifacts
- name: Archive MacOS Universal artifacts
uses: actions/upload-artifact@v3
with:
name: macos-universal
# The current path is very specific and might need adjustments with any changes in the file name or structure. A more generalized path (e.g., src-tauri/target/release/bundle/dmg/*.dmg) would be preferable as it's more flexible and resilient to such changes.
path: src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg
if-no-files-found: error # or 'warn' or 'ignore'
# Placeholder steps for future implementation for Windows
# Build the project for Windows OS
# - name: Build for Windows
# run: pnpm build:app:windows
# - name: Archive Windows artifacts
# uses: actions/upload-artifact@v3
# with:
# name: windows
# path: src-tauri/target/release/bundle/windows/* # Adjust this path if necessary
# Placeholder steps for future implementation for Linux
# Build the project for Linux OS
# - name: Build for Linux
# run: pnpm build:app:linux
# - name: Archive Linux artifacts
# uses: actions/upload-artifact@v3
# with:
# name: linux
# path: src-tauri/target/release/bundle/linux/* # Adjust this path if necessary
# # List the contents of the build directory
# # For Debugging purposes
# - name: List files in the build directory
# run: |
# echo "Listing contents of macos-silicon directory"
# ls -la src-tauri/target/aarch64-apple-darwin/release/bundle/dmg/
# echo "Listing contents of macos-intel directory"
# ls -la src-tauri/target/x86_64-apple-darwin/release/bundle/dmg/
# echo "Listing contents of macos-universal directory"
# ls -la src-tauri/target/universal-apple-darwin/release/bundle/dmg/
# Define the release job which depends on the build job
release:
# Specify that this job needs the build job to complete successfully
needs: build
# Specify the runner environment
runs-on: ubuntu-latest
# Define the steps to be performed in the release job
steps:
# Download the build artifacts from the build job
- name: Download artifacts
uses: actions/download-artifact@v3
# # List the contents of the directories
# # For debugging purposes
# - name: List contents of directories
# run: |
# echo "Listing contents of macos-silicon directory"
# ls -la /home/runner/work/Ollama-Gui/Ollama-Gui/macos-silicon
# echo "Listing contents of macos-intel directory"
# ls -la /home/runner/work/Ollama-Gui/Ollama-Gui/macos-intel
# echo "Listing contents of macos-universal directory"
# ls -la /home/runner/work/Ollama-Gui/Ollama-Gui/macos-universal
# Needs to be updated to use an adequate generated tag
# Generate the tag
- name: Generate tag
id: generate_tag
run: echo "::set-output name=tag::release-$(date +'%Y%m%d%H%M%S')"
# Create a new GitHub release with the generated tag
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.generate_tag.outputs.tag }}
release_name: Release ${{ steps.generate_tag.outputs.tag }}
draft: false
prerelease: false
# Get the file name and assign it to an object
- name: Get Silicon file name
id: get_filename_silicon
run: echo "::set-output name=filename::$(ls /home/runner/work/Ollama-Gui/Ollama-Gui/macos-silicon/*.dmg)"
# Print the file name
- name: Echo the Silicon file name
run: echo "The file name is ${{ steps.get_filename_silicon.outputs.filename }}"
# Upload the MacOS Silicon build artifact to the GitHub release
- name: Upload Release Asset (MacOS Silicon)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.get_filename_silicon.outputs.filename }} # adjusted path
asset_name: Ollama-Gui-MacOS-Silicon.dmg
asset_content_type: application/octet-stream
# Get the file name and assign it to an object
- name: Get Intel file name
id: get_filename_intel
run: echo "::set-output name=filename::$(ls /home/runner/work/Ollama-Gui/Ollama-Gui/macos-intel/*.dmg)"
# Print the file name
- name: Echo the Intel file name
run: echo "The Intel file name is ${{ steps.get_filename_intel.outputs.filename }}"
# Upload the MacOS Intel build artifact to the GitHub release
- name: Upload Release Asset (MacOS Intel)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.get_filename_intel.outputs.filename }} # adjusted path
asset_name: Ollama-Gui-MacOS-Intel.dmg
asset_content_type: application/octet-stream
# Get the file name and assign it to an object
- name: Get Universal file name
id: get_filename_universal
run: echo "::set-output name=filename::$(ls /home/runner/work/Ollama-Gui/Ollama-Gui/macos-universal/*.dmg)"
# Print the file name
- name: Echo the Universal file name
run: echo "The Universal file name is ${{ steps.get_filename_universal.outputs.filename }}"
# Upload the MacOS Universal build artifact to the GitHub release
- name: Upload Release Asset (MacOS Universal)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.get_filename_universal.outputs.filename }} # adjusted path
asset_name: Ollama-Gui-MacOS-Universal.dmg
asset_content_type: application/octet-stream