-
Notifications
You must be signed in to change notification settings - Fork 39
172 lines (148 loc) · 4.97 KB
/
Copy pathbuild.yml
File metadata and controls
172 lines (148 loc) · 4.97 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
name: Build and Release
on:
push:
tags:
- 'v*.*.*'
paths-ignore:
- '**.md'
- '**.spec.js'
- '.idea'
- '.vscode'
- '.dockerignore'
- 'Dockerfile'
- '.gitignore'
- '.github/**'
- '!.github/workflows/build.yml'
jobs:
build:
name: Build for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
environment: Prod
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
- name: Set up Python (for native modules)
uses: actions/setup-python@v5
id: setup_python
with:
python-version: '3.11'
- name: Install Python build tools
run: |
python -m pip install --upgrade pip setuptools wheel
# Ensure distutils is available for node-gyp
python -c "import distutils; print('distutils available')"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache-dependency-path: backend/go.sum
- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('backend/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Verify Go installation
run: |
which go
go version
- name: Install Go Dependencies
working-directory: backend
run: go mod download
- name: Install Node Dependencies
run: npm install
env:
PYTHON: ${{ steps.setup_python.outputs.python-path }}
npm_config_python: ${{ steps.setup_python.outputs.python-path }}
- name: Run Unit Tests
run: npm run test
- name: Get app version from package.json
id: get_version
run: echo "APP_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
shell: bash
- name: Create app-config.json
shell: bash
run: |
printf "{\n" > app-config.json
printf " \"VITE_GOOGLE_CLIENT_ID\": \"%s\",\n" "${{ secrets.VITE_GOOGLE_CLIENT_ID }}" >> app-config.json
printf " \"VITE_GOOGLE_CLIENT_SECRET\": \"%s\"\n" "${{ secrets.VITE_GOOGLE_CLIENT_SECRET }}" >> app-config.json
printf "}\n" >> app-config.json
env:
VITE_GOOGLE_CLIENT_ID: ${{ secrets.VITE_GOOGLE_CLIENT_ID }}
VITE_GOOGLE_CLIENT_SECRET: ${{ secrets.VITE_GOOGLE_CLIENT_SECRET }}
- name: Create resources directory
run: mkdir -p resources/backend
shell: bash
- name: Install build dependencies
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
sudo apt-get update
sudo apt-get install -y build-essential
elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then
# Windows has build tools available by default
echo "Using Windows build tools"
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
# macOS has build tools available via Xcode Command Line Tools
echo "Using macOS build tools"
fi
shell: bash
- name: Build Go Backend and Download Models
run: npm run build:go
shell: bash
- name: Build Release Files
run: npm run build:web && npx electron-builder --publish never
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Artifacts for ${{ matrix.os }}
uses: actions/upload-artifact@v4
with:
name: release-artifacts-${{ matrix.os }}
path: release/${{ env.APP_VERSION }}
if-no-files-found: error
retention-days: 5
create_release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: true
- name: Download all release assets
uses: actions/download-artifact@v4
with:
path: ./release-assets
pattern: release-artifacts-*
merge-multiple: true
- name: Display structure of downloaded files
shell: bash
run: |
echo "Downloaded release assets:"
ls -R ./release-assets
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
artifacts: './release-assets/*'
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
generateReleaseNotes: true
prerelease: ${{ contains(github.ref_name, 'beta') || contains(github.ref_name, 'alpha') || contains(github.ref_name, 'rc') }}