@@ -42,12 +42,43 @@ runs:
4242
4343 if [[ "$DECISION" == "skip" ]]; then
4444 echo "Skipping installation on Linux (exact version present)."
45+ exit 0
46+ fi
47+
48+ # -------------------------------------------------------------------------------------------------
49+ # Ubuntu/Debian install via APT package (preferred over legacy GitHub install script)
50+ # -------------------------------------------------------------------------------------------------
51+ if command -v apt-get >/dev/null; then
52+ echo "Using APT package manager (Debian/Ubuntu)…"
53+
54+ echo "Ensuring Microsoft package repo is configured…"
55+ if ! grep -q "packages.microsoft.com" /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null; then
56+ wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc > /dev/null
57+ DIST_CODENAME=$(lsb_release -cs)
58+ sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://packages.microsoft.com/ubuntu/$DIST_CODENAME/prod $DIST_CODENAME main"
59+ fi
60+
61+ echo "Updating package index…"
62+ sudo apt-get update -y
63+
64+ if [[ "$DECISION" != "install" ]]; then
65+ echo "Removing any existing PowerShell packages…"
66+ sudo apt-get remove -y powershell || true
67+ sudo apt-get autoremove -y || true
68+ fi
69+
70+ echo "Attempting to install exact version $REQUESTED_VERSION from repo…"
71+ EXACT_PKG=$(apt-cache madison powershell | awk '{print $3}' | grep -E "^${REQUESTED_VERSION}(-|$)" | head -n1 || true)
72+ if [[ -n "$EXACT_PKG" ]]; then
73+ sudo apt-get install -y powershell=$EXACT_PKG
74+ else
75+ echo "Exact version not found in repo; installing latest available package instead."
76+ sudo apt-get install -y powershell
77+ fi
78+
4579 else
46- echo "Uninstalling any existing PowerShell…"
47- sudo rm -rf /usr/local/microsoft/powershell || true
48- sudo rm -f /usr/local/bin/pwsh || true
49- echo "Installing PowerShell $REQUESTED_VERSION…"
50- curl -sSL https://aka.ms/install-powershell.sh | sudo bash -s -- -Version "$REQUESTED_VERSION" -Destination /usr/local
80+ echo "Unsupported Linux distribution (no apt-get). PowerShell install via package manager not implemented."
81+ exit 1
5182 fi
5283
5384 PWSH_PATH=$(command -v pwsh)
@@ -84,10 +115,9 @@ runs:
84115 echo "Skipping installation on macOS (exact version present)."
85116 else
86117 echo "Uninstalling any existing PowerShell…"
87- sudo rm -rf /usr/local/microsoft/powershell || true
88- sudo rm -f /usr/local/bin/pwsh || true
89- echo "Installing PowerShell $REQUESTED_VERSION…"
90- curl -sSL https://aka.ms/install-powershell.sh | sudo bash -s -- -Version "$REQUESTED_VERSION" -Destination /usr/local
118+ brew uninstall --ignore-dependencies --force powershell || true
119+ echo "Installing PowerShell $REQUESTED_VERSION via Homebrew…"
120+ brew install --cask powershell@$REQUESTED_VERSION || brew install --cask powershell
91121 fi
92122
93123 PWSH_PATH=$(command -v pwsh)
0 commit comments