Skip to content

GitHub Packages Overview

GitHub Packages is a package hosting service that allows developers to host and manage their packages alongside their source code. It integrates seamlessly with GitHub repositories and workflows.

  • Multi-Language Support: Supports various package ecosystems, including npm, Maven, NuGet, Docker, and more.
  • Integration with GitHub Actions: Automate package publishing and management using GitHub Actions.
  • Access Control: Manage who can view and install your packages.
  • Versioning: Keep track of package versions and updates.
  • Centralized Management: Host your code and packages in one place.
  • Improved Collaboration: Share packages with your team or the community.
  • Enhanced Security: Control access to your packages and use signed packages for added security.
  1. Authenticate with GitHub Packages using a personal access token.
  2. Configure your package manager to use GitHub Packages as a registry.
  3. Publish your package to GitHub Packages.

Example .npmrc Configuration:

//npm.pkg.github.com/:_authToken=YOUR_PERSONAL_ACCESS_TOKEN
@OWNER:registry=https://npm.pkg.github.com
name: Publish Package
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Publish to GitHub Packages
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

GitHub Packages simplifies package management by integrating it directly into your GitHub workflow. Whether you’re managing private packages for your team or sharing open-source packages with the community, GitHub Packages provides a secure and efficient solution.