-
Notifications
You must be signed in to change notification settings - Fork 8
121 lines (109 loc) · 4.06 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
# Workflow dispatch for packaging an electron executable
name: 📦 Package Workflow
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"
- "mac-x64"
- "mac-arm64"
- "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 }} == mac-x64 ] && matrix='["macOS-13"]'
[ ${{ github.event.inputs.os }} == mac-arm64 ] && matrix='["macOS-latest"]'
[ ${{ github.event.inputs.os }} == linux ] && matrix='["ubtuntu-latest"]'
[ ${{ github.event.inputs.os }} == all ] && matrix='["windows-latest", "macOS-13", "macOS-latest", "ubuntu-latest"]'
echo "matrix=$matrix" >> $GITHUB_OUTPUT
package-and-upload:
name: Package and Upload Installer
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-x64'
[ ${{ matrix.os }} == macOS-latest ] && osShortName='mac-arm64'
[ ${{ matrix.os }} == ubuntu-latest ] && osShortName='linux'
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
# Install dependencies
- 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/[email protected]
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 }}
# Extract the file's path and outfile's name
- name: Extract installer info
id: installer_info
shell: bash
run: |
packageName=$(jq -r '.name' package.json)
packageVersion=$(jq -r '.version' package.json)
name="${packageName}-${packageVersion}-${{github.event.inputs.setting}}-${{steps.os_name.outputs.name}}"
echo name=$name >> $GITHUB_OUTPUT
if [[ ${{ matrix.os }} == windows-latest ]]; then
path="out/make/squirrel.windows/x64/${packageName}-${packageVersion} Setup.exe"
elif [[ ${{ matrix.os }} == macOS-13 ]]; then
path="out/make/${packageName}-${packageVersion}-x64.dmg"
elif [[ ${{ matrix.os }} == macOS-latest ]]; then
path="out/make/${packageName}-${packageVersion}-arm64.dmg"
elif [[ ${{ matrix.os }} == ubuntu-latest ]]; then
path="out/make/deb/x64/${packageName}_${packageVersion}_amd64.deb"
fi
echo path=$path >> $GITHUB_OUTPUT
- name: ⬆ Upload installer
uses: actions/upload-artifact@v4
with:
name: ${{steps.installer_info.outputs.name}}
path: ${{steps.installer_info.outputs.path}}
if-no-files-found: error