GitHub Packages is a package management service that allows you to securely publish and consume software packages. It is deeply integrated with the GitHub ecosystem.
| Package Manager | Language/Platform | Repository Type |
|---|---|---|
| npm | JavaScript/Node.js | npm |
| NuGet | .NET | nuget |
| RubyGems | Ruby | gem |
| Maven | Java | maven |
| Gradle | Java/Kotlin | gradle |
| Docker | Container | docker |
| Helm | Kubernetes | helm |
| Swift | iOS/macOS | swift |
- Private Packages: Publish packages for internal company use
- Public Packages: Publish open source packages for community use
- Dependency Management: Use GitHub Packages as package source in CI/CD
- Container Images: Store and distribute Docker images
# Configure npm to use GitHub Packages
echo "@your-username:registry=https://npm.pkg.github.com" > .npmrc
# Install package
npm install @your-username/package-name# Add GitHub Packages source
dotnet nuget add source "https://nuget.pkg.github.com/your-username/index.json" \
--name "GitHub" \
--username "your-username" \
--password "your-token"
# Install package
dotnet add package package-name# Login to GitHub Container Registry
echo "your-token" | docker login ghcr.io -u your-username --password-stdin
# Pull image
docker pull ghcr.io/username/image-name:tag# Login
npm login --registry=https://npm.pkg.github.com
# Publish
npm publish# Build image
docker build -t ghcr.io/username/image-name:tag .
# Push image
docker push ghcr.io/username/image-name:tag{
"name": "@your-username/package-name",
"version": "1.0.0",
"description": "My package",
"main": "index.js",
"publishConfig": {
"registry": "https://npm.pkg.github.com"
}
}name: Publish Package
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://npm.pkg.github.com'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}name: Publish Docker Image
on:
push:
tags:
- 'v*'
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.ref_name }}Configure in repository Settings → Actions → General:
- Read: Read packages
- Write: Read and publish packages
- Admin: Manage package permissions
Configure default permissions in organization Settings → Packages.
MAJOR.MINOR.PATCH
- MAJOR: Incompatible API changes
- MINOR: Backward compatible new features
- PATCH: Backward compatible bug fixes
Use Git tags to mark versions:
git tag -a v1.0.0 -m "Release version 1.0.0"
git push origin v1.0.0- Use Semantic Versioning: Let users understand nature of changes
- Write Clear Release Notes: Explain new features and fixes
- Automate Release Process: Use GitHub Actions
- Set Appropriate Permissions: Principle of least privilege
- Regularly Update Dependencies: Maintain package security
-
Storage Limits:
- GitHub Free: 500 MB
- GitHub Pro: 2 GB
- GitHub Team: 2 GB
- GitHub Enterprise: 50 GB
-
Bandwidth Limits:
- GitHub Free: 1 GB/month
- GitHub Pro: 2 GB/month