Skip to content

About

add GitHub Topics ๐ŸŒŸ Star if you like it! ๐ŸŒŸ

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

24 Commits

Folders and files

Repository files navigation

Add GitHub Topics Banner

๐Ÿš€ Add GitHub Topics CLI ๐Ÿท๏ธ

โœจ Automate your GitHub repository tagging process with a single command! โœจ

Awesome Discord PyPI version Python versions License: MIT GitHub_Stars GitHub followers


๐ŸŒŸ Overview

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! ๐Ÿ”โœจ


โœจ Key Features

  • ๐Ÿ”„ 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 .env files 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-topic from any terminal or directory.
  • ๐Ÿ’ป Cross-Platform: Works smoothly on Windows ๐ŸชŸ, macOS ๐ŸŽ, and Linux ๐Ÿง.

๐Ÿš€ Quick Start

1. Installation ๐Ÿ“ฆ

Install the tool directly from PyPI using pip:

pip install add-github-topics

2. Configuration โš™๏ธ

Set your GitHub token using any of the following methods (listed in order of priority):

  1. ๐Ÿ’ป CLI Argument:

    add-github-topic python --token ghp_your_token_here
  2. ๐ŸŒ Environment Variable:

    • ๐Ÿง Bash / Zsh:
      export GITHUB_TOKEN=ghp_your_token_here
    • ๐ŸชŸ PowerShell:
      $env:GITHUB_TOKEN = "ghp_your_token_here"
  3. ๐Ÿ“„ .env File: Create a .env file in your repository or home directory:

    GITHUB_TOKEN=ghp_your_token_here

    (Also supports GH_TOKEN and legacy ADMIN_TOKEN)

  4. ๐Ÿ™ GitHub CLI (gh): If you already have GitHub CLI installed and authenticated (gh auth login), the CLI automatically falls back to gh auth token with zero manual configuration!

3. Basic Usage ๐Ÿ› ๏ธ

Run the command from within any local git repository:

add-github-topic python

๐Ÿ“š Documentation & Guides


๐Ÿ‘ค For Users ๐Ÿง‘โ€๐Ÿ’ป

1. Installation ๐Ÿ“ฆ

Install the latest release directly from PyPI:

pip install add-github-topics

2. Configuration โš™๏ธ

Set your GitHub token using any of the following methods (listed in order of evaluation priority):

  1. ๐Ÿ’ป CLI Flag:
    add-github-topic python --token ghp_your_token_here
  2. ๐ŸŒ Environment Variable:
    • ๐Ÿง Linux / macOS (Bash/Zsh):
      export GITHUB_TOKEN=ghp_your_token_here
    • ๐ŸชŸ Windows (PowerShell):
      $env:GITHUB_TOKEN = "ghp_your_token_here"
  3. ๐Ÿ“„ Local .env File: Create a .env file in your repository or home directory:
    GITHUB_TOKEN=ghp_your_token_here
    (Supports GITHUB_TOKEN, GH_TOKEN, and ADMIN_TOKEN)
  4. ๐Ÿ™ GitHub CLI Integration: If logged into the GitHub CLI (gh), add-github-topic automatically obtains credentials via gh auth token.

3. Common Commands ๐Ÿ› ๏ธ

# ๐Ÿท๏ธ 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-project

๐Ÿ’ป For Developers & Contributors ๐Ÿค

We warmly welcome contributions to add-github-topics! ๐ŸŽ‰

1. Local Development Setup ๐Ÿ› ๏ธ

  1. ๐Ÿ“ฅ Clone the Repository:

    git clone https://github.com/ishandutta2007/add-github-topics.git
    cd add-github-topics
  2. ๐Ÿ Set Up Virtual Environment:

    python -m venv venv
    # ๐Ÿง On Linux/macOS:
    source venv/bin/activate
    # ๐ŸชŸ On Windows:
    .\venv\Scripts\activate
  3. ๐Ÿ“ฆ Install Editable Package:

    pip install -e .

2. Code Structure & Guidelines ๐Ÿ“

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. โœจ


๐Ÿš€ For Package Publishers & DevOps ๐Ÿšข

Automated PyPI Publishing ๐Ÿ“ฆ

The project uses GitHub Actions with PyPI Trusted Publishing (OIDC) for automated releases. ๐Ÿ”’

How Version Release & Auto-Publishing Works: ๐Ÿ”„

  1. ๐Ÿท๏ธ Version Bump Workflow (Automated on Push):

    • Whenever you increment the version in pyproject.toml (e.g. version = "0.2.2") and push your commit to main or master:
      [project]
      version = "0.2.2"
    • The .github/workflows/publish.yml workflow 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.
  2. ๐Ÿ”– 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
  3. โšก Manual Trigger (workflow_dispatch):

    • You can also trigger a release manually via the Actions tab in GitHub.

DevOps Initial Setup Checklist (One-time): ๐Ÿ“‹

  • ๐Ÿ”‘ Configure PyPI Trusted Publisher for repository ishandutta2007/add-github-topics.
  • ๐Ÿ›ก๏ธ Create environment pypi under GitHub Repository Settings -> Environments.

๐Ÿ’– Support & Community

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! โœจ


Star History

Star History Chart


Made with โค๏ธ by Ishan Dutta

โญ Star History

Star History Chart

About

add GitHub Topics ๐ŸŒŸ Star if you like it! ๐ŸŒŸ

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages