Skip to main content

A CLI tool for uploading files to GitLab's Generic Package Registry

Project description

glpkg

Tests Lint Publish Docs Coverage

A CLI tool for uploading and listing files in GitLab's Generic Package Registry.

Installation

From PyPI (Recommended)

# Using uv (recommended)
uv pip install glpkg-cli

# Or using pip
pip install glpkg-cli

After installation, the glpkg command is available in your PATH:

# Verify installation
glpkg --version

# View available commands
glpkg --help

Universal Binary (.pyz)

Download the pre-built universal binary from GitHub releases. This is a self-contained executable that requires no installation - just Python 3.11+.

# Download the latest release (replace VERSION with desired version, e.g., v0.1.1)
curl -L -o glpkg.pyz \
  https://github.com/jetm/glpkg/releases/download/VERSION/glpkg-VERSION.pyz

# Make it executable
chmod +x glpkg.pyz

# Run directly
./glpkg.pyz --help

# Or run with Python
python glpkg.pyz --help

Optionally, install the binary to a location in your PATH for easier access:

# Install to ~/.local/bin (user-local)
mv glpkg.pyz ~/.local/bin/glpkg
chmod +x ~/.local/bin/glpkg

# Or install system-wide (requires sudo)
sudo mv glpkg.pyz /usr/local/bin/glpkg
sudo chmod +x /usr/local/bin/glpkg

# Now use it like a regular command
glpkg --help

Development Installation

# Clone the repository
git clone https://github.com/jetm/glpkg.git
cd glpkg

# Install in development mode with uv
uv pip install -e .

# Or run directly without installing
uv run glpkg --help

Usage

# Upload a single file
glpkg upload --package-name my-package --package-version 1.0.0 \
  --files file.tar.gz

# Upload multiple files
glpkg upload --package-name my-package --package-version 1.0.0 \
  --files file1.tar.gz file2.zip

# Upload with automatic project detection from git remote
glpkg upload --package-name my-package --package-version 1.0.0 \
  --files file.tar.gz

# Specify project explicitly
glpkg upload --package-name my-package --package-version 1.0.0 \
    --project-path namespace/project --files file.tar.gz

# Handle duplicates (skip, replace, or error)
glpkg upload --package-name my-package --package-version 1.0.0 \
    --duplicate-policy replace --files file.tar.gz

# Verbose output with global flags
glpkg --verbose upload --package-name my-package \
  --package-version 1.0.0 --files file.tar.gz

# JSON output for CI/CD pipelines
glpkg --json-output upload --package-name my-package \
  --package-version 1.0.0 --files file.tar.gz

# List files in a package from a GitLab URL
glpkg list --url https://gitlab.com/group/project/-/packages/12345

# List files by package name and version
glpkg list --package-name my-package --package-version 1.0.0

# List all versions of a package
glpkg list --package-name my-package

# List with JSON output
glpkg --json-output list --url https://gitlab.com/group/project/-/packages/12345

Configuration

Environment Variables

Variable Description Required
GITLAB_TOKEN GitLab access token with api scope Yes
GITLAB_URL GitLab URL (default: gitlab.com) No
GITLAB_PROJECT_PATH Project path (e.g., group/project) No

Token Permissions

Your GitLab token requires:

  • api scope for full API access
  • Write access to the target project's Package Registry

Development

For detailed contribution guidelines, see CONTRIBUTING.md.

Quick Start

# Clone and install dependencies
git clone https://github.com/jetm/glpkg.git
cd glpkg
uv sync --all-extras

# Install pre-commit hooks
uv run pre-commit install

# Run tests
uv run pytest tests/unit/

Q&A

Why not use the glab tool?

The glab CLI tool does not properly support uploading to the Generic Package Registry. See gitlab-org/cli#7421 for details.

Why not contribute this feature to glab?

For several reasons. I wanted to gain the experience of creating a tool from scratch, learn more about Python and its ecosystem, and understand GitHub CI better. GitLab is too slow at reviewing changes.

Documentation

Project Structure

glpkg/
├── src/
│   └── glpkg/
│       ├── __init__.py
│       ├── cli/
│       │   ├── __init__.py
│       │   ├── main.py         # Main CLI entry point
│       │   ├── upload.py       # Upload subcommand implementation
│       │   └── list_cmd.py     # List subcommand implementation
│       ├── models.py           # Data models
│       ├── uploader.py         # Upload logic
│       ├── formatters.py       # Output formatting
│       ├── duplicate_detector.py  # Duplicate detection
│       └── validators.py       # Input validation
├── tests/
│   ├── unit/                   # Unit tests
│   ├── integration/            # Integration tests
│   └── utils/                  # Test utilities
├── pyproject.toml              # Project configuration
└── README.md                   # This file

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glpkg_cli-0.1.2.tar.gz (47.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

glpkg_cli-0.1.2-py3-none-any.whl (50.0 kB view details)

Uploaded Python 3

File details

Details for the file glpkg_cli-0.1.2.tar.gz.

File metadata

  • Download URL: glpkg_cli-0.1.2.tar.gz
  • Upload date:
  • Size: 47.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for glpkg_cli-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e727c4cb1512391f5d50f99889eb86f49cf8845d07d373f1c69b4117a077a967
MD5 8dfff24e5141673eba0b1bdbbca83544
BLAKE2b-256 5db040326f04635c9d2aefbaefba57f3cd65363a59bfdd96455b4bf68cad18e6

See more details on using hashes here.

File details

Details for the file glpkg_cli-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: glpkg_cli-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 50.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for glpkg_cli-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e6d7f157165d4d55ec5c53487dc77aff0159bb95b8bb7229bd9e0595b2b4914c
MD5 9600c45ff469665cf5d095e083e8774e
BLAKE2b-256 710aa8a43e183415839b2125b6940770f5bca67a560af9af8b0255c4ad072622

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page