* Add actions category name as first commit * Package reorganization: rename articles for "Learning..." and "Managing..." categories (#18880) * Initial prep work for Packages reorg * Make changes for Learning and Managing categories * Match file name to revised article title * Rework packages guides (#18902) * Create new directory * Delete guides directory and index.md link * Remove duplicated redirects to fix test * fix folder name * delete temporary directory of old content * Add Gradle article * Update landing page with new links * Update test to fix CI failure for deleted articles * Update links and titles for reorg-ed articles * Fix broken links Co-authored-by: hubwriter <hubwriter@github.com> * Update more changed article titles in links (#18911) * remove test line to test PR build failure * Add sections to permissions article * Add draft reusable * restore versioning tests * Remove accidental inclusion of new reusable from a different branch * Package registry content redesign updates (#18930) * Update container registry product variable * First round of edits * Update tidbit * Apply suggestions from code review Co-authored-by: hubwriter <hubwriter@github.com> * Update docker-vs-container-registry.md * Update authentication section to resolve bug/confusion * Revisions * Last touchups * Migration from intro article Co-authored-by: hubwriter <hubwriter@github.com> * Add versioned diagrams * Add packages actions revisions (#18956) * Add refreshed content * Update content/packages/managing-github-packages-using-github-actions-workflows/example-workflows-for-publishing-a-package.md Due to tightness of time on this I'm going to commit this suggestion so that I can merge this PR into the Packages megabranch. Co-authored-by: hubwriter <hubwriter@github.com> * Packages reorg: "Introduction to GitHub Packages" article (#18906) * Initial commit. Remove stray comma * Initial CC work - WiP * More changes for the Introduction article * Make changes as per Jessica's review * Fix broken reusable ref * improve test failure message and add clarifying comments * Packages reorganization: More updates to the 'Learn GitHub Packages' articles" (#18961) * Viewing - WiP * More updates to the 'Learn...' category * revisions to intro article * Add permissions article and make a few other streamlined updates * Fix links 🌿 Co-authored-by: jmarlena <> * Apply suggestions from code review * Apply product input * Fix versioning * Apply some straight-forward suggested changes ⚡ Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review * Add "GitHub Packages" before container registry mention * Standardize visibility & permsisions section into a reusable * Add link * Replace outdated link * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * ✂️ cut note * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Superseded rewrite? * bye single-use reusable * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Condense packages & actions conceptual content * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * remove "package registries" * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Add reusable * Add these redirects from the deleted containers conceptual article * Incorporate changes from main into retitled articles 💫 * Missing endif * Fix unexpected redirect behavior * Revamp and consolidate actions access settings * Further reading section * Last fix for now * standardize steps * Apply suggestions from code review Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: hubwriter <hubwriter@github.com> Co-authored-by: Sarah Schneider <sarahs@github.com> Co-authored-by: jmarlena <> Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com>
6.0 KiB
title, intro, allowTitleToDifferFromFilename, versions
| title | intro | allowTitleToDifferFromFilename | versions | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Quickstart for GitHub Packages | Publish to {% data variables.product.prodname_registry %} with {% data variables.product.prodname_actions %}. | true |
|
{% data reusables.actions.enterprise-github-hosted-runners %} {% data reusables.actions.ae-beta %} {% data reusables.actions.ae-self-hosted-runners-notice %}
Introduction
In this guide, you'll create a {% data variables.product.prodname_actions %} workflow to test your code and then publish it to {% data variables.product.prodname_registry %}.
Publishing your package
-
Create a new repository on {% data variables.product.prodname_dotcom %}, adding the
.gitignorefor Node. {% if currentVersion ver_lt "enterprise-server@3.1" %} Create a private repository if you’d like to delete this package later, public packages cannot be deleted.{% endif %} For more information, see "Creating a new repository." -
Clone the repository to your local machine.
$ git clone https://{% if currentVersion == "github-ae@latest" %}<em>YOUR-HOSTNAME</em>{% else %}github.com{% endif %}/<em>YOUR-USERNAME</em>/<em>YOUR-REPOSITORY</em>.git $ cd <em>YOUR-REPOSITORY</em> -
Create an
index.jsfile and add a basic alert to say "Hello world!" {% raw %}alert("Hello, World!");{% endraw %}
-
Initialize an npm package with
npm init. In the package initialization wizard, enter your package with the name:@YOUR-USERNAME/YOUR-REPOSITORY, and set the test script toexit 0. This will generate apackage.jsonfile with information about your package. {% raw %}$ npm init ... package name: <em>@YOUR-USERNAME/YOUR-REPOSITORY</em> ... test command: <em>exit 0</em> ...{% endraw %}
-
Run
npm installto generate thepackage-lock.jsonfile, then commit and push your changes to {% data variables.product.prodname_dotcom %}.$ npm install $ git add index.js package.json package-lock.json $ git commit -m "initialize npm package" $ git push -
Create a
.github/workflowsdirectory. In that directory, create a file namedrelease-package.yml. -
Copy the following YAML content into the
release-package.ymlfile{% if currentVersion == "github-ae@latest" %}, replacingYOUR-HOSTNAMEwith the name of your enterprise{% endif %}.name: Node.js Package on: release: types: [created] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: 12 - run: npm ci - run: npm test publish-gpr: needs: build runs-on: ubuntu-latest{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@3.1" or currentVersion == "github-ae@next" %} permissions: packages: write contents: read{% endif %} steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: 12 registry-url: {% if currentVersion == "github-ae@latest" %}https://npm.YOUR-HOSTNAME.com/{% else %}https://npm.pkg.github.com/{% endif %} - run: npm ci - run: npm publish env: NODE_AUTH_TOKEN: ${% raw %}{{secrets.GITHUB_TOKEN}}{% endraw %} -
Commit and push your changes to {% data variables.product.prodname_dotcom %}.
$ git add .github/workflows/release-package.yml $ git commit -m "workflow to publish package" $ git push -
The workflow that you created will run whenever a new release is created in your repository. If the tests pass, then the package will be published to {% data variables.product.prodname_registry %}.
To test this out, navigate to the Code tab in your repository and create a new release. For more information, see "Managing releases in a repository."
Viewing your published package
You can view all of the packages you have published.
{% data reusables.repositories.navigate-to-repo %} {% data reusables.package_registry.packages-from-code-tab %} {% data reusables.package_registry.navigate-to-packages %}
Installing a published package
Now that you've published the package, you'll want to use it as a dependency across your projects. For more information, see "Working with the npm registry."
Next steps
The basic workflow you just added runs any time a new release is created in your repository. But this is only the beginning of what you can do with {% data variables.product.prodname_registry %}. You can publish your package to multiple registries with a single workflow, trigger the workflow to run on different events such as a merged pull request, manage containers, and more.
Combining {% data variables.product.prodname_registry %} and {% data variables.product.prodname_actions %} can help you automate nearly every aspect of your application development processes. Ready to get started? Here are some helpful resources for taking your next steps with {% data variables.product.prodname_registry %} and {% data variables.product.prodname_actions %}:
- "Learn {% data variables.product.prodname_registry %}" for an in-depth tutorial on GitHub Packages
- "Learn {% data variables.product.prodname_actions %}" for an in-depth tutorial on GitHub Actions
- "Working with a {% data variables.product.prodname_registry %} registry" for specific uses cases and examples