From 7caae8411ad05d31b48b370feb2bc5943d8c17cd Mon Sep 17 00:00:00 2001 From: Jeremiah K <17190268+jeremiah-k@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:15:16 -0500 Subject: [PATCH 1/2] Back to originals --- .github/workflows/main.yml | 23 +++-------- mmrelay.iss | 81 +++++++++----------------------------- 2 files changed, 24 insertions(+), 80 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b2330cf..1b49fc9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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_.exe in the dist folder + run: pyinstaller --name=mmrelay.exe --onefile --console main.py - name: Build installer uses: nadeemjazmawe/inno-setup-action-cli@v6.0.5 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.exe + asset_name: MMRelay_setup.exe tag: ${{ github.ref }} - overwrite: true + overwrite: true \ No newline at end of file diff --git a/mmrelay.iss b/mmrelay.iss index cf05fc3..ed412c2 100644 --- a/mmrelay.iss +++ b/mmrelay.iss @@ -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 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; @@ -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; @@ -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 @@ -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 @@ -165,7 +131,6 @@ begin Result := Not OverwriteConfig.Values[0]; end; -; Procedure to handle actions after installation procedure AfterInstall(sAppDir: string); var config: string; @@ -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'; @@ -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 + @@ -213,7 +173,6 @@ 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 @@ -221,26 +180,22 @@ begin 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; \ No newline at end of file From 6ecce00655d24fbee539e746202c6b092506bec3 Mon Sep 17 00:00:00 2001 From: Jeremiah K <17190268+jeremiah-k@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:17:22 -0500 Subject: [PATCH 2/2] Add version number to release --- .github/workflows/main.yml | 6 +++--- mmrelay.iss | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1b49fc9..b7e1519 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,7 +34,7 @@ jobs: uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: MMRelay_setup.exe - asset_name: MMRelay_setup.exe + file: MMRelay_setup_${{ github.ref_name }}.exe + asset_name: MMRelay_setup_${{ github.ref_name }}.exe tag: ${{ github.ref }} - overwrite: true \ No newline at end of file + overwrite: true diff --git a/mmrelay.iss b/mmrelay.iss index ed412c2..296c55f 100644 --- a/mmrelay.iss +++ b/mmrelay.iss @@ -9,7 +9,7 @@ DefaultDirName={userpf}\MM Relay DefaultGroupName=MM Relay UninstallFilesDir={app} OutputDir=. -OutputBaseFilename=MMRelay_setup +OutputBaseFilename=MMRelay_setup_{#AppVersion} PrivilegesRequiredOverridesAllowed=dialog commandline [Files]