Files
cpd-cli-updater/README.md
Michael Schapira 675216e34b Initial commit: cpd-cli auto-update script
- update-cpd-cli.sh: automate CPD CLI version updates
- README.md: project documentation
- .gitignore: standard ignores
2026-04-03 18:18:29 +00:00

107 lines
2.4 KiB
Markdown

# cpd-cli Update Automation Script
Automate [IBM cpd-cli](https://github.com/IBM/cpd-cli) version updates with a single script!
## Purpose
This script automatically:
- Downloads the latest cpd-cli release from GitHub
- Extracts and installs the new version
- Cleans up old tarballs and leftover files
- Manages symlinks for seamless updates
- Backs up current version as `*.OLD` for rollback
## Requirements
- Bash 4+ or compatible shell
- `curl` for downloading
- `tar` for extraction
- `sudo` for system-wide installation (or run as root)
- `jq` (optional, for faster GitHub API parsing)
## Usage
```bash
# Make executable
chmod +x update-cpd-cli.sh
# Run update script
./update-cpd-cli.sh
# Output:
[INFO] Fetching latest release from GitHub API...
[INFO] Downloading cpd-cli-linux-EE-14.3.2.tgz...
[INFO] Installing cpd-cli 14.3.2...
[SUCCESS] Successfully installed cpd-cli 14.3.2
[UPDATE] Update completed successfully!
```
## Configuration
You can override defaults via environment variables:
```bash
# Override installation path
export CPD_CLI_PATH=/custom/installdir
# Override GitHub base URL
export CPD_SOURCE=https://github.com/corp-softy/cpd-cli/releases
# Run with custom paths
./update-cpd-cli.sh
```
## What Happens
1. **Detects latest version** from GitHub Releases API
2. **Downloads** the new release tarball (with retries)
3. **Backs up** current installation as `*.OLD`
4. **Extracts** new version to temp directory
5. **Removes** old symlinks
6. **Installs** new version and creates symlinks
7. **Cleans up** old tarballs
8. **Verifies** installation
## Rollback
If you need to rollback:
```bash
# Reinstall version from OLD directory
mv /path/to/cpd-cli-linux-EE.X.X.X-OLD /path/to/new/name
# Or:
sudo ln -s /path/to/cpd-cli-linux-EE.X.X.X-OLD/* /usr/local/bin/
```
## Development
```bash
# Make changes
vim update-cpd-cli.sh
# Test locally
./update-cpd-cli.sh
# Commit changes
git add .
git commit -m "update-cpd-cli.sh: some improvement"
# Push to remote
./scripts/push_to_gitea.sh
```
## License
Part of IBM Watson CPD tooling. See GitHub repo for full licensing.
## Contributing
Feel free to submit PRs for improvements!
The script is production-quality but always room for improvement.
---
**Maintained by Michael Schapira** • IBM
[![GitHub Release](https://img.shields.io/badge/release-latest-blue.svg)](https://github.com/IBM/cpd-cli/releases/latest)