Skip to content

Commit

Permalink
log to file and upload
Browse files Browse the repository at this point in the history
  • Loading branch information
verhas committed Oct 3, 2024
1 parent a069d2d commit 790eec5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,22 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with: {java-version: '21', distribution: temurin}

- name: Package application
run: package.bat
shell: cmd

- name: Upload Log Artifact
if: always()
uses: actions/upload-artifact@v3
with:
name: jamal-post-image-log
path: ${{ runner.temp }}/jamal-post-image.log

- name: Upload Package Artifact
uses: actions/upload-artifact@v3
with:
Expand Down
45 changes: 30 additions & 15 deletions packaging-resources/jamal-post-image.wsf
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,34 @@
Option Explicit
On Error Resume Next

' Create FileSystemObject
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

' Set up the log file path
Dim logFilePath
logFilePath = fso.GetSpecialFolder(2) & "\jamal-post-image.log" ' 2 refers to the Temp folder

' Open the log file for appending
Dim logFile
Set logFile = fso.OpenTextFile(logFilePath, 8, True) ' 8 = ForAppending

logFile.WriteLine "Starting jamal-post-image.wsf"

' Retrieve installer directory
Dim installerDir
installerDir = WScript.Arguments(0)
logFile.WriteLine "Installer directory: " & installerDir

' Define the path to main.wxs
Dim wixFilePath
wixFilePath = installerDir & "\main.wxs"

' Create FileSystemObject
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
logFile.WriteLine "WiX file path: " & wixFilePath

' Check if main.wxs exists
If Not fso.FileExists(wixFilePath) Then
WScript.Echo "Error: main.wxs not found at " & wixFilePath
logFile.WriteLine "Error: main.wxs not found at " & wixFilePath
logFile.Close()
WScript.Quit 1
End If

Expand All @@ -28,27 +42,27 @@
wixFile.Close()

If Err.Number <> 0 Then
WScript.Echo "Error reading main.wxs: " & Err.Description
logFile.WriteLine "Error reading main.wxs: " & Err.Description
logFile.Close()
WScript.Quit 1
End If

' Define registry XML to add to main.wxs
Dim registryXml
registryXml = "
<DirectoryRef Id='TARGETDIR'>
<Component Id='AppPathsRegistry' Guid='{YOUR-GUID-HERE}'>
<DirectoryRef Id='APPLICATIONFOLDER'>
<Component Id='AppPathsRegistry' Guid='" & CreateObject("Scriptlet.TypeLib").Guid & "'>
<RegistryKey Root='HKLM' Key='Software\Microsoft\Windows\CurrentVersion\App Paths\jamal.exe'>
<RegistryValue Name='' Type='string' Value='[INSTALLDIR]jamal.exe' KeyPath='yes'/>
<RegistryValue Name='' Type='string' Value='[APPLICATIONFOLDER]jamal.exe' KeyPath='yes'/>
</RegistryKey>
</Component>
</DirectoryRef>
<Feature Id='DefaultFeature' Level='1'>
<Feature Id='DefaultFeature'>
<ComponentRef Id='AppPathsRegistry'/>
</Feature>
"

' Replace placeholders
registryXml = Replace(registryXml, "{YOUR-GUID-HERE}", CreateObject("Scriptlet.TypeLib").Guid)
logFile.WriteLine "Registry XML: " & registryXml

' Insert registryXml before </Wix>
wixContent = Replace(wixContent, "</Wix>", registryXml & vbCrLf & "</Wix>")
Expand All @@ -59,12 +73,13 @@
wixFile.Close()

If Err.Number <> 0 Then
WScript.Echo "Error writing main.wxs: " & Err.Description
logFile.WriteLine "Error writing main.wxs: " & Err.Description
logFile.Close()
WScript.Quit 1
End If

' Success
WScript.Echo "Successfully modified main.wxs"
logFile.WriteLine "Successfully modified main.wxs"
logFile.Close()
WScript.Quit 0
</script>
</job>

0 comments on commit 790eec5

Please sign in to comment.