mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 22:30:08 +00:00
58
.github/workflows/release-windows.yml
vendored
58
.github/workflows/release-windows.yml
vendored
@@ -1,10 +1,8 @@
|
||||
name: Build Windows Release
|
||||
name: Build Windows Prerelease
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*' # Trigger on version tags (e.g., v1.0.0)
|
||||
- 'V*.*.*' # Also support uppercase V (e.g., V1.0.0)
|
||||
- 'v*.*.*-windows' # Windows-specific releases
|
||||
- 'V*.*.*-windows' # Windows-specific releases (uppercase)
|
||||
workflow_dispatch: # Allow manual trigger
|
||||
@@ -19,7 +17,7 @@ permissions:
|
||||
|
||||
jobs:
|
||||
build-windows:
|
||||
name: Build Windows Release Artifacts
|
||||
name: Build Windows Prerelease Artifacts
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
@@ -31,7 +29,7 @@ jobs:
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.21'
|
||||
go-version: '1.24.6'
|
||||
|
||||
- name: Setup PowerShell
|
||||
shell: pwsh
|
||||
@@ -47,6 +45,7 @@ jobs:
|
||||
$version = "${{ github.event.inputs.version }}"
|
||||
} elseif ("${{ github.ref }}" -like "refs/tags/*") {
|
||||
$version = "${{ github.ref }}" -replace '^refs/tags/[Vv]', ''
|
||||
$version = $version -replace '-windows$', ''
|
||||
} else {
|
||||
$content = Get-Content mole.ps1 -Raw
|
||||
if ($content -match '\$script:MOLE_VER\s*=\s*"([^"]+)"') {
|
||||
@@ -79,6 +78,12 @@ jobs:
|
||||
shell: pwsh
|
||||
run: |
|
||||
& scripts\build-release.ps1 -Version ${{ steps.version.outputs.VERSION }}
|
||||
|
||||
- name: Prepare raw TUI binary assets
|
||||
shell: pwsh
|
||||
run: |
|
||||
Copy-Item "bin\analyze.exe" "release\analyze-windows-x64.exe" -Force
|
||||
Copy-Item "bin\status.exe" "release\status-windows-x64.exe" -Force
|
||||
|
||||
|
||||
- name: Build standalone EXE
|
||||
@@ -117,22 +122,47 @@ jobs:
|
||||
name: checksums
|
||||
path: release/SHA256SUMS.txt
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Upload TUI binaries
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tui-binaries
|
||||
path: |
|
||||
release/analyze-windows-x64.exe
|
||||
release/status-windows-x64.exe
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Collect release files
|
||||
id: release_files
|
||||
shell: pwsh
|
||||
run: |
|
||||
$files = @(
|
||||
"release/mole-${{ steps.version.outputs.VERSION }}-x64.zip",
|
||||
"release/analyze-windows-x64.exe",
|
||||
"release/status-windows-x64.exe",
|
||||
"release/SHA256SUMS.txt"
|
||||
)
|
||||
$optionalExe = "release/mole-${{ steps.version.outputs.VERSION }}-x64.exe"
|
||||
if (Test-Path $optionalExe) {
|
||||
$files += $optionalExe
|
||||
}
|
||||
"files<<EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
|
||||
$files | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
|
||||
"EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
|
||||
|
||||
- name: Create GitHub Release
|
||||
- name: Create GitHub Prerelease
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
release/mole-${{ steps.version.outputs.VERSION }}-x64.zip
|
||||
release/mole-${{ steps.version.outputs.VERSION }}-x64.exe
|
||||
release/SHA256SUMS.txt
|
||||
files: ${{ steps.release_files.outputs.files }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
prerelease: true
|
||||
generate_release_notes: true
|
||||
body: |
|
||||
## Windows System Maintenance Toolkit
|
||||
## Windows System Maintenance Toolkit (Prerelease)
|
||||
|
||||
**Download:** `mole-${{ steps.version.outputs.VERSION }}-x64.zip` (portable) or `.exe` (launcher)
|
||||
**TUI assets:** `analyze-windows-x64.exe` and `status-windows-x64.exe`
|
||||
|
||||
**Install:**
|
||||
```powershell
|
||||
@@ -140,7 +170,9 @@ jobs:
|
||||
cd C:\mole
|
||||
.\install.ps1
|
||||
```
|
||||
|
||||
|
||||
These assets are prerelease-only and do not affect the macOS stable release channel.
|
||||
|
||||
**Verify:** Check SHA256SUMS.txt for file integrity.
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
106
.github/workflows/release.yml
vendored
106
.github/workflows/release.yml
vendored
@@ -1,106 +0,0 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'W*' # Windows releases use W prefix (e.g., W1.0.0)
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build Windows
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.24.6"
|
||||
|
||||
- name: Build Binaries
|
||||
run: |
|
||||
cd cmd/analyze
|
||||
go build -ldflags="-s -w" -o analyze.exe .
|
||||
cd ../status
|
||||
go build -ldflags="-s -w" -o status.exe .
|
||||
shell: pwsh
|
||||
|
||||
- name: Create release package
|
||||
run: |
|
||||
# Create release directory
|
||||
New-Item -ItemType Directory -Force -Path release
|
||||
|
||||
# Copy binaries
|
||||
Copy-Item cmd/analyze/analyze.exe release/
|
||||
Copy-Item cmd/status/status.exe release/
|
||||
|
||||
# Copy PowerShell scripts
|
||||
Copy-Item mole.ps1 release/
|
||||
Copy-Item install.ps1 release/
|
||||
Copy-Item -Recurse bin release/
|
||||
Copy-Item -Recurse lib release/
|
||||
|
||||
# Copy docs
|
||||
Copy-Item README.md release/
|
||||
Copy-Item LICENSE release/
|
||||
|
||||
# Create zip
|
||||
Compress-Archive -Path release/* -DestinationPath mole-windows.zip
|
||||
shell: pwsh
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows-release
|
||||
path: mole-windows.zip
|
||||
retention-days: 5
|
||||
|
||||
release:
|
||||
name: Publish Release
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: windows-release
|
||||
|
||||
- name: Display downloaded files
|
||||
run: ls -la
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: mole-windows.zip
|
||||
generate_release_notes: true
|
||||
draft: false
|
||||
prerelease: false
|
||||
name: "Mole for Windows ${{ github.ref_name }}"
|
||||
body: |
|
||||
## Mole for Windows
|
||||
|
||||
Windows port of the Mole system maintenance toolkit.
|
||||
|
||||
### Installation
|
||||
|
||||
**Quick install:**
|
||||
```powershell
|
||||
irm https://raw.githubusercontent.com/tw93/Mole/windows/install.ps1 | iex
|
||||
```
|
||||
|
||||
**Manual install:**
|
||||
1. Download and extract `mole-windows.zip`
|
||||
2. Run `install.ps1`
|
||||
|
||||
### Features
|
||||
- Deep system cleanup (temp files, caches, logs)
|
||||
- Smart app uninstaller with leftover detection
|
||||
- Disk space analyzer (TUI)
|
||||
- System status monitor (TUI)
|
||||
- Developer artifact cleanup
|
||||
- System optimization
|
||||
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
@@ -54,21 +54,19 @@ jobs:
|
||||
|
||||
- name: Build Go binaries
|
||||
run: |
|
||||
cd cmd/analyze
|
||||
go build -o analyze.exe .
|
||||
cd ../status
|
||||
go build -o status.exe .
|
||||
go build -o bin/analyze.exe ./cmd/analyze/
|
||||
go build -o bin/status.exe ./cmd/status/
|
||||
shell: pwsh
|
||||
|
||||
- name: Verify binaries
|
||||
run: |
|
||||
if (Test-Path cmd/analyze/analyze.exe) {
|
||||
if (Test-Path bin/analyze.exe) {
|
||||
Write-Host "analyze.exe built successfully"
|
||||
} else {
|
||||
Write-Host "Failed to build analyze.exe"
|
||||
exit 1
|
||||
}
|
||||
if (Test-Path cmd/status/status.exe) {
|
||||
if (Test-Path bin/status.exe) {
|
||||
Write-Host "status.exe built successfully"
|
||||
} else {
|
||||
Write-Host "Failed to build status.exe"
|
||||
|
||||
196
.github/workflows/windows.yml
vendored
196
.github/workflows/windows.yml
vendored
@@ -1,196 +0,0 @@
|
||||
name: Windows CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, dev]
|
||||
paths:
|
||||
- 'windows/**'
|
||||
- '.github/workflows/windows.yml'
|
||||
pull_request:
|
||||
branches: [main, dev]
|
||||
paths:
|
||||
- 'windows/**'
|
||||
- '.github/workflows/windows.yml'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build & Test
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.24"
|
||||
cache-dependency-path: windows/go.sum
|
||||
|
||||
- name: Build Go binaries
|
||||
working-directory: windows
|
||||
run: |
|
||||
go build -o bin/analyze.exe ./cmd/analyze/
|
||||
go build -o bin/status.exe ./cmd/status/
|
||||
|
||||
- name: Run Go tests
|
||||
working-directory: windows
|
||||
run: go test -v ./...
|
||||
|
||||
- name: Validate PowerShell syntax
|
||||
shell: pwsh
|
||||
run: |
|
||||
$scripts = Get-ChildItem -Path windows -Filter "*.ps1" -Recurse
|
||||
$errors = @()
|
||||
foreach ($script in $scripts) {
|
||||
$parseErrors = $null
|
||||
$null = [System.Management.Automation.Language.Parser]::ParseFile(
|
||||
$script.FullName,
|
||||
[ref]$null,
|
||||
[ref]$parseErrors
|
||||
)
|
||||
if ($parseErrors) {
|
||||
Write-Host "ERROR: $($script.FullName)" -ForegroundColor Red
|
||||
foreach ($err in $parseErrors) {
|
||||
Write-Host " $($err.Message)" -ForegroundColor Red
|
||||
}
|
||||
$errors += $script.FullName
|
||||
} else {
|
||||
Write-Host "OK: $($script.Name)" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
if ($errors.Count -gt 0) {
|
||||
Write-Host "`n$($errors.Count) script(s) have syntax errors!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
pester:
|
||||
name: Pester Tests
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Pester
|
||||
shell: pwsh
|
||||
run: |
|
||||
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
|
||||
Install-Module -Name Pester -MinimumVersion 5.0.0 -Force -SkipPublisherCheck
|
||||
|
||||
- name: Run Pester tests
|
||||
shell: pwsh
|
||||
run: |
|
||||
Import-Module Pester -MinimumVersion 5.0.0
|
||||
|
||||
$config = New-PesterConfiguration
|
||||
$config.Run.Path = "windows/tests"
|
||||
$config.Run.Exit = $true
|
||||
$config.Output.Verbosity = "Detailed"
|
||||
$config.TestResult.Enabled = $true
|
||||
$config.TestResult.OutputPath = "windows/test-results.xml"
|
||||
$config.TestResult.OutputFormat = "NUnitXml"
|
||||
|
||||
Invoke-Pester -Configuration $config
|
||||
|
||||
- name: Upload test results
|
||||
uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: pester-results
|
||||
path: windows/test-results.xml
|
||||
|
||||
compatibility:
|
||||
name: Windows Compatibility
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-2022, windows-2019]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Test PowerShell 5.1
|
||||
shell: powershell
|
||||
run: |
|
||||
Write-Host "Testing on ${{ matrix.os }} with PowerShell $($PSVersionTable.PSVersion)"
|
||||
|
||||
# Test main entry point
|
||||
$result = & powershell -ExecutionPolicy Bypass -File "windows\mole.ps1" -ShowHelp 2>&1
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "mole.ps1 -ShowHelp failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Write-Host "✓ mole.ps1 works on ${{ matrix.os }}"
|
||||
|
||||
- name: Test command scripts
|
||||
shell: powershell
|
||||
run: |
|
||||
$commands = @("clean", "uninstall", "optimize", "purge", "analyze", "status")
|
||||
foreach ($cmd in $commands) {
|
||||
$scriptPath = "windows\bin\$cmd.ps1"
|
||||
if (Test-Path $scriptPath) {
|
||||
$result = & powershell -ExecutionPolicy Bypass -File $scriptPath -ShowHelp 2>&1
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "✗ $cmd.ps1 failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Write-Host "✓ $cmd.ps1 works"
|
||||
}
|
||||
}
|
||||
|
||||
security:
|
||||
name: Security Checks
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Check for unsafe patterns
|
||||
shell: pwsh
|
||||
run: |
|
||||
Write-Host "Checking for unsafe removal patterns..."
|
||||
|
||||
$unsafePatterns = @(
|
||||
"Remove-Item.*-Recurse.*-Force.*\\\$env:SystemRoot",
|
||||
"Remove-Item.*-Recurse.*-Force.*C:\\Windows",
|
||||
"Remove-Item.*-Recurse.*-Force.*C:\\Program Files"
|
||||
)
|
||||
|
||||
$files = Get-ChildItem -Path windows -Filter "*.ps1" -Recurse
|
||||
$issues = @()
|
||||
|
||||
foreach ($file in $files) {
|
||||
$content = Get-Content $file.FullName -Raw
|
||||
foreach ($pattern in $unsafePatterns) {
|
||||
if ($content -match $pattern) {
|
||||
$issues += "$($file.Name): matches unsafe pattern"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($issues.Count -gt 0) {
|
||||
Write-Host "Unsafe patterns found:" -ForegroundColor Red
|
||||
$issues | ForEach-Object { Write-Host " $_" -ForegroundColor Red }
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "✓ No unsafe patterns found" -ForegroundColor Green
|
||||
|
||||
- name: Verify protection checks
|
||||
shell: pwsh
|
||||
run: |
|
||||
Write-Host "Verifying protection logic..."
|
||||
|
||||
# Source file_ops to get Test-IsProtectedPath
|
||||
. windows\lib\core\base.ps1
|
||||
. windows\lib\core\file_ops.ps1
|
||||
|
||||
$protectedPaths = @(
|
||||
"C:\Windows",
|
||||
"C:\Windows\System32",
|
||||
"C:\Program Files",
|
||||
"C:\Program Files (x86)"
|
||||
)
|
||||
|
||||
foreach ($path in $protectedPaths) {
|
||||
if (-not (Test-ProtectedPath -Path $path)) {
|
||||
Write-Host "✗ $path should be protected!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Write-Host "✓ $path is protected" -ForegroundColor Green
|
||||
}
|
||||
Reference in New Issue
Block a user