Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows PowerShell installer script and update README #10

Merged
merged 8 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ jobs:
target: aarch64-apple-darwin
artifact_name: stop-nagging
asset_name: stop-nagging-aarch64-apple-darwin.tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: stop-nagging.exe
asset_name: stop-nagging-x86_64-pc-windows-msvc.zip
- os: windows-latest
target: aarch64-pc-windows-msvc
artifact_name: stop-nagging.exe
asset_name: stop-nagging-aarch64-pc-windows-msvc.zip
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -84,7 +92,11 @@ jobs:
staging="stop-nagging-${{ matrix.target }}"
mkdir -p "$staging"
cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" "$staging/"
tar czf "${{ matrix.asset_name }}" "$staging"
if [[ "${{ matrix.asset_name }}" == *.zip ]]; then
7z a "${{ matrix.asset_name }}" "$staging"
else
tar czf "${{ matrix.asset_name }}" "$staging"
fi
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -112,10 +124,12 @@ jobs:
if: steps.semantic.outputs.new_release_published == 'true'
run: |
mv artifacts/*/*.tar.gz ./
mv artifacts/*/*.zip ./
- name: Update Release with Artifacts
if: steps.semantic.outputs.new_release_published == 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.semantic.outputs.new_release_version }}
files: |
*.tar.gz
*.zip
41 changes: 41 additions & 0 deletions .github/workflows/installation_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Installation Test

on:
release:
types: [published]
workflow_dispatch:

jobs:
test-linux-install:
name: Test Linux Installation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Test installation script
run: |
curl -fsSL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref_name }}/scripts/install_stop_nagging.sh | bash

- name: Verify installation
run: |
stop-nagging --version
# Test basic functionality
stop-nagging check

test-windows-install:
name: Test Windows Installation
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

- name: Test installation script
shell: powershell
run: |
iwr https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref_name }}/scripts/install_stop_nagging.ps1 -useb | iex

- name: Verify installation
shell: powershell
run: |
stop-nagging --version
# Test basic functionality
stop-nagging check
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,23 @@ Head over to [`tools.yaml`](tools.yaml) to see the list of supported tools.

## Installation

### Quick Install
### Quick Install (Linux/macOS)

```bash
curl -s https://raw.githubusercontent.com/bodo-run/stop-nagging/main/scripts/install_stop_nagging.sh | bash
```

Then add `~/.local/bin` to your PATH if not already.

### Quick Install (Windows)

1. Download and run the PowerShell installer script:
```powershell
# Example in PowerShell
iwr https://raw.githubusercontent.com/bodo-run/stop-nagging/main/scripts/install_stop_nagging.ps1 -UseBasicParsing | iex
```
2. If needed, add the installation directory (default: `$HOME\.local\bin`) to your PATH.

### From Source

1. Ensure Rust is installed
Expand Down
90 changes: 90 additions & 0 deletions scripts/install_stop_nagging.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# install_stop_nagging.ps1
# Install Stop-Nagging on Windows via PowerShell
param(
[string]$InstallDir = "$HOME\.local\bin"
)

# Exit on error
$ErrorActionPreference = "Stop"

Write-Host "Stop-Nagging Windows Installer"

if (!(Test-Path -Path $InstallDir)) {
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
}

Write-Host "Selected install directory: $InstallDir"

# Detect architecture
$arch = $ENV:PROCESSOR_ARCHITECTURE
switch ($arch) {
"AMD64" { $target = "x86_64-pc-windows-msvc" }
"ARM64" { $target = "aarch64-pc-windows-msvc" }
default {
Write-Host "Unsupported or unknown architecture: $arch"
Write-Host "Please build from source or check for a compatible artifact."
exit 1
}
}

$repoOwner = "bodo-run"
$repoName = "stop-nagging"
$assetName = "stop-nagging-$target.zip"

Write-Host "OS/ARCH => Windows / $arch"
Write-Host "Asset name => $assetName"

Write-Host "Fetching latest release info from GitHub..."
$releasesUrl = "https://api.github.com/repos/$repoOwner/$repoName/releases/latest"
try {
$releaseData = Invoke-RestMethod -Uri $releasesUrl
} catch {
Write-Host "Failed to fetch release info from GitHub."
Write-Host "Please build from source or check back later."
exit 0
}

# Find the asset download URL
$asset = $releaseData.assets | Where-Object { $_.name -eq $assetName }
if (!$asset) {
Write-Host "Failed to find an asset named $assetName in the latest release."
Write-Host "Check that your OS/ARCH is built or consider building from source."
exit 0
}

$downloadUrl = $asset.browser_download_url
Write-Host "Downloading from: $downloadUrl"

$zipPath = Join-Path $env:TEMP $assetName
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipPath -UseBasicParsing

Write-Host "Extracting archive..."
$extractDir = Join-Path $env:TEMP "stop-nagging-$($arch)"
if (Test-Path $extractDir) {
Remove-Item -Recurse -Force $extractDir
}
Expand-Archive -Path $zipPath -DestinationPath $extractDir

Write-Host "Moving binary to $InstallDir..."
$binaryPath = Join-Path $extractDir "stop-nagging-$target" "stop-nagging.exe"
if (!(Test-Path $binaryPath)) {
Write-Host "stop-nagging.exe not found in the extracted folder."
exit 1
}
Move-Item -Force $binaryPath $InstallDir

Write-Host "Cleanup temporary files..."
Remove-Item -Force $zipPath
Remove-Item -Recurse -Force $extractDir

Write-Host "Installation complete!"

# Check if $InstallDir is in PATH
$pathDirs = $ENV:PATH -split ";"
if ($pathDirs -notcontains (Resolve-Path $InstallDir)) {
Write-Host "NOTE: $InstallDir is not in your PATH. Add it by running something like:"
Write-Host "`$env:Path += `";$(Resolve-Path $InstallDir)`""
Write-Host "Or update your system's environment variables to persist this."
}

Write-Host "Now you can run: stop-nagging --help"
Loading
Loading