Skip to content

Commit 6cd5114

Browse files
authored
fix: use tags for codex installation scripts (#52)
* feat: update the codex install scripts to use a tag * update readme * fix the ps script
1 parent 3e4c2d1 commit 6cd5114

3 files changed

Lines changed: 44 additions & 21 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ Run the `claude` command to start the agent, then follow these steps:
7878

7979
**macOS / Linux:**
8080
```bash
81-
curl -sSL https://raw.githubusercontent.com/gemini-cli-extensions/data-agent-kit-starter-pack/0.1.1/codex-install.sh | bash
81+
curl -sSL https://raw.githubusercontent.com/gemini-cli-extensions/data-agent-kit-starter-pack/0.1.1/codex-install.sh | bash -s -- 0.1.1
8282
```
8383

8484
**Windows:**
8585
```powershell
86-
irm https://raw.githubusercontent.com/gemini-cli-extensions/data-agent-kit-starter-pack/0.1.1/codex-install.ps1 | iex
86+
$env:CODEX_TAG="0.1.1"; irm https://raw.githubusercontent.com/gemini-cli-extensions/data-agent-kit-starter-pack/0.1.1/codex-install.ps1 | iex
8787
```
8888

8989
2. **Install the plugin in Codex:**

codex-install.ps1

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
param(
16+
[Parameter(Mandatory = $false)]
17+
[string]$Tag
18+
)
19+
20+
if (-not $Tag -and $env:CODEX_TAG) {
21+
$Tag = $env:CODEX_TAG
22+
}
23+
1524
$ErrorActionPreference = "Stop"
1625

1726
$pluginName = "data-agent-kit-starter-pack"
@@ -56,25 +65,26 @@ Write-Host "--- $pluginName Installer for Codex ---"
5665
New-Item -ItemType Directory -Force -Path $pluginsRoot | Out-Null
5766

5867
if (Test-Path $installDir) {
59-
try {
60-
& git -C $installDir rev-parse --is-inside-work-tree 2>$null | Out-Null
61-
} catch {
62-
}
68+
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
69+
$backupName = "$pluginName" + "_backup_" + $timestamp
70+
$backupPath = Join-Path (Split-Path $installDir) $backupName
71+
Write-Host "Backing up existing plugin to $backupPath..."
72+
Rename-Item -LiteralPath $installDir -NewName $backupName
73+
Write-Host "Notice: Your previous installation has been backed up to $backupPath."
74+
Write-Host "You can delete it if you do not need it."
75+
}
6376

64-
if ($LASTEXITCODE -eq 0) {
65-
Write-Host "Updating existing plugin at $installDir..."
66-
Invoke-GitCommand -Arguments @("-C", $installDir, "pull")
67-
} else {
68-
Write-Host "Existing directory at $installDir is not a valid git checkout. Reinstalling..."
69-
Remove-Item -LiteralPath $installDir -Recurse -Force
70-
Write-Host "Cloning plugin to $installDir..."
71-
Invoke-GitCommand -Arguments @("clone", $repoUrl, $installDir)
72-
}
77+
if ($Tag) {
78+
Write-Host "Cloning plugin version $Tag to $installDir..."
79+
Invoke-GitCommand -Arguments @("clone", "--depth", "1", "--branch", $Tag, $repoUrl, $installDir)
7380
} else {
74-
Write-Host "Cloning plugin to $installDir..."
75-
Invoke-GitCommand -Arguments @("clone", $repoUrl, $installDir)
81+
Write-Host "Cloning plugin default branch to $installDir..."
82+
Invoke-GitCommand -Arguments @("clone", "--depth", "1", $repoUrl, $installDir)
7683
}
7784

85+
Write-Host "Removing git metadata..."
86+
Remove-Item -LiteralPath (Join-Path $installDir ".git") -Recurse -Force
87+
7888
if (-not (Test-Path $marketplaceFile)) {
7989
Write-Host "Creating new personal marketplace..."
8090
Write-TextFileNoBom -Path $marketplaceFile -Content '{"name":"personal","plugins":[]}'

codex-install.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
set -e
1717

18+
TAG=$1
19+
1820
PLUGIN_NAME="data-agent-kit-starter-pack"
1921
REPO_URL="https://github.com/gemini-cli-extensions/data-agent-kit-starter-pack"
2022
INSTALL_DIR="$HOME/.agents/plugins/$PLUGIN_NAME"
@@ -25,13 +27,24 @@ echo "--- $PLUGIN_NAME Installer for Codex ---"
2527
# 1. Download/Update Plugin Content
2628
mkdir -p "$HOME/.agents/plugins"
2729
if [ -d "$INSTALL_DIR" ]; then
28-
echo "Updating existing plugin at $INSTALL_DIR..."
29-
cd "$INSTALL_DIR" && git pull
30+
BACKUP_DIR="${INSTALL_DIR}_backup_$(date +%Y%m%d_%H%M%S)"
31+
echo "Backing up existing plugin to $BACKUP_DIR..."
32+
mv "$INSTALL_DIR" "$BACKUP_DIR"
33+
echo "Notice: Your previous installation has been backed up to $BACKUP_DIR."
34+
echo "You can delete it if you do not need it."
35+
fi
36+
37+
if [ -n "$TAG" ]; then
38+
echo "Cloning plugin version $TAG to $INSTALL_DIR..."
39+
git clone --depth 1 --branch "$TAG" "$REPO_URL" "$INSTALL_DIR"
3040
else
31-
echo "Cloning plugin to $INSTALL_DIR..."
32-
git clone "$REPO_URL" "$INSTALL_DIR"
41+
echo "Cloning plugin default branch to $INSTALL_DIR..."
42+
git clone --depth 1 "$REPO_URL" "$INSTALL_DIR"
3343
fi
3444

45+
echo "Removing git metadata..."
46+
rm -rf "$INSTALL_DIR/.git"
47+
3548
# 2. Register with Codex Marketplace
3649
if [ ! -f "$MARKETPLACE_FILE" ]; then
3750
echo "Creating new personal marketplace..."

0 commit comments

Comments
 (0)