Exercise - Publish to a GitHub Packages registry

In this lab, you will learn how to publish and share your code packages using GitHub Packages. GitHub Packages is a package hosting service that allows you to host your packages privately or publicly and use packages as dependencies in your projects. This exercise will guide you through the process of publishing a package to the GitHub Packages registry.

You will learn how to:

  • Understand what GitHub Packages is and its benefits
  • Configure a package for publishing
  • Authenticate to GitHub Packages
  • Publish a package to the registry
  • Install and use packages from GitHub Packages
  • Manage package versions and permissions

This lab takes approximately 30-45 minutes to complete.

Before you start

To complete the lab, you need:

  • A GitHub user account. If you don't have one, you can create a new account. If you need instructions on how to create a GitHub account, refer to the article Creating an account on GitHub.
  • Basic understanding of package managers (npm, Maven, NuGet, etc.).
  • A web browser with access to the internet.

Complete the exercise on GitHub

In this exercise, you'll learn to publish packages through a hands-on GitHub Skills exercise.

Note: This exercise is hosted on GitHub Skills and provides an interactive learning experience. You'll configure a project, set up authentication, and publish a package to GitHub Packages.

The exercise consists of the following activities:

  1. Start a web browser and navigate to the exercise repository: https://github.com/skills/publish-packages

  2. On the exercise page, select the Use this template button to copy the exercise to your GitHub account.

    Note: Simply copy the exercise to your account, then give GitHub about 20 seconds to prepare the first lesson, then refresh the page.

  3. Follow the instructions on the repository's README to complete all the challenges, which include:

    • Understanding GitHub Packages and supported package types
    • Configuring package metadata in your project
    • Setting up authentication using Personal Access Tokens (PATs)
    • Publishing a package to the GitHub Packages registry
    • Installing packages from GitHub Packages
    • Managing package versions and updates
    • Configuring package visibility (public vs private)
    • Understanding package permissions and access control
  4. Work through each step in the exercise, following the prompts and instructions provided.

    Note: GitHub Packages supports multiple package types including npm, Maven, NuGet, Docker, and RubyGems. The exercise will guide you through one specific package type.

  5. When you finish all the challenges, you'll understand how to publish and share packages using GitHub Packages.

What you've learned

After completing this exercise, you should be able to:

  • Understand GitHub Packages and its benefits
  • Configure packages for publishing to GitHub Packages
  • Authenticate to GitHub Packages securely
  • Publish packages to the registry
  • Install and use packages from GitHub Packages
  • Manage package versions effectively
  • Control package visibility and access
  • Integrate GitHub Packages into your development workflow
  • Share libraries and dependencies with teams

Congratulations! You've completed the "Publish to a GitHub Packages registry" exercise and learned how to share your code as packages!