Skip to content

Commit d1742ab

Browse files
chore: Update releaser instructions/installation (#536)
* chore: Update releaser instructions/installation installation in v3 is not user friendly - do it automagically * Fix broken test
1 parent f07bf43 commit d1742ab

4 files changed

Lines changed: 90 additions & 29 deletions

File tree

.goreleaser.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ release:
101101
102102
```bash
103103
# Linux/macOS
104-
curl -sfL https://raw.githubusercontent.com/go-nv/goenv/master/install.sh | bash
104+
curl -sfL https://raw.githubusercontent.com/go-nv/goenv/main/install.sh | bash
105+
106+
# Windows (PowerShell)
107+
irm https://raw.githubusercontent.com/go-nv/goenv/main/install.ps1 | iex
105108
106109
# Or download directly:
107110
# Linux (x64): goenv_{{ .Version }}_linux_amd64.tar.gz

cmd/diagnostics/doctor_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,8 +1424,8 @@ func TestCheckSystemGoVersion(t *testing.T) {
14241424
currentVersion: "system",
14251425
hasSystemGo: true,
14261426
systemVersion: "1.26.2",
1427-
expectedStatus: StatusOK,
1428-
shouldContain: "Using system Go 1.26.2",
1427+
expectedStatus: StatusWarning, // Changed from StatusOK - version 1.26.2 is outdated (1.26.3 is latest)
1428+
shouldContain: "System Go 1.26.2 is outdated",
14291429
},
14301430
{
14311431
name: "Using system Go, but not found",

install.ps1

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# goenv installer script for Windows PowerShell
2-
# Usage: iwr -useb https://raw.githubusercontent.com/go-nv/goenv/master/install.ps1 | iex
2+
# Usage: iwr -useb https://raw.githubusercontent.com/go-nv/goenv/main/install.ps1 | iex
33

44
$ErrorActionPreference = "Stop"
55

@@ -112,7 +112,44 @@ function Install-Binary {
112112
}
113113
}
114114

115-
# Print setup instructions
115+
# Auto-configure PowerShell profile
116+
function Setup-PowerShellProfile {
117+
$profilePath = $PROFILE
118+
119+
# Create profile directory if it doesn't exist
120+
$profileDir = Split-Path -Parent $profilePath
121+
if (-not (Test-Path $profileDir)) {
122+
New-Item -ItemType Directory -Path $profileDir -Force | Out-Null
123+
}
124+
125+
# Create profile file if it doesn't exist
126+
if (-not (Test-Path $profilePath)) {
127+
New-Item -ItemType File -Path $profilePath -Force | Out-Null
128+
}
129+
130+
# Check if goenv is already configured
131+
$profileContent = Get-Content $profilePath -Raw -ErrorAction SilentlyContinue
132+
if ($profileContent -and $profileContent -match "goenv init") {
133+
Write-ColorOutput Green "goenv is already configured in $profilePath"
134+
return
135+
}
136+
137+
# Add goenv configuration with comment marker
138+
Write-ColorOutput Yellow "Adding goenv configuration to $profilePath..."
139+
140+
$goenvConfig = @"
141+
142+
# goenv - Go version manager (auto-configured by installer)
143+
`$env:GOENV_ROOT = "`$HOME\.goenv"
144+
`$env:PATH = "`$env:GOENV_ROOT\bin;`$env:PATH"
145+
& goenv init - | Invoke-Expression
146+
"@
147+
148+
Add-Content -Path $profilePath -Value $goenvConfig
149+
Write-ColorOutput Green "PowerShell profile configured successfully!"
150+
}
151+
152+
# Print setup completion message
116153
function Show-Instructions {
117154
$profilePath = $PROFILE
118155

@@ -121,22 +158,11 @@ function Show-Instructions {
121158
Write-ColorOutput Green "Installation complete!"
122159
Write-ColorOutput Green "=============================================="
123160
Write-Output ""
124-
Write-ColorOutput Yellow "Add the following to your PowerShell profile:"
125-
Write-Output " $profilePath"
126-
Write-Output ""
127-
Write-Output " `$env:GOENV_ROOT = \"`$HOME\.goenv\""
128-
Write-Output " `$env:PATH = \"`$env:GOENV_ROOT\bin;`$env:PATH\""
129-
Write-Output " & goenv init - | Invoke-Expression"
130-
Write-Output ""
131-
Write-ColorOutput Yellow "Quick setup command (copy and paste):"
132-
Write-Output ""
133-
Write-Output " `$env:GOENV_ROOT = \"`$HOME\.goenv\""
134-
Write-Output " `$env:PATH = \"`$env:GOENV_ROOT\bin;`$env:PATH\""
135-
Write-Output " & goenv init - | Invoke-Expression"
136-
Write-Output ""
137-
Write-ColorOutput Yellow "Then reload your profile:"
161+
Write-ColorOutput Yellow "To start using goenv, reload your profile:"
138162
Write-Output " . `$PROFILE"
139163
Write-Output ""
164+
Write-ColorOutput Yellow "Or restart your PowerShell session"
165+
Write-Output ""
140166
Write-ColorOutput Yellow "Quick start:"
141167
Write-Output " goenv install 1.22.0 # Install Go 1.22.0"
142168
Write-Output " goenv global 1.22.0 # Set as default"
@@ -158,6 +184,7 @@ function Main {
158184

159185
$version = Get-LatestVersion
160186
Install-Binary -Version $version -Arch $arch
187+
Setup-PowerShellProfile
161188
Show-Instructions
162189
}
163190

install.sh

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
# goenv installer script for Linux/macOS
3-
# Usage: curl -sfL https://raw.githubusercontent.com/go-nv/goenv/master/install.sh | bash
3+
# Usage: curl -sfL https://raw.githubusercontent.com/go-nv/goenv/main/install.sh | bash
44

55
set -e
66

@@ -125,7 +125,44 @@ install_binary() {
125125
echo -e "${GREEN}✓ goenv installed successfully!${NC}"
126126
}
127127

128-
# Print setup instructions
128+
# Auto-configure shell profile
129+
setup_shell_profile() {
130+
local shell_config
131+
132+
# Detect shell config file
133+
if [ -n "$BASH_VERSION" ]; then
134+
if [ -f "$HOME/.bash_profile" ]; then
135+
shell_config="$HOME/.bash_profile"
136+
else
137+
shell_config="$HOME/.bashrc"
138+
fi
139+
elif [ -n "$ZSH_VERSION" ]; then
140+
shell_config="$HOME/.zshrc"
141+
else
142+
shell_config="$HOME/.profile"
143+
fi
144+
145+
# Check if goenv is already configured
146+
if [ -f "$shell_config" ] && grep -q "goenv init" "$shell_config"; then
147+
echo -e "${GREEN}✓ goenv is already configured in ${shell_config}${NC}"
148+
return 0
149+
fi
150+
151+
# Add goenv configuration with markers
152+
echo -e "${YELLOW}Adding goenv configuration to ${shell_config}...${NC}"
153+
154+
cat >> "$shell_config" << 'EOF'
155+
156+
# goenv - Go version manager (auto-configured by installer)
157+
export GOENV_ROOT="$HOME/.goenv"
158+
export PATH="$GOENV_ROOT/bin:$PATH"
159+
eval "$(goenv init -)"
160+
EOF
161+
162+
echo -e "${GREEN}✓ Shell profile configured successfully!${NC}"
163+
}
164+
165+
# Print setup completion message
129166
print_instructions() {
130167
local shell_config
131168

@@ -147,14 +184,7 @@ print_instructions() {
147184
echo -e "${GREEN}Installation complete!${NC}"
148185
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
149186
echo ""
150-
echo -e "${YELLOW}Add the following to your shell configuration:${NC}"
151-
echo -e " ${shell_config}"
152-
echo ""
153-
echo ' export GOENV_ROOT="$HOME/.goenv"'
154-
echo ' export PATH="$GOENV_ROOT/bin:$PATH"'
155-
echo ' eval "$(goenv init -)"'
156-
echo ""
157-
echo -e "${YELLOW}Then reload your shell:${NC}"
187+
echo -e "${YELLOW}To start using goenv, reload your shell:${NC}"
158188
echo " exec \$SHELL"
159189
echo ""
160190
echo -e "${YELLOW}Or source your config now:${NC}"
@@ -179,6 +209,7 @@ main() {
179209
detect_platform
180210
get_latest_version
181211
install_binary
212+
setup_shell_profile
182213
print_instructions
183214
}
184215

0 commit comments

Comments
 (0)