Skip to main content

Introduction to GitHub Packages

GitHub Packages is a software package hosting service that allows you to host your software packages privately or publicly and use packages as dependencies in your projects.

GitHub Packages 适用于 GitHub Free、GitHub Pro、面向组织的 GitHub Free、GitHub Team, GitHub Enterprise Cloud, GitHub Enterprise Server 3.0 或更高版本以及 GitHub AE。
GitHub Packages 不适用于使用旧版按仓库计划的帐户所拥有的私有仓库。 此外,使用旧版按仓库计划的帐户无法访问 Container registry,因为这些帐户是按仓库计费的。 有关详细信息,请参阅“GitHub 的产品”。

About GitHub Packages

GitHub Packages is a platform for hosting and managing packages, including containers and other dependencies. GitHub Packages combines your source code and packages in one place to provide integrated permissions management and billing, so you can centralize your software development on GitHub Enterprise Cloud.

You can integrate GitHub Packages with GitHub APIs, GitHub Actions, and webhooks to create an end-to-end DevOps workflow that includes your code, CI, and deployment solutions.

GitHub Packages offers different package registries for commonly used package managers, such as npm, RubyGems, Apache Maven, Gradle, Docker, and NuGet. GitHub's Container registry is optimized for containers and supports Docker and OCI images. For more information on the different package registries that GitHub Packages supports, see "Working with a GitHub Packages registry."

Diagram showing packages support for the Container registry, RubyGems, npm, Apache Maven, NuGet, and Gradle

You can view a package's README, as well as metadata such as licensing, download statistics, version history, and more on GitHub Enterprise Cloud. For more information, see "Viewing packages."

Overview of package permissions and visibility

PermissionsThe permissions for a package are either inherited from the repository where the package is hosted or, for packages in the Container registry and npm registry, they can be defined for specific user or organization accounts. For more information, see "Configuring a package’s access control and visibility."
Visibility可以在公共存储库存储库中发布包(公共包)以与所有人GitHub共享,或者在专用存储库(专用包)中与协作者或组织共享。

For more information, see "About permissions for GitHub Packages."

About billing for GitHub Packages

公共包免费使用 GitHub Packages。 对于专用包,每个 GitHub.com 帐户可获得一定数量的免费存储和数据传输,具体取决于帐户所使用的产品。 超出包含数量的任何使用量都由支出限制控制。 如果您是每月付费的用户,您的帐户默认支出限额为 0 美元,这将防止您在达到包含的限额后额外使用存储或数据传输。 如果按发票支付帐户费用,则帐户将具有无限制的默认支出限制。 For more information, see "About billing for GitHub Packages."

Supported clients and formats

GitHub Packages uses the native package tooling commands you're already familiar with to publish and install package versions.

Support for package registries

LanguageDescriptionPackage formatPackage client
JavaScriptNode package managerpackage.jsonnpm
RubyRubyGems package managerGemfilegem
JavaApache Maven project management and comprehension toolpom.xmlmvn
JavaGradle build automation tool for Javabuild.gradle or build.gradle.ktsgradle
.NETNuGet package management for .NETnupkgdotnet CLI
N/ADocker container managementDockerfileDocker

For more information about configuring your package client for use with GitHub Packages, see "Working with a GitHub Packages registry."

For more information about Docker and the Container registry, see "Working with the Container registry."

Authenticating to GitHub Packages

需要访问令牌才能发布、安装和删除包。

可使用个人访问令牌 (PAT) 向 GitHub Packages 或 GitHub API 进行身份验证。 创建个人访问令牌时,可根据需要为令牌分配不同的作用域。 有关 PAT 的包相关范围的详细信息,请参阅“关于 GitHub Packages 的权限”。

要在 GitHub Actions 工作流程内向 GitHub Packages 注册表验证,您可以使用:

  • GITHUB_TOKEN 发布与工作流存储库相关联的包。
  • PAT 来安装与其他专用存储库(GITHUB_TOKEN 无法访问)相关联的包。

有关 GitHub Actions 工作流中使用的 GITHUB_TOKEN 的详细信息,请参阅“工作流中的身份验证”。

Managing packages

You can delete a package in the GitHub.com user interface or using the REST API. For more information, see "Deleting and restoring a package" and the "GitHub Packages API."

The GitHub Packages GraphQL API does not support containers or Docker images that use the package namespace https://ghcr.io/OWNER/PACKAGE-NAME, or npm images that use the package namespace https://npm.pkg.github.com/OWNER/PACKAGE-NAME.

When you use the GraphQL API to query and delete private packages, you must use the same token you use to authenticate to GitHub Packages.

For more information, see "Forming calls with GraphQL."

You can configure webhooks to subscribe to package-related events, such as when a package is published or updated. For more information, see the "package webhook event."

Contacting support

If you have feedback or feature requests for GitHub Packages, use a GitHub Community discussion.

Contact GitHub 支持 about GitHub Packages using our contact form if:

  • You experience anything that contradicts the documentation
  • You encounter vague or unclear errors
  • Your published package contains sensitive data, such as GDPR violations, API Keys, or personally identifying information