diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..505492a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,277 @@ +name: Build + +on: + workflow_dispatch: + push: + branches: [ '**' ] + tags: [ 'v*.*.*' ] + pull_request: + branches: [ 'main' ] + +env: + godot-version: 4.5 + windows-installer-name: Kintsugi3DViewer-windows-installer.exe + windows-name: Kintsugi3DViewer-windows.zip + macos-name: Kintsugi3DViewer-macos.zip + +jobs: + prepare-release: + name: Prepare draft release + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Check out repository + if: github.ref_type == 'tag' + uses: actions/checkout@v4 + with: + ref: ${{ github.sha }} + + - name: Create draft release if needed + if: github.ref_type == 'tag' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if ! gh release view "${{ github.ref_name }}" >/dev/null 2>&1; then + gh release create "${{ github.ref_name }}" \ + --title "${{ github.ref_name }}" \ + --notes-file RELEASE.md \ + --draft + fi + + windows: + name: Windows build and tests + runs-on: windows-latest + needs: [ 'prepare-release'] + permissions: + contents: write + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + ref: ${{ github.sha }} + + - name: Install Godot + shell: pwsh + run: | + curl.exe -L -o godot.zip "https://github.com/godotengine/godot/releases/download/${{ env.godot-version }}-stable/Godot_v${{ env.godot-version }}-stable_win64.exe.zip" + Expand-Archive godot.zip -DestinationPath godot + Move-Item "godot/Godot_v${{ env.godot-version }}-stable_win64.exe" Godot.exe + + - name: Install Godot export templates + shell: pwsh + run: | + curl.exe -L -o godot-templates.zip "https://github.com/godotengine/godot/releases/download/${{ env.godot-version }}-stable/Godot_v${{ env.godot-version }}-stable_export_templates.tpz" + Expand-Archive godot-templates.zip -DestinationPath godot-templates + + $templateDir = "$env:APPDATA/Godot/export_templates/${{ env.godot-version }}.stable" + New-Item -ItemType Directory -Force -Path $templateDir | Out-Null + Copy-Item godot-templates/templates/* $templateDir -Recurse -Force + + - name: Update project imports + run: ./Godot.exe --headless --import --verbose | Out-Host + + - name: Build project + shell: pwsh + run: | + $output = Join-Path $PWD "export/Kintsugi3DViewer.exe" + New-Item -ItemType Directory -Force export | Out-Null + ./Godot.exe --headless --path . --export-release "Windows Desktop (with environments)" "$output" --verbose | Out-Host + $code = $LASTEXITCODE + Write-Host "Godot exit code: $code" + if (!(Test-Path $output -PathType Leaf)) { + throw "Godot did not create the executable at: $output" + } + if ($code -ne 0) { + throw "Godot export failed with exit code $code" + } + + - name: Package Windows ZIP + shell: pwsh + run: Compress-Archive -Path "export/Kintsugi3DViewer.exe" -DestinationPath "${{ env.windows-name }}" + + - name: Install NSIS + shell: pwsh + run: | + choco install nsis --yes --no-progress + "C:\Program Files (x86)\NSIS" >> $env:GITHUB_PATH + + - name: Build NSIS installer + run: makensis -V3 installer.nsi + + - name: Smoke test Windows ZIP + shell: pwsh + run: | + Expand-Archive "${{ env.windows-name }}" -DestinationPath extracted + + $exe = Join-Path $PWD "extracted/Kintsugi3DViewer.exe" + if (!(Test-Path $exe)) { + throw "Executable missing from ZIP." + } + + $p = Start-Process -FilePath $exe -WorkingDirectory (Split-Path $exe) -PassThru + Start-Sleep -Seconds 30 + $p.Refresh() + + if ($p.HasExited) { + throw "App failed to launch or exited within 30 seconds with code $($p.ExitCode)." + } + + Write-Host "App remained open for 30 seconds." + Stop-Process -Id $p.Id -Force + + - name: Install application + shell: pwsh + run: | + $installer = Join-Path $PWD "export/${{ env.windows-installer-name }}" + if (!(Test-Path $installer)) { + throw "Installer missing: $installer" + } + + $installDir = Join-Path $env:RUNNER_TEMP "Kintsugi3DViewer" + $p = Start-Process -FilePath $installer ` + -ArgumentList "/S", "/D=$installDir" -Wait -PassThru + + if ($p.ExitCode -ne 0) { + throw "Installer exited with code $($p.ExitCode)." + } + + $exe = Join-Path $installDir "Kintsugi3DViewer.exe" + if (!(Test-Path $exe)) { + throw "Installed executable missing." + } + + $uninstaller = Join-Path $installDir "uninstall.exe" + if (!(Test-Path $uninstaller)) { + throw "Uninstaller missing." + } + + "INSTALL_DIR=$installDir" >> $env:GITHUB_ENV + + - name: Smoke test installed executable + shell: pwsh + run: | + $exe = Join-Path $env:INSTALL_DIR "Kintsugi3DViewer.exe" + $p = Start-Process -FilePath $exe ` + -WorkingDirectory $env:INSTALL_DIR -PassThru + + Start-Sleep -Seconds 30 + $p.Refresh() + + if ($p.HasExited) { + throw "App failed to launch or exited within 30 seconds with code $($p.ExitCode)." + } + + Stop-Process -Id $p.Id -Force + Write-Host "App remained open for 30 seconds." + + - name: Uninstall application + shell: pwsh + run: | + $uninstaller = Join-Path $env:INSTALL_DIR "uninstall.exe" + $p = Start-Process -FilePath $uninstaller ` + -ArgumentList "/S" -Wait -PassThru + + if ($p.ExitCode -ne 0) { + throw "Uninstaller exited with code $($p.ExitCode)." + } + + if (Test-Path (Join-Path $env:INSTALL_DIR "Kintsugi3DViewer.exe")) { + throw "Application executable still exists after uninstall." + } + + Write-Host "App successfully uninstalled." + + - name: Upload Windows release assets + if: github.ref_type == 'tag' + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload "${{ github.ref_name }}" \ + "${{ env.windows-name }}" \ + "export/${{ env.windows-installer-name }}" \ + --clobber + + macos: + name: macOS build and tests + runs-on: macos-latest + needs: [ 'prepare-release' ] + permissions: + contents: write + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + ref: ${{ github.sha }} + + - name: Install Godot + run: | + curl -L -o godot.zip "https://github.com/godotengine/godot/releases/download/${{ env.godot-version }}-stable/Godot_v${{ env.godot-version }}-stable_macos.universal.zip" + unzip -q godot.zip + + - name: Install Godot export templates + run: | + curl -L -o godot-templates.zip "https://github.com/godotengine/godot/releases/download/${{ env.godot-version }}-stable/Godot_v${{ env.godot-version }}-stable_export_templates.tpz" + unzip -q godot-templates.zip + mkdir -p ~/Library/Application\ Support/Godot/export_templates/${{ env.godot-version }}.stable/ + mv ./templates/* ~/Library/Application\ Support/Godot/export_templates/${{ env.godot-version }}.stable/ + + - name: Update project imports + run: ./Godot.app/Contents/MacOS/Godot --headless --import --verbose + + - name: Build project + run: | + mkdir -p export + ./Godot.app/Contents/MacOS/Godot --headless --path . --export-release "macOS (all environments)" "export/${{ env.macos-name }}" --verbose + + - name: Extract macOS ZIP + run: unzip -q "export/${{ env.macos-name }}" -d extracted + + - name: Install timeout utility + run: brew install coreutils + + - name: Smoke-test macOS app + shell: bash + run: | + APP="extracted/Kintsugi 3D Viewer.app" + EXE="$APP/Contents/MacOS/Kintsugi 3D Viewer" + + # Test 1: Run the executable directly and check whether it exits early. + "$EXE" & + PID=$! + sleep 30 + + if kill -0 "$PID" 2>/dev/null; then + kill "$PID" + wait "$PID" 2>/dev/null || true + echo "App remained open for 30 seconds (direct executable launch)." + else + if wait "$PID"; then + STATUS=0 + else + STATUS=$? + fi + echo "App failed to launch or exited within 30 seconds with code $STATUS (direct executable launch)." + exit 1 + fi + + # Test 2: Launch as a user would and require it to remain open for 30 seconds. + Gtimeout="$(brew --prefix coreutils)/bin/gtimeout" + set +e + "$Gtimeout" --kill-after=5s 30s open -W -n "$APP" + STATUS=$? + set -e + + if [ "$STATUS" -eq 124 ]; then + echo "App remained open for 30 seconds (app launched with 'open')." + else + echo "App failed to launch or exited within 30 seconds with code $STATUS (app launched with 'open')." + exit 1 + fi + + - name: Upload macOS release asset + if: github.ref_type == 'tag' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh release upload "${{ github.ref_name }}" "export/${{ env.macos-name }}" --clobber diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000..92ad9c0 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1 @@ +## Kintsugi3DViewer diff --git a/installer.nsi b/installer.nsi index 8d887fc..5695967 100644 --- a/installer.nsi +++ b/installer.nsi @@ -9,7 +9,7 @@ Name "Kintsugi 3D Viewer" RequestExecutionLevel admin Unicode True ManifestDPIAware True -OutFile "export/Kintsugi3DViewer-setup.exe" +OutFile "export/Kintsugi3DViewer-windows-installer.exe" InstallDir $PROGRAMFILES64\Kintsugi3DViewer @@ -33,8 +33,15 @@ InstallDir $PROGRAMFILES64\Kintsugi3DViewer !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH +; Variables to store uninstall choices +Var Checkbox_ClearViewerCache +Var Checkbox_ClearViewerPreferences +Var ClearViewerCache +Var ClearViewerPreferences + ; Uninstaller Pages !insertmacro MUI_UNPAGE_CONFIRM +UninstPage custom un.CachePageCreate un.CachePageLeave !insertmacro MUI_UNPAGE_INSTFILES ; Language Files @@ -50,7 +57,7 @@ Section "Kintsugi 3D Viewer (required)" SectionApp SetOutPath $INSTDIR File "export\Kintsugi3DViewer.exe" - File "export\Kintsugi3DViewer.console.exe" + ;File "export\Kintsugi3DViewer.console.exe" ;File "export\Kintsugi3DViewer.pck" File "README.md" @@ -116,6 +123,17 @@ Section "Uninstall" RMDir /r "$SMPROGRAMS\Kintsugi3DViewer" RMDir /r "$INSTDIR" + ; Remove viewer cache + ${If} $ClearViewerCache == 1 + RMDir /r "$APPDATA\Kintsugi 3D Viewer\cache" + RMDir /r "$APPDATA\Kintsugi 3D Viewer\shader_cache" + ${EndIf} + + ; Remove viewer preferences (will also remove cache) + ${If} $ClearViewerPreferences == 1 + RMDir /r "$APPDATA\Kintsugi 3D Viewer" + ${EndIf} + ; Remove Desktop Shortcut Delete "$DESKTOP\Kintsugi 3D Viewer.lnk" @@ -139,6 +157,44 @@ Function LaunchLink FunctionEnd +; Options for uninstalling cache directories +Function un.CachePageCreate + ; Create the page + nsDialogs::Create 1018 + + ; Set Page Header Text + !insertmacro MUI_HEADER_TEXT "Additional Directories" "Choose which additional software directories to remove." + + ${NSD_CreateCheckbox} 10u 10u 100% 12u "Clear Kintsugi 3D Viewer preferences, logs, and local files list" + Pop $Checkbox_ClearViewerPreferences + ${NSD_Check} $Checkbox_ClearViewerPreferences + ${NSD_OnClick} $Checkbox_ClearViewerPreferences un.OnViewerPreferences + + ${NSD_CreateCheckbox} 10u 25u 100% 12u "Clear Kintsugi 3D Viewer cache" + Pop $Checkbox_ClearViewerCache + ${NSD_Check} $Checkbox_ClearViewerCache + + ; Display the configured page + nsDialogs::Show +FunctionEnd + +; Force clearing preferences to clear cache as well +Function un.OnViewerPreferences + Pop $0 + ${NSD_GetState} $Checkbox_ClearViewerPreferences $0 + ${If} $0 == 1 + ${NSD_Check} $Checkbox_ClearViewerCache + ${Else} + ${NSD_Uncheck} $Checkbox_ClearViewerCache + ${EndIf} +FunctionEnd + +; Read checkbox states +Function un.CachePageLeave + ${NSD_GetState} $Checkbox_ClearViewerCache $ClearViewerCache + ${NSD_GetState} $Checkbox_ClearViewerPreferences $ClearViewerPreferences +FunctionEnd + ; Init function, read previous installation directory Function .onInit @@ -163,4 +219,4 @@ LangString DESC_SectionDesktop ${LANG_ENGLISH} "Add a shortcut to Kintsugi 3D Vi !insertmacro MUI_DESCRIPTION_TEXT ${SectionAssociation} $(DESC_SectionAssociation) !insertmacro MUI_DESCRIPTION_TEXT ${SectionShortcut} $(DESC_SectionShortcut) !insertmacro MUI_DESCRIPTION_TEXT ${SectionDesktop} $(DESC_SectionDesktop) -!insertmacro MUI_FUNCTION_DESCRIPTION_END \ No newline at end of file +!insertmacro MUI_FUNCTION_DESCRIPTION_END