Skip to content

Commit

Permalink
Merge pull request #83 from jeremiah-k/main
Browse files Browse the repository at this point in the history
Add version number to installer
  • Loading branch information
jeremiah-k authored Oct 3, 2024
2 parents 73bf8f3 + 6ecce00 commit aa42b9a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 79 deletions.
21 changes: 5 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ on:
jobs:
build:
runs-on: windows-latest
env:
VERSION: ${{ github.ref_name }} # Extract the version from the GitHub tag

steps:
- name: Checkout repository
uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
Expand All @@ -26,26 +23,18 @@ jobs:
pip install pyinstaller
- name: Build executable
run: |
pyinstaller --name=mmrelay_${{ env.VERSION }} --onefile --console main.py
# This will create mmrelay_<version>.exe in the dist folder
run: pyinstaller --name=mmrelay.exe --onefile --console main.py

- name: Build installer
uses: nadeemjazmawe/[email protected]
with:
filepath: "/DAppVersion=${{ env.VERSION }} ./mmrelay.iss"
# Pass the version to Inno Setup

- name: Rename Installer with Version
run: |
Rename-Item "MMRelay_setup.exe" "MMRelay_setup_${{ env.VERSION }}.exe"
# Rename the installer to include the version number
filepath: "/DAppVersion=${{ github.ref_name }} ./mmrelay.iss"

- name: Upload setup.exe to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: MMRelay_setup_${{ env.VERSION }}.exe # Upload the versioned installer
asset_name: MMRelay_setup_${{ env.VERSION }}.exe
file: MMRelay_setup_${{ github.ref_name }}.exe
asset_name: MMRelay_setup_${{ github.ref_name }}.exe
tag: ${{ github.ref }}
overwrite: true
81 changes: 18 additions & 63 deletions mmrelay.iss
Original file line number Diff line number Diff line change
@@ -1,42 +1,28 @@
; Inno Setup Script for MMRelay Installer
; This script builds the installer for the MMRelay application,
; incorporating the version number from the GitHub tag.

[Setup]
; Application Information
// Add the custom wizard page to the installation
//WizardImageFile=wizard.bmp
//WizardSmallImageFile=smallwiz.bmp

AppName=Matrix <> Meshtastic Relay
AppVersion={#AppVersion} ; Use the version passed from GitHub Actions
AppVersion={#AppVersion}
DefaultDirName={userpf}\MM Relay
DefaultGroupName=MM Relay
UninstallFilesDir={app}

; Output Configuration
OutputDir=.
OutputBaseFilename=MMRelay_setup_{#AppVersion} ; Include version in installer filename

; Privileges
OutputBaseFilename=MMRelay_setup_{#AppVersion}
PrivilegesRequiredOverridesAllowed=dialog commandline

; Uncomment the following lines to add custom wizard images
; WizardImageFile=wizard.bmp
; WizardSmallImageFile=smallwiz.bmp

[Files]
; Source Executable with Version Number
Source: "dist\mmrelay_{#AppVersion}.exe"; DestDir: "{app}"; Flags: recursesubdirs createallsubdirs; AfterInstall: AfterInstall(ExpandConstant('{app}'));
Source: "dist\mmrelay.exe"; DestDir: "{app}"; Flags: recursesubdirs createallsubdirs; AfterInstall: AfterInstall(ExpandConstant('{app}'));

[Icons]
; Application Icons
Name: "{group}\MM Relay"; Filename: "{app}\mmrelay.bat"
Name: "{group}\MM Relay Config"; Filename: "{app}\config.yaml"; IconFilename: "{sys}\notepad.exe"; WorkingDir: "{app}"; Parameters: "config.yaml"
Name: "{group}\MM Relay Config"; Filename: "{app}\config.yaml"; IconFilename: "{sys}\notepad.exe"; WorkingDir: "{app}"; Parameters: "config.yaml";

[Run]
; Launch the MMRelay application after installation
Filename: "{app}\mmrelay.bat"; Description: "Launch MM Relay"; Flags: nowait postinstall

[Code]
; Pascal Script for Custom Installation Logic
var
TokenInfoLabel: TLabel;
TokenInfoLink: TNewStaticText;
Expand All @@ -53,50 +39,38 @@ var
begin
if not ShellExec('', 'open', TNewStaticText(Sender).Caption, '', SW_SHOWNORMAL, ewNoWait, ErrorCode) then
begin
// Handle failure if necessary
// handle failure if necessary
end;
end;
procedure InitializeWizard;
begin
; Create configuration option page
OverwriteConfig := CreateInputOptionPage(wpWelcome,
'Configure the relay', 'Create new configuration',
'', False, False);
; Create Matrix Setup page
MatrixPage := CreateInputQueryPage(OverwriteConfig.ID,
'Matrix Setup', 'Configure Matrix Settings',
'Enter the settings for your Matrix server.');
; Create Meshtastic Setup page
MeshtasticPage := CreateInputQueryPage(MatrixPage.ID,
'Meshtastic Setup', 'Configure Meshtastic Settings',
'Enter the settings for connecting with your Meshtastic radio.');
; Create Matrix <> Meshtastic Setup page
MatrixMeshtasticPage := CreateInputQueryPage(MeshtasticPage.ID,
'Matrix <> Meshtastic Setup', 'Configure Matrix <> Meshtastic Settings',
'Connect a Matrix room with a Meshtastic radio channel.');
; Create Additional Options page
OptionsPage := CreateInputOptionPage(MatrixMeshtasticPage.ID,
'Additional Options', 'Provide additional options',
'Set logging and broadcast options, you can keep the defaults.', False, False);
; Increase wizard form height for better layout
// Increase page height
WizardForm.ClientHeight := WizardForm.ClientHeight + 50;
; Add options to OverwriteConfig page
OverwriteConfig.Add('Generate configuration (overwrite any current config files)');
OverwriteConfig.Values[0] := False;
; Add input fields to MatrixPage
MatrixPage.Add('Homeserver (example: https://matrix.org):', False);
MatrixPage.Add('Bot user ID (example: @mybotuser:matrix.org):', False);
MatrixPage.Add('Access token (example: syt_bWvzaGjvdD1_PwsXoZgGItImVxBIZbBK_1XZVW8):', False);
; Add informational label and link for access token
TokenInfoLabel := TLabel.Create(WizardForm);
TokenInfoLabel.Caption := 'For instructions on where to find your access token, visit:';
TokenInfoLabel.Parent := MatrixPage.Surface;
Expand All @@ -113,41 +87,33 @@ begin
TokenInfoLink.Left := TokenInfoLabel.Left;
TokenInfoLink.Top := TokenInfoLabel.Top + TokenInfoLabel.Height;
; Set hints for MatrixPage input fields
MatrixPage.Edits[0].Hint := 'https://example.matrix.org';
MatrixPage.Edits[1].Hint := '@botuser:example.matrix.org';
MatrixPage.Edits[2].Hint := 'reaalllllyloooooongsecretttttcodeeeeeeforrrrbot';
; Add input fields to MeshtasticPage
MeshtasticPage.Add('Connection type (network, serial, or ble):', False);
MeshtasticPage.Add('Serial port (if serial):', False);
MeshtasticPage.Add('Hostname/IP (if network):', False);
MeshtasticPage.Add('BLE address/name (if ble):', False);
MeshtasticPage.Add('Meshnet name:', False);
; Set hints for MeshtasticPage input fields
MeshtasticPage.Edits[0].Hint := 'network, serial, or ble';
MeshtasticPage.Edits[1].Hint := 'serial port (if serial)';
MeshtasticPage.Edits[2].Hint := 'hostname/IP (if network)';
MeshtasticPage.Edits[3].Hint := 'BLE address or name (if ble)';
MeshtasticPage.Edits[4].Hint := 'Name for radio Meshnet';
; Add input fields to MatrixMeshtasticPage
MatrixMeshtasticPage.Add('Matrix room ID/alias (example: #someroom:example.matrix.org):', False);
MatrixMeshtasticPage.Add('Meshtastic channel # (0 is primary, 1-7 secondary):', False);
; Set hints for MatrixMeshtasticPage input fields
MatrixMeshtasticPage.Edits[0].Hint := '!someroomid:example.matrix.org';
MatrixMeshtasticPage.Edits[1].Hint := '0-7 (default 0)';
; Add options to OptionsPage
OptionsPage.Add('Detailed logging');
OptionsPage.Add('Radio broadcasts enabled');
OptionsPage.Values[0] := True;
OptionsPage.Values[1] := True;
end;
; Helper function to convert Boolean to String
function BoolToStr(Value: Boolean): String;
begin
if Value then
Expand All @@ -156,7 +122,7 @@ begin
result := 'false';
end;
; Determines whether to skip a wizard page based on user input
{ Skips config setup pages if needed}
function ShouldSkipPage(PageID: Integer): Boolean;
begin
if PageID = OverwriteConfig.ID then
Expand All @@ -165,7 +131,6 @@ begin
Result := Not OverwriteConfig.Values[0];
end;
; Procedure to handle actions after installation
procedure AfterInstall(sAppDir: string);
var
config: string;
Expand All @@ -176,23 +141,19 @@ var
log_level: string;
batch_file: string;
begin
; Exit if user chose not to overwrite existing config
If Not OverwriteConfig.Values[0] then
Exit;
; Backup existing config if it exists
if (FileExists(sAppDir + '\config.yaml')) then
if (FileExists(sAppDir + '/config.yaml')) then
begin
RenameFile(sAppDir + '\config.yaml', sAppDir + '\config-old.yaml');
RenameFile(sAppDir + '/config.yaml', sAppDir + '/config-old.yaml');
end;
; Retrieve user inputs from MeshtasticPage
connection_type := MeshtasticPage.Values[0];
serial_port := MeshtasticPage.Values[1];
host := MeshtasticPage.Values[2];
ble_address := MeshtasticPage.Values[3];
; Determine logging level based on user input
if OptionsPage.Values[0] then
begin
log_level := 'debug';
Expand All @@ -202,7 +163,6 @@ begin
log_level := 'info';
end;
; Construct the configuration content
config := 'matrix:' + #13#10 +
' homeserver: "' + MatrixPage.Values[0] + '"' + #13#10 +
' bot_user_id: "' + MatrixPage.Values[1] + '"' + #13#10 +
Expand All @@ -213,34 +173,29 @@ begin
'meshtastic:' + #13#10 +
' connection_type: "' + connection_type + '"' + #13#10;
; Append connection-specific settings
if connection_type = 'serial' then
config := config + ' serial_port: "' + serial_port + '"' + #13#10
else if connection_type = 'network' then
config := config + ' host: "' + host + '"' + #13#10
else if connection_type = 'ble' then
config := config + ' ble_address: "' + ble_address + '"' + #13#10;
; Continue constructing the configuration
config := config + ' meshnet_name: "' + MeshtasticPage.Values[4] + '"' + #13#10 +
' broadcast_enabled: ' + BoolToStr(OptionsPage.Values[1]) + #13#10 +
'logging:' + #13#10 +
' level: "' + log_level + '"' + #13#10 +
'plugins:' + #13#10;
; Save the configuration to config.yaml
if Not SaveStringToFile(sAppDir + '\config.yaml', config, false) then
if Not SaveStringToFile(sAppDir + '/config.yaml', config, false) then
begin
MsgBox('Could not create config file "config.yaml". Close any applications that may have it open and re-run setup', mbInformation, MB_OK);
end;
; Create the batch file to launch the application with the versioned executable
batch_file := '"' + sAppDir + '\mmrelay_' + '{#AppVersion}' + '.exe" config.yaml ' + #13#10 +
batch_file := '"' + sAppDir + '\mmrelay.exe" config.yaml ' + #13#10 +
'pause';
; Save the batch file as mmrelay.bat
if Not SaveStringToFile(sAppDir + '\mmrelay.bat', batch_file, false) then
if Not SaveStringToFile(sAppDir + '/mmrelay.bat', batch_file, false) then
begin
MsgBox('Could not create batch file "mmrelay.bat". Close any applications that may have it open and re-run setup', mbInformation, MB_OK);
MsgBox('Could not create batch file "relay.bat". Close any applications that may have it open and re-run setup', mbInformation, MB_OK);
end;
end;
end;

0 comments on commit aa42b9a

Please sign in to comment.