hf-release
Push model weights to Hugging Face Hub and create a GitHub Release in one atomic command.
The Problem
Today, releasing an ML model requires four separate manual steps:
push_to_hub()— upload weights to HF Hubgit tag— version the commit- GitHub UI — create a release
- Edit README — update the model card
No existing tool treats this as a single operation. hf-release does.
Installation
pip install hf-release
Quick Start
export HF_TOKEN=hf_...
export GITHUB_TOKEN=ghp_...
hf-release release \
--model ./my-model \
--version v1.2.0 \
--hf-repo username/my-model \
--gh-repo username/my-model-repo
This single command will:
- Upload all model files to HF Hub on the
mainbranch - Create a git tag
v1.2.0on HF Hub - Sync the local
README.mdto the HF model card (with version tag injected) - Create an annotated git tag on GitHub
- Create a GitHub Release with auto-generated release notes (grouped by PR labels)
- Append an "ML Artifacts" table to the release notes linking both platforms
All Options
--model PATH Local model directory [required]
--version TEXT Version tag, e.g. v1.2.0 [required]
--hf-repo TEXT HF Hub repo ID (owner/name) [required unless --skip-hf]
--gh-repo TEXT GitHub repo ID (owner/name) [required unless --skip-gh]
--hf-token TEXT HF write token [env: HF_TOKEN]
--gh-token TEXT GitHub PAT [env: GITHUB_TOKEN]
--branch TEXT HF Hub target branch [default: main]
--commit-msg TEXT Custom HF commit message
--ignore TEXT Glob pattern to exclude from upload [repeatable]
--create-repo Create HF repo if it does not exist
--release-name TEXT GitHub release display name
--previous-tag TEXT Starting tag for release note diff
--draft Create GitHub release as draft
--prerelease Mark as pre-release
--notes-file PATH Use a local Markdown file as release notes
--skip-card-sync Do not sync model card README
--tags TEXT Extra tags to inject into card metadata [repeatable]
--skip-hf Skip HF Hub push entirely
--skip-gh Skip GitHub release entirely
--skip-tag Skip tag creation on both platforms
--dry-run Show plan, make no API calls
--yes / -y Skip confirmation prompt
Environment Variables
| Variable | Description |
|---|---|
HF_TOKEN |
Hugging Face write token |
GITHUB_TOKEN |
GitHub personal access token (needs repo scope) |
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 2 | Authentication error |
| 3 | Repo not found |
| 4 | Tag conflict |
| 5 | Model card sync failure |
| 6 | Upload failure |
| 7 | GitHub release creation failure |
| 8 | Input validation error |
License
MIT