From 0bb1e8c3ea11f8342e7a6bd59d0f584e113385b0 Mon Sep 17 00:00:00 2001 From: Alexander Loren Date: Mon, 24 Aug 2026 16:12:12 -0700 Subject: [PATCH] Initial commit --- .gitignore | 97 ++++++++++++++++++++++++++++++++++++++++++++++ LICENSE.md | 21 ++++++++++ action.yml | 21 ++++++++++ collect.ps1 | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 248 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE.md create mode 100644 action.yml create mode 100644 collect.ps1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7b5ddbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,97 @@ +# Created by https://www.toptal.com/developers/gitignore/api/windows,linux,macos,visualstudiocode +# Edit at https://www.toptal.com/developers/gitignore?templates=windows,linux,macos,visualstudiocode + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/windows,linux,macos,visualstudiocode diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..1e374b1 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Alexander Loren (omgitsalexl) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..935ae6b --- /dev/null +++ b/action.yml @@ -0,0 +1,21 @@ +name: "Collect Dependencies" +description: "Copies an executable's required non-system DLLs to an artifact directory" + +inputs: + executable: + description: "Path to the executable" + required: true + + output: + description: "Artifact output directory" + required: false + default: "artifacts" + +runs: + using: "composite" + + steps: + - name: Collect dependencies + shell: powershell + run: | + "${{ github.action_path }}\collect.ps1" -Executable "${{ inputs.executable }}" -Output "${{ inputs.output }}" \ No newline at end of file diff --git a/collect.ps1 b/collect.ps1 new file mode 100644 index 0000000..cfc8e6b --- /dev/null +++ b/collect.ps1 @@ -0,0 +1,109 @@ +param( + [Parameter(Mandatory = $true)] + [string]$Executable, + + [Parameter(Mandatory = $false)] + [string]$Output = "artifacts" +) + +$ErrorActionPreference = "Stop" + +if (-not (Test-Path $Executable)) { + throw "Executable does not exist: $Executable" +} + +New-Item -ItemType Directory -Force -Path $Output | Out-Null + +$windowsDirectories = @( + $env:WINDIR, + (Join-Path $env:WINDIR "System32"), + (Join-Path $env:WINDIR "SysWOW64") +) + +$processed = @{} + +function Test-IsWindowsSystemDll { + param( + [string]$Name + ) + + foreach ($directory in $windowsDirectories) { + $path = Join-Path $directory $Name + + if (Test-Path $path) { + return $true + } + } + + return $false +} + +function Find-Dependency { + param( + [string]$Name, + [string]$BinaryDirectory + ) + + $localPath = Join-Path $BinaryDirectory $Name + + if (Test-Path $localPath) { + return $localPath + } + + $command = Get-Command $Name -ErrorAction SilentlyContinue + + if ($command) { + return $command.Source + } + + return $null +} + +function Copy-Dependencies { + param( + [string]$Binary + ) + + $binaryDirectory = Split-Path -Parent $Binary + + $dependencies = dumpbin /DEPENDENTS $Binary | + Select-String '^\s+.*\.dll$' | + ForEach-Object { $_.Line.Trim() } | + Sort-Object -Unique + + foreach ($dll in $dependencies) { + + $key = $dll.ToLowerInvariant() + + if ($processed.ContainsKey($key)) { + continue + } + + $processed[$key] = $true + + if (Test-IsWindowsSystemDll $dll) { + Write-Host "Skipping Windows system dependency: $dll" + continue + } + + $source = Find-Dependency ` + -Name $dll ` + -BinaryDirectory $binaryDirectory + + if (-not $source) { + Write-Warning "Could not locate dependency: $dll" + continue + } + + $destination = Join-Path $Output (Split-Path -Leaf $source) + + if (-not (Test-Path $destination)) { + Write-Host "Copying dependency: $source" + Copy-Item $source $destination -Force + } + + Copy-Dependencies -Binary $source + } +} + +Copy-Dependencies -Binary $Executable