โจ Automate your GitHub repository tagging process with a single command! โจ
add-github-topics is a powerful and lightweight Python CLI tool designed to help developers and maintainers programmatically manage their GitHub repository topics. Whether you are managing a single project or automating a large-scale migration, this tool simplifies the process of adding descriptive tags to your repositories.
Topics are essential for SEO on GitHub, making your projects more discoverable to the community! ๐โจ
- ๐ Smart Appending: Fetches existing topics first to avoid accidental overwrites.
- ๐ฏ Zero Config Defaults: Automatically detects username and repository name from your local git environment.
- ๐ Secure Token Handling: Supports
.envfiles and environment variables for managing your GitHub Personal Access Token (PAT). - ๐ GitHub CLI Integration: Seamlessly inherits credentials from logged-in
gh auth token. - ๐ Global CLI: Once installed, run
add-github-topicfrom any terminal or directory. - ๐ป Cross-Platform: Works smoothly on Windows ๐ช, macOS ๐, and Linux ๐ง.
Install the tool directly from PyPI using pip:
pip install add-github-topicsSet your GitHub token using any of the following methods (listed in order of priority):
-
๐ป CLI Argument:
add-github-topic python --token ghp_your_token_here
-
๐ Environment Variable:
- ๐ง Bash / Zsh:
export GITHUB_TOKEN=ghp_your_token_here - ๐ช PowerShell:
$env:GITHUB_TOKEN = "ghp_your_token_here"
- ๐ง Bash / Zsh:
-
๐
.envFile: Create a.envfile in your repository or home directory:GITHUB_TOKEN=ghp_your_token_here
(Also supports
GH_TOKENand legacyADMIN_TOKEN) -
๐ GitHub CLI (
gh): If you already have GitHub CLI installed and authenticated (gh auth login), the CLI automatically falls back togh auth tokenwith zero manual configuration!
Run the command from within any local git repository:
add-github-topic pythonInstall the latest release directly from PyPI:
pip install add-github-topicsSet your GitHub token using any of the following methods (listed in order of evaluation priority):
- ๐ป CLI Flag:
add-github-topic python --token ghp_your_token_here
- ๐ Environment Variable:
- ๐ง Linux / macOS (Bash/Zsh):
export GITHUB_TOKEN=ghp_your_token_here - ๐ช Windows (PowerShell):
$env:GITHUB_TOKEN = "ghp_your_token_here"
- ๐ง Linux / macOS (Bash/Zsh):
- ๐ Local
.envFile: Create a.envfile in your repository or home directory:(SupportsGITHUB_TOKEN=ghp_your_token_here
GITHUB_TOKEN,GH_TOKEN, andADMIN_TOKEN) - ๐ GitHub CLI Integration:
If logged into the GitHub CLI (
gh),add-github-topicautomatically obtains credentials viagh auth token.
# ๐ท๏ธ Add single or multiple topics
add-github-topic python machine-learning devops
# ๐ List current repository topics
add-github-topic --list
# ๐๏ธ Remove existing topics
add-github-topic --remove legacy-tag
# ๐ฏ Target a specific remote repository
add-github-topic python --owner ishandutta2007 --repo awesome-projectWe warmly welcome contributions to add-github-topics! ๐
-
๐ฅ Clone the Repository:
git clone https://github.com/ishandutta2007/add-github-topics.git cd add-github-topics -
๐ Set Up Virtual Environment:
python -m venv venv # ๐ง On Linux/macOS: source venv/bin/activate # ๐ช On Windows: .\venv\Scripts\activate
-
๐ฆ Install Editable Package:
pip install -e .
The codebase is organized into decoupled, modular components under src/add_github_topics/:
- ๐ฎ
cli.py: Main CLI orchestration and execution entrypoint. - ๐งฉ
parser.py: Command-line interface definitions, flags, and argument parsing. - ๐
api.py: GitHub REST API operations (fetching, updating, adding, removing, and listing topics). - ๐ฟ
git.py: Local git repository detection and remote URL resolution. - ๐
auth.py: Authentication token resolution (CLI flags,.env, env vars,gh auth token). - ๐งผ
utils.py: Topic validation and sanitization utilities.
Please follow PEP 8 style guidelines and test changes locally before submitting a PR. โจ
The project uses GitHub Actions with PyPI Trusted Publishing (OIDC) for automated releases. ๐
-
๐ท๏ธ Version Bump Workflow (Automated on Push):
- Whenever you increment the version in
pyproject.toml(e.g.version = "0.2.2") and push your commit tomainormaster:[project] version = "0.2.2"
- The
.github/workflows/publish.ymlworkflow triggers automatically. - It builds the package source & wheel and attempts to publish to PyPI.
- Idempotency (
skip-existing: true): If the version has already been published to PyPI, the publish action skips safely without failing.
- Whenever you increment the version in
-
๐ Git Tag Workflow:
- Tagged releases (e.g.
v0.2.2) pushed to GitHub will also trigger auto-publishing:git tag v0.2.2 git push origin v0.2.2
- Tagged releases (e.g.
-
โก Manual Trigger (
workflow_dispatch):- You can also trigger a release manually via the Actions tab in GitHub.
- ๐ Configure PyPI Trusted Publisher for repository
ishandutta2007/add-github-topics. - ๐ก๏ธ Create environment
pypiunder GitHub Repository Settings -> Environments.
Thank you for using and exploring add-github-topics! ๐
If this project saved you time or made repository tagging effortless, please consider supporting its development:
- โญ Star this repository on GitHub to show your appreciation and help others discover it!
- ๐ด Fork and share it with fellow developers and open-source communities.
- โ Buy me a coffee / Sponsor: Support ongoing maintenance and new features through the GitHub Sponsors Dashboard.
Every bit of support helps keep open-source projects thriving! โจ
Made with โค๏ธ by Ishan Dutta