Skip to content

Commit 5ff114b

Browse files
committed
Update Windows build and deploy Github Action to use Wix
1 parent 049c650 commit 5ff114b

25 files changed

Lines changed: 406 additions & 102 deletions

.github/workflows/windows_build_deploy.yml

Lines changed: 127 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -12,89 +12,137 @@ permissions:
1212
contents: read
1313

1414
env:
15-
AWS_REGION : us-east-1
15+
AWS_REGION: us-east-1
1616

1717
jobs:
1818
build:
1919
name: Build for Windows
2020
runs-on: windows-latest
2121

2222
steps:
23-
- name: Clone Repository
24-
uses: actions/checkout@v3
25-
26-
- name: Install Python 3.9
27-
uses: actions/setup-python@v4
28-
with:
29-
python-version: '3.9'
30-
architecture: 'x64'
31-
32-
- name: Install Processing
33-
run: |
34-
mkdir %GITHUB_WORKSPACE%\processing
35-
cd %GITHUB_WORKSPACE%\processing
36-
curl -O -L --insecure https://github.com/processing/processing4/releases/download/processing-1292-4.2/processing-4.2-windows-x64.zip
37-
ls -l %GITHUB_WORKSPACE%\processing
38-
unzip processing-4.2-windows-x64.zip
39-
ls -l %GITHUB_WORKSPACE%\processing\processing-4.2
40-
mkdir %userprofile%\documents\processing\libraries
41-
xcopy %GITHUB_WORKSPACE%\OpenBCI_GUI\libraries\* %userprofile%\documents\processing\libraries /s /i /q
42-
ls -l %userprofile%\documents\processing\libraries
43-
shell: cmd
44-
45-
- name: Set Path
46-
run: |
47-
echo %GITHUB_WORKSPACE%\processing\processing-4.2>>%GITHUB_PATH%
48-
echo C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64>>%GITHUB_PATH%
49-
shell: cmd
50-
51-
- name: Print Path
52-
run: echo %PATH%
53-
shell: cmd
54-
55-
- name: Check processing-java Command
56-
run: processing-java --help
57-
shell: cmd
58-
59-
- name: Run Unit Tests
60-
run: python %GITHUB_WORKSPACE%\GuiUnitTests\run-unittests.py
61-
shell: cmd
62-
63-
- name: Build
64-
run: python %GITHUB_WORKSPACE%\release\build.py
65-
shell: cmd
66-
67-
- name: Sign
68-
run: |
69-
dotnet tool install --global azuresigntool
70-
mt -manifest %GITHUB_WORKSPACE%\release\windows\gui.manifest -outputresource:%GITHUB_WORKSPACE%\application.windows64\OpenBCI_GUI.exe;#1
71-
mt -manifest %GITHUB_WORKSPACE%\release\windows\java.manifest -outputresource:%GITHUB_WORKSPACE%\application.windows64\java\bin\java.exe;#1
72-
mt -manifest %GITHUB_WORKSPACE%\release\windows\javaw.manifest -outputresource:%GITHUB_WORKSPACE%\application.windows64\java\bin\javaw.exe;#1
73-
azuresigntool sign --azure-key-vault-url "${{ secrets.AZURE_KEY_VAULT_URI }}" --azure-key-vault-client-id "${{ secrets.AZURE_CLIENT_ID }}" --azure-key-vault-tenant-id "${{ secrets.AZURE_TENANT_ID }}" --azure-key-vault-client-secret "${{ secrets.AZURE_CLIENT_SECRET }}" --azure-key-vault-certificate "${{ secrets.AZURE_CERT_NAME }}" --timestamp-rfc3161 http://timestamp.digicert.com --verbose %GITHUB_WORKSPACE%\application.windows64\OpenBCI_GUI.exe
74-
shell: cmd
75-
76-
- name: Package
77-
run: python %GITHUB_WORKSPACE%\release\package.py
78-
shell: cmd
79-
80-
- name: Configure AWS credentials
81-
uses: aws-actions/configure-aws-credentials@v2
82-
with:
83-
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
84-
aws-region: ${{ env.AWS_REGION }}
85-
86-
- name: Get Branch Names
87-
id: branch-name
88-
uses: tj-actions/branch-names@v7
89-
90-
- name: Store Build on AWS
91-
run: |
92-
cd ${{ github.workspace }}
93-
ls
94-
echo "${{ steps.branch-name.outputs.head_ref_branch }}"
95-
set S3_BRANCH_FOLDER=s3://openbci-public-gui-v6/${{ steps.branch-name.outputs.head_ref_branch }}
96-
echo %S3_BRANCH_FOLDER%
97-
aws s3 rm s3://openbci-public-gui-v6/latest --recursive --exclude "*" --include "openbcigui_*_windows64.zip"
98-
aws s3 cp ${{ github.workspace }}/. %S3_BRANCH_FOLDER% --recursive --exclude "*" --include "openbcigui_*_windows64.zip"
99-
aws s3 cp ${{ github.workspace }}/. s3://openbci-public-gui-v6/latest --recursive --exclude "*" --include "openbcigui_*_windows64.zip"
100-
shell: cmd
23+
- name: Clone Repository
24+
uses: actions/checkout@v4
25+
26+
- name: Install Python 3.9
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: '3.9'
30+
architecture: 'x64'
31+
32+
- name: Install Processing
33+
run: |
34+
mkdir %GITHUB_WORKSPACE%\processing
35+
cd %GITHUB_WORKSPACE%\processing
36+
curl -O -L --insecure https://github.com/processing/processing4/releases/download/processing-1292-4.2/processing-4.2-windows-x64.zip
37+
ls -l %GITHUB_WORKSPACE%\processing
38+
unzip processing-4.2-windows-x64.zip
39+
ls -l %GITHUB_WORKSPACE%\processing\processing-4.2
40+
mkdir %userprofile%\documents\processing\libraries
41+
xcopy %GITHUB_WORKSPACE%\OpenBCI_GUI\libraries\* %userprofile%\documents\processing\libraries /s /i /q
42+
ls -l %userprofile%\documents\processing\libraries
43+
shell: cmd
44+
45+
- name: Set Path
46+
run: |
47+
echo %GITHUB_WORKSPACE%\processing\processing-4.2>>%GITHUB_PATH%
48+
echo C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64>>%GITHUB_PATH%
49+
shell: cmd
50+
51+
- name: Print Path
52+
run: echo %PATH%
53+
shell: cmd
54+
55+
- name: Check processing-java Command
56+
run: processing-java --help
57+
shell: cmd
58+
59+
- name: Update Processing Application Icon File
60+
run: |
61+
echo ${{ env.gui-icon-parent-folder }}
62+
ls -l ${{ env.gui-icon-parent-folder }}
63+
echo ${{ env.processing-icon-path }}
64+
ls -l ${{ env.processing-icon-path }}
65+
xcopy ${{ env.gui-icon-path }} ${{ env.processing-icon-path }} /i /y
66+
env:
67+
gui-icon-parent-folder: ${{ github.workspace }}\release\windows\icons\application
68+
gui-icon-path: ${{ github.workspace }}\release\windows\icons\application\application.ico
69+
processing-icon-path: ${{ github.workspace }}\processing\processing-4.2\modes\java\application
70+
71+
- name: Update Processing Core Icon Files
72+
run: |
73+
ren ${{ env.processing-core-folder }}\core.jar core.zip
74+
mkdir ${{ env.processing-core-icon-path }}
75+
ls -l ${{ env.processing-core-folder }}
76+
unzip ${{ env.processing-core-folder }}\core.zip -d ${{ env.processing-core-unzip-path }}
77+
del ${{ env.processing-core-folder }}\core.zip
78+
xcopy ${{ env.gui-core-icon-path }} ${{ env.processing-core-icon-path }} /e /i /y
79+
cd ${{ env.processing-core-unzip-path }}
80+
ls -l
81+
7z a -r core.zip *
82+
ren core.zip core.jar
83+
echo "Updated Processing Core Icon Files"
84+
ls -l
85+
move core.jar ${{ env.processing-core-updated-jar-path }}
86+
cd ${{ env.processing-core-updated-jar-path }}
87+
rmdir ${{ env.processing-core-icon-path }} /s /q
88+
ls -l
89+
env:
90+
processing-core-folder: ${{ github.workspace }}\processing\processing-4.2\core\library\
91+
processing-core-unzip-path: ${{ github.workspace }}\processing\processing-4.2\core\library\core
92+
gui-core-icon-path: ${{ github.workspace }}\release\windows\icons\core\*
93+
processing-core-icon-path: ${{ github.workspace }}\processing\processing-4.2\core\library\core\icon
94+
processing-core-updated-jar-path: ${{ github.workspace }}\processing\processing-4.2\core\library\
95+
shell: cmd
96+
97+
- name: Run Unit Tests
98+
run: python %GITHUB_WORKSPACE%\GuiUnitTests\run-unittests.py
99+
shell: cmd
100+
101+
- name: Build
102+
run: python %GITHUB_WORKSPACE%\release\build.py
103+
shell: cmd
104+
105+
- name: Sign Executables
106+
if: ${{ true }}
107+
run: |
108+
dotnet tool install --global azuresigntool
109+
mt -manifest %GITHUB_WORKSPACE%\release\windows\gui.manifest -outputresource:%GITHUB_WORKSPACE%\application.windows64\OpenBCI_GUI.exe;#1
110+
mt -manifest %GITHUB_WORKSPACE%\release\windows\java.manifest -outputresource:%GITHUB_WORKSPACE%\application.windows64\java\bin\java.exe;#1
111+
mt -manifest %GITHUB_WORKSPACE%\release\windows\javaw.manifest -outputresource:%GITHUB_WORKSPACE%\application.windows64\java\bin\javaw.exe;#1
112+
azuresigntool sign --azure-key-vault-url "${{ secrets.AZURE_KEY_VAULT_URI }}" --azure-key-vault-client-id "${{ secrets.AZURE_CLIENT_ID }}" --azure-key-vault-tenant-id "${{ secrets.AZURE_TENANT_ID }}" --azure-key-vault-client-secret "${{ secrets.AZURE_CLIENT_SECRET }}" --azure-key-vault-certificate "${{ secrets.AZURE_CERT_NAME }}" --timestamp-rfc3161 http://timestamp.digicert.com --verbose %GITHUB_WORKSPACE%\application.windows64\OpenBCI_GUI.exe
113+
shell: cmd
114+
115+
- name: Package
116+
id: package
117+
run: python %GITHUB_WORKSPACE%\release\package.py
118+
shell: cmd
119+
120+
- name: Sign MSI Package
121+
if: ${{ true }}
122+
run: |
123+
azuresigntool sign --azure-key-vault-url "${{ secrets.AZURE_KEY_VAULT_URI }}" --azure-key-vault-client-id "${{ secrets.AZURE_CLIENT_ID }}" --azure-key-vault-tenant-id "${{ secrets.AZURE_TENANT_ID }}" --azure-key-vault-client-secret "${{ secrets.AZURE_CLIENT_SECRET }}" --azure-key-vault-certificate "${{ secrets.AZURE_CERT_NAME }}" --timestamp-rfc3161 http://timestamp.digicert.com --verbose ${{ env.msi-path }}
124+
env:
125+
msi-path: ${{ steps.package.outputs.msi_path }}
126+
shell: cmd
127+
128+
- name: Configure AWS credentials
129+
uses: aws-actions/configure-aws-credentials@v4
130+
with:
131+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
132+
aws-region: ${{ env.AWS_REGION }}
133+
134+
- name: Get Branch Names
135+
id: branch-name
136+
uses: tj-actions/branch-names@v8
137+
138+
- name: Store Build on AWS
139+
run: |
140+
cd ${{ github.workspace }}
141+
ls
142+
echo "${{ steps.branch-name.outputs.head_ref_branch }}"
143+
set S3_BRANCH_FOLDER=s3://openbci-public-gui-v7/${{ steps.branch-name.outputs.head_ref_branch }}
144+
echo %S3_BRANCH_FOLDER%
145+
aws s3 rm s3://openbci-public-gui-v6/latest --recursive --exclude "*" --include "openbcigui_*_windows64.zip"
146+
aws s3 cp ${{ github.workspace }}/. %S3_BRANCH_FOLDER% --recursive --exclude "*" --include "openbcigui_*_windows64.zip"
147+
aws s3 cp ${{ github.workspace }}/. s3://openbci-public-gui-v7/latest --recursive --exclude "*" --include "openbcigui_*_windows64.zip"
148+
shell: cmd

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ libGanglionLib.so
2727
libGanglionScan.so
2828
libunicorn.so
2929
OpenBCI_GUI/out/
30+
release/wix/bin/*
31+
release/wix/obj/*
32+
UNITTEST_FAILURE

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/*.wxs

release/build.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,6 @@ def clean():
5555
os.remove(file_path)
5656
print ("Successfully deleted " + file)
5757

58-
def update_timestamp():
59-
sketch = find_sketch_directory()
60-
main_file = os.path.join(sketch, "OpenBCI_GUI.pde")
61-
62-
timestamp = subprocess.check_output(['git', 'log', '-1', '--date=format:"%Y/%m/%d %T"', '--format=%ad']).decode("utf-8").strip('"\n')
63-
64-
data = []
65-
with open(main_file, 'r') as sketch_file:
66-
data = sketch_file.readlines()
67-
68-
for i in range(0, len(data)):
69-
if data[i].startswith("String localGUIVersionDate"):
70-
print(data[i])
71-
data[i] = "String localGUIVersionDate = \"" + timestamp + "\";\n"
72-
print(data[i])
73-
break
74-
75-
with open(main_file, 'w') as sketch_file:
76-
sketch_file.writelines(data)
77-
7858
def build():
7959
# unfortunately, processing-java always returns exit code 1,
8060
# so we can't reliably check for success or failure
@@ -98,7 +78,6 @@ def delete_source_directory():
9878

9979
def main ():
10080
clean()
101-
update_timestamp()
10281
build()
10382
delete_source_directory()
10483

release/package.py

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ def main ():
3737
if line.startswith("String localGUIVersionString"):
3838
quotes_pos = [pos for pos, char in enumerate(line) if char == '"']
3939
version = line[quotes_pos[0]+1:quotes_pos[1]]
40-
print(version)
40+
print("GUI Version: " + version)
4141
break
4242

4343
new_name = "openbcigui_" + version + "_"
4444
build_directory = os.path.join(os.getcwd(), flavors[LOCAL_OS])
45+
print("Build directory: " + build_directory)
4546

4647
# Allow GUI to launch from directory with spaces #916
4748
if LOCAL_OS == LINUX:
@@ -60,15 +61,57 @@ def main ():
6061

6162
if LOCAL_OS == MAC:
6263
shutil.move(flavors[LOCAL_OS] + ".dmg", new_name + "macosx.dmg")
63-
else: # Windows and Linux
64+
elif LOCAL_OS == LINUX:
6465
release_directory = flavors[LOCAL_OS].replace("application.", new_name)
6566
release_directory = os.path.join(os.getcwd(), release_directory)
67+
print("Release directory: " + release_directory)
6668

6769
temporary_directory = os.path.join(sketch_directory, "OpenBCI_GUI")
70+
print("Temporary directory: " + temporary_directory)
6871
os.rename(build_directory, temporary_directory)
6972
os.mkdir(release_directory)
7073
shutil.move(temporary_directory, release_directory)
7174
shutil.make_archive(release_directory, 'zip', release_directory)
75+
else:
76+
update_wix_version(version)
77+
print("Making WiX installer for Windows")
78+
wix_command = f'dotnet build {os.getcwd()}\\release\\wix\\OpenBCI_GUI.wixproj -c Release -p:ProductVersion={version}'
79+
print(wix_command)
80+
os.system(wix_command)
81+
name = 'msi_path'
82+
found_msi_files = [f for f in os.listdir(os.path.join(os.getcwd(), 'release', 'wix', 'bin', 'Release', 'en-US')) if f.endswith('.msi')]
83+
print(f'Found MSI files: {found_msi_files}')
84+
msi_path = os.path.join(os.getcwd(), 'release', 'wix', 'bin', 'Release', 'en-US', found_msi_files[0])
85+
github_output = os.getenv('GITHUB_OUTPUT')
86+
if github_output is not None:
87+
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
88+
print(f'{name}={msi_path}', file=fh)
89+
else:
90+
print(f'{name}={msi_path}')
91+
92+
def update_wix_version(version):
93+
wix_file = os.path.join(os.getcwd(), "release", "wix", "Package.wxs")
94+
with open(wix_file, 'r') as file :
95+
filedata = file.read()
96+
97+
filedata = replace_between_identifiers(filedata, 'Version="', '"', version + '"')
98+
with open(wix_file, 'w') as file:
99+
file.write(filedata)
100+
101+
def replace_between_identifiers(text, start_id, end_id, replacement):
102+
start_index = text.find(start_id)
103+
end_index = text.find(end_id, start_index + len(start_id))
104+
105+
if start_index == -1 or end_index == -1:
106+
# If either identifier is not found, return the original text
107+
return text
108+
109+
# Include the end identifier in the part to be replaced
110+
end_index += len(end_id)
111+
112+
# Replace the part between the identifiers
113+
new_text = text[:start_index + len(start_id)] + replacement + text[end_index:]
114+
return new_text
72115

73116
if __name__ == "__main__":
74117
main ()

release/windows/core/icon-1024.png

245 KB
Loading

release/windows/core/icon-128.png

22.9 KB
Loading

release/windows/core/icon-16.png

3.29 KB
Loading

release/windows/core/icon-256.png

51.4 KB
Loading

release/windows/core/icon-32.png

4.91 KB
Loading

0 commit comments

Comments
 (0)