Are you sure you want to delete this access key?
title | intro | allowTitleToDifferFromFilename | versions |
---|---|---|---|
Quickstart for GitHub Packages | Publish to {% data variables.product.prodname_registry %} in 5 minutes or less with {% data variables.product.prodname_actions %}. | true | [{free-pro-team *} {enterprise-server >=2.22}] |
You only need an existing {% data variables.product.prodname_dotcom %} repository to publish a package to {% data variables.product.prodname_registry %}. 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 %}. Feel free to create a new repository for this Quickstart. You can use it to test this and future {% data variables.product.prodname_actions %} workflows.
.gitignore
for 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."$ git clone https://github.com/<em>YOUR-USERNAME</em>/<em>YOUR-REPOSITORY</em>.git
$ cd <em>YOUR-REPOSITORY</em>
{% endraw %}index.js
file and add a basic alert to say "Hello world!"
{% raw %}
alert("Hello, World!");
{% endraw %}@YOUR-USERNAME/YOUR-REPOSITORY
, and set the test script to exit 0
if you do not have any tests. Commit your changes and push them to {% data variables.product.prodname_dotcom %}.
{% raw %}
$ npm init
...
package name: <em>@YOUR-USERNAME/YOUR-REPOSITORY</em>
...
test command: <em>exit 0</em>
...
$ npm install
$ git add index.js package.json package-lock.json
$ git commit -m "initialize npm package"
$ git push
{% endraw %}.github/workflows
directory named release-package.yml
. For more information, see "Creating new files."release-package.yml
file.
{% raw %}
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
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://npm.pkg.github.com/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
{% endraw %}Creating a new release in your repository triggers the workflow to build and test your code. If the tests pass, then the package will be published to {% data variables.product.prodname_registry %}.
Packages are published at the repository level. You can see all the packages in a repository and search for a specific package.
{% data reusables.repositories.navigate-to-repo %} {% data reusables.package_registry.packages-from-code-tab %} {% data reusables.package_registry.navigate-to-packages %}
Now that you've published the package, you'll want to use it as a dependency across your projects. For more information, see "Configuring npm for use with {% data variables.product.prodname_registry %}."
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 %}:
Press p or to see the previous file or, n or to see the next file
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?