Operations 4 min read

Publishing Packages to GitHub Packages with GitHub Actions

This guide explains how to use GitHub Packages as a unified package registry and demonstrates step‑by‑step how to configure npm, create a workflow file, and automatically publish a Node.js package to GitHub Packages via GitHub Actions whenever a new release is created.

DevOps Cloud Academy
DevOps Cloud Academy
DevOps Cloud Academy
Publishing Packages to GitHub Packages with GitHub Actions

GitHub Packages is a platform for hosting and managing packages, including container images, that integrates with source code, permissions, and billing on GitHub.

It supports registries for common package managers such as npm, RubyGems, Maven, Gradle, Docker, and NuGet, with a dedicated container registry optimized for Docker and OCI images.

The article lists language‑specific package formats and clients (e.g., JavaScript → package.json via npm, Ruby → Gemfile via gem, Java → pom.xml via mvn, etc.).

To publish a Node.js package to GitHub Packages, follow these steps:

Create a repository and clone it locally.

Add a test index.js file.

Initialize the npm package with npm init , using a scoped name like @YOUR-USERNAME/YOUR-REPOSITORY .

Run npm install to generate package-lock.json , commit and push the changes.

Create a workflow file .github/workflows/release-package.yml that triggers on a release event, builds the package, and publishes it using the npm publish command with the appropriate authentication token.

Add a .npmrc file in the repository root containing @YOUR-USERNAME:registry=https://npm.pkg.github.com and set the publishConfig field in package.json to point to the same registry.

Commit the workflow and configuration files and push them; the workflow will run automatically on each new release, publishing the package to GitHub Packages if tests pass.

Images in the original article illustrate the process and promote the DevOps Cloud Academy.

CI/CDDevOpsnpmPackage ManagementGitHub ActionsGitHub Packages
DevOps Cloud Academy
Written by

DevOps Cloud Academy

Exploring industry DevOps practices and technical expertise.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.