Skip to content

Commit e678086

Browse files
committed
Add docs
1 parent 2ee4651 commit e678086

File tree

3 files changed

+109
-10
lines changed

3 files changed

+109
-10
lines changed

docs/installing-nightly.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ On the details page, select the artifact for your platform:
4949
Extract the archive and place the `dsc` executable (or `dsc.exe` on Windows) in a directory in
5050
your PATH.
5151

52-
## Advanced Script Options
52+
## Advanced script options
5353

5454
### DSC CLI
5555

sharedScripts/install_cli_nightly.ps1

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,10 @@ if ($null -eq (Get-Command "gh" -ErrorAction SilentlyContinue)) {
1212
throw "Please install the GitHub CLI: https://cli.github.com/"
1313
}
1414

15-
$platform = if ($IsWindows) { "windows" } elseif ($IsLinux) { "linux" } elseif ($IsMacOS) { "macos" } else { throw "Unsupported OS" }
16-
1715
# Fetch
1816
if (!$InstallPath) {
19-
# Default install paths by platform
20-
if ($IsWindows) {
21-
$InstallPath = [System.IO.Path]::combine($env:LOCALAPPDATA, "dsc")
22-
} else {
23-
$InstallPath = [System.IO.Path]::combine($HOME, ".dsc", "bin")
24-
}
17+
# Default install for Windows
18+
$InstallPath = [System.IO.Path]::combine($env:LOCALAPPDATA, "dsc")
2519
}
2620
if (!$Repo) {
2721
$Repo = "PowerShell/DSC"
@@ -54,7 +48,7 @@ $installationFiles = Join-Path $tmpDir 'bin' 'debug'
5448
New-Item -ItemType Directory -Force -Path $InstallPath | Out-Null
5549
Move-Item -Path "$installationFiles/*" -Destination $InstallPath -Force -ErrorAction Ignore
5650

57-
$dscExe = if ($IsWindows) { Join-Path $InstallPath "dsc.exe" } else { Join-Path $InstallPath "dsc" }
51+
$dscExe = Join-Path $InstallPath "dsc.exe"
5852
$versionStdout = & $dscExe --version; if(!$?) { throw }
5953
$version = $versionStdout -replace 'dsc ', ''
6054
Write-Host "Installed DSC CLI $version from https://github.com/$Repo/actions/runs/$RunId to $InstallPath"
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Default values
5+
INSTALL_PATH=""
6+
REPO="PowerShell/DSC"
7+
BRANCH="main"
8+
RUN_ID=""
9+
10+
# Parse command line arguments
11+
while [[ $# -gt 0 ]]; do
12+
case $1 in
13+
--install-path)
14+
INSTALL_PATH="$2"
15+
shift 2
16+
;;
17+
--repo)
18+
REPO="$2"
19+
shift 2
20+
;;
21+
--branch)
22+
BRANCH="$2"
23+
shift 2
24+
;;
25+
--run-id)
26+
RUN_ID="$2"
27+
shift 2
28+
;;
29+
*)
30+
echo "Unknown option: $1"
31+
exit 1
32+
;;
33+
esac
34+
done
35+
36+
# Check for GitHub CLI
37+
if ! command -v gh &> /dev/null; then
38+
echo "Error: GitHub CLI (gh) is not installed."
39+
echo "Please install it from: https://cli.github.com/"
40+
exit 1
41+
fi
42+
43+
# Detect platform
44+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
45+
PLATFORM="linux"
46+
elif [[ "$OSTYPE" == "darwin"* ]]; then
47+
PLATFORM="macos"
48+
else
49+
echo "Error: Unsupported OS: $OSTYPE"
50+
exit 1
51+
fi
52+
53+
# Set default install path if not provided
54+
if [[ -z "$INSTALL_PATH" ]]; then
55+
INSTALL_PATH="$HOME/.dsc/bin"
56+
fi
57+
58+
# Fetch run ID if not provided
59+
if [[ -z "$RUN_ID" ]]; then
60+
echo "Fetching latest successful build for branch '$BRANCH'..."
61+
RUN_ID=$(gh run list -R "$REPO" --branch "$BRANCH" --workflow rust --status success -L 1 --json databaseId -q ".[0].databaseId")
62+
63+
if [[ -z "$RUN_ID" ]]; then
64+
echo "Error: Failed to find a successful build to install from"
65+
exit 1
66+
fi
67+
fi
68+
69+
echo "Downloading artifacts from run $RUN_ID..."
70+
71+
# Create temporary directory
72+
TMP_DIR=$(mktemp -d)
73+
trap "rm -rf $TMP_DIR" EXIT
74+
75+
# Download artifact
76+
gh run download -R "$REPO" "$RUN_ID" -n "${PLATFORM}-bin" --dir "$TMP_DIR"
77+
78+
# Find the tar file
79+
TAR_FILE=$(find "$TMP_DIR" -name "*.tar.gz" -o -name "*.tgz" | head -n 1)
80+
81+
if [[ -z "$TAR_FILE" ]]; then
82+
echo "Error: Failed to find downloaded artifact"
83+
exit 1
84+
fi
85+
86+
# Extract
87+
echo "Extracting archive..."
88+
tar -xzf "$TAR_FILE" -C "$TMP_DIR"
89+
90+
# Install
91+
echo "Installing to $INSTALL_PATH..."
92+
mkdir -p "$INSTALL_PATH"
93+
mv "$TMP_DIR/dsc" "$INSTALL_PATH/dsc"
94+
chmod +x "$INSTALL_PATH/dsc"
95+
96+
# Get version
97+
VERSION=$("$INSTALL_PATH/dsc" --version 2>&1 || echo "unknown")
98+
99+
echo ""
100+
echo "Successfully installed DSC to $INSTALL_PATH/dsc"
101+
echo "Version: $VERSION"
102+
echo "From: https://github.com/$REPO/actions/runs/$RUN_ID"
103+
echo ""
104+
echo "To use DSC, add the following to your PATH:"
105+
echo " export PATH=\"\$PATH:$INSTALL_PATH\""

0 commit comments

Comments
 (0)