-
Notifications
You must be signed in to change notification settings - Fork 8
247 lines (219 loc) · 8.34 KB
/
workflow-package.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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# name: 📦 Package Workflow
# # Workflow dispatch for packaging an electron executable
# on:
# workflow_dispatch:
# inputs:
# setting:
# type: choice
# options:
# - "home"
# - "clinic"
# default: "home"
# required: true
# description: Package the app for 'home' or 'clinic' use
# os:
# type: choice
# description: Which operating system to make executables for
# required: true
# default: "All"
# options:
# - "All"
# - "Windows"
# - "macOS"
# - "Linux"
# jobs:
# package-and-upload:
# name: Package and Upload
# runs-on: ${{ matrix.os }}
# # Run action for [home/clinic] in [windows/macOS/ubuntu] based on user input
# strategy:
# matrix:
# # TODO: There's got to be a better way to handle this?
# os: ${{
# (github.event.inputs.os == 'All' && fromJSON('["ubuntu-latest", "macOS-13", "windows-latest"]')) ||
# (github.event.inputs.os == 'Windows' && fromJSON('["windows-latest"]')) ||
# (github.event.inputs.os == 'macOS' && fromJSON('["macOS-13"]')) ||
# (github.event.inputs.os == 'Linux' && fromJSON('["ubuntu-latest"]')) }}
# fail-fast: false # A failed build will not end the other matrix jobs
# steps:
# # Set up runner
# - name: ⬇️ Checkout repo
# uses: actions/checkout@v4
# - name: ⎔ Setup node
# uses: actions/setup-node@v4
# with:
# node-version-file: .nvmrc
# cache: npm
# - name: 🐍 Setup Python
# uses: actions/setup-python@v4
# with:
# python-version: 3.12
# # Install dependencies and set up environment
# - name: 🅿️ Install Python tools
# run: pip install setuptools
# - name: 📥 Install Dependencies
# run: npm ci
# # TEMP
# - name: Test - electron rebuild
# run: npx electron-rebuild
# # Set up the environment
# - name: 🔃 Load .env file (.env.${{github.event.inputs.setting}})
# uses: xom9ikk/dotenv@v2
# with:
# path: ./env
# mode: ${{github.event.inputs.setting}}
# # Package the app and make the installers
# - name: 📦 Make app installer - Windows
# if: startsWith(matrix.os, 'windows')
# run: npm run make:windows
# - name: 📦 Make app installer - Mac
# if: startsWith(matrix.os, 'mac')
# run: npm run make:mac
# - name: 📦 Make app installer - Linux
# if: startsWith(matrix.os, 'ubuntu')
# run: npm run make:linux
# # Get package info
# - name: Get package name and version
# id: package_info
# run: |
# echo "name=$(cat package.json | jq -r '.name')" >> $GITHUB_OUTPUT
# echo "version=$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT
# shell: bash
# - run: ls ./out/make
# shell: bash
# # Upload installers to github action
# # TODO @brown-ccv #247: Can we use the publish command here?
# - name: ⬆ Upload installer - Windows
# uses: actions/upload-artifact@v3
# if: startsWith(matrix.os, 'windows')
# with:
# name: ${{ format('win-installer-{0}', github.event.inputs.setting) }}
# path: out/make/squirrel.windows/x64/${{ steps.package_info.outputs.name }}-${{ steps.package_info.outputs.version }} Setup.exe
# if-no-files-found: error
# - name: ⬆ Upload installer - Mac
# uses: actions/upload-artifact@v3
# if: startsWith(matrix.os, 'mac')
# with:
# name: ${{ format('mac-installer-{0}', github.event.inputs.setting) }}
# path: out/make/${{ steps.package_info.outputs.name }}-${{ steps.package_info.outputs.version }}-universal.dmg
# if-no-files-found: error
# - name: ⬆ Upload installer - Linux
# uses: actions/upload-artifact@v3
# if: startsWith(matrix.os, 'ubuntu')
# with:
# name: ${{ format('linux-installer-{0}', github.event.inputs.setting) }}
# path: out/make/deb/x64/${{ steps.package_info.outputs.name }}_${{ steps.package_info.outputs.version }}_amd64.deb
# if-no-files-found: error
name: 📦 Package Workflow
# Workflow dispatch for packaging an electron executable
on:
workflow_dispatch:
inputs:
setting:
type: choice
options:
- "home"
- "clinic"
default: "home"
required: true
description: Package the app for 'home' or 'clinic' use
os:
type: choice
description: Which operating system to make executables for
required: true
default: "All"
options:
- "All"
- "Windows"
- "macOS"
- "Linux"
jobs:
setup-job:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set matrix
id: set-matrix
run: |
[ ${{ github.event.inputs.os }} == Windows ] && matrix='["windows-latest"]'
[ ${{ github.event.inputs.os }} == macOS ] && matrix='["macOS-13"]'
[ ${{ github.event.inputs.os }} == Linux ] && matrix='["ubtuntu-latest"]'
[ ${{ github.event.inputs.os }} == All ] && matrix='["windows-latest", "macOS-13", "ubuntu-latest"]'
echo "matrix=$matrix" >> $GITHUB_OUTPUT
package-and-upload:
name: Package and Upload Installer(s)
needs: setup-job
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ${{ fromJson(needs.setup-job.outputs.matrix) }}
fail-fast: false # A failed build will not end the other matrix jobs
steps:
- name: Extact OS short name
id: os_name
shell: bash
run: |
[ ${{ matrix.os }} == windows-latest ] && osShortName='windows'
[ ${{ matrix.os }} == macOS-13 ] && osShortName='mac'
[ ${{ matrix.os }} == ubuntu-latest ] && osShortName='linux'
echo $osShortName
echo name=$osShortName >> $GITHUB_OUTPUT
# Set up runner
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- name: 🐍 Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12
# TESTING
# TODO: Extract package name/info here, don't need extra step
- name: Extract artificact info
id: artifact_info
shell: bash
run: |
packageName=$(jq -r '.name' package.json)
packageVersion=$(jq -r '.version' package.json)
echo $packageName_$packageVersion_${{github.event.inputs.setting}}-${{steps.os_name.outputs.name}}
outfile="$packageName-$packageVersion-${{github.event.inputs.setting}}-${{steps.os_name.outputs.name}}"
if [[ ${{ matrix.os }} == windows-latest ]]; then
filepath="out/make/squirrel.windows/x64/$packageName-$packageVersion Setup.exe"
elif [[ ${{ matrix.os }} == macOS-13 ]]; then
filepath=out/make/$packageName-$packageVersion-x64.dmg
elif [[ ${{ matrix.os }} == ubuntu-latest ]]; then
filepath=out/make/deb/x64/$packageName_$packageVersion_amd64.deb
fi
echo $packageName
echo $packageVersion
echo $outfile
echo $filepath
echo outfile=$outfile >> $GITHUB_OUTPUT
echo filepath=$filepath >> $GITHUB_OUTPUT
# Install dependencies and set up environment
- name: 🅿️ Install Python tools
run: pip install setuptools
- name: 📥 Install Dependencies
run: npm ci
# Set up the environment
- name: 🔃 Load .env file (.env.${{github.event.inputs.setting}})
uses: xom9ikk/dotenv@v2
with:
path: ./env
mode: ${{github.event.inputs.setting}}
# Make the installers
- name: 📦 Make app installer
shell: bash
run: npm run make:${{ steps.os_name.outputs.name }}
- run: ls -R ./out/make
shell: bash
- name: ⬆ Upload installer
uses: actions/upload-artifact@v4
with:
name: ${{steps.artifact_info.outputs.outfile}}
path: ${{steps.artifact_info.outputs.filepath}}
if-no-files-found: error