Frecuentemente publicamos actualizaciones de nuestra documentación. Es posible que la traducción de esta página esté en curso. Para conocer la información más actual, visita la documentación en inglés. Si existe un problema con las traducciones en esta página, por favor infórmanos.
GitHub AE is currently under limited release. Please contact our Sales Team to find out more.

Quickstart for GitHub Packages

Publish to Paquetes de GitHub with GitHub Actions.

En este artículo

Note: GitHub Actions is currently in beta for GitHub AE.

Warning: Self-hosted runners are currently disabled for GitHub AE. This is because GitHub AE offers guarantees for security boundaries which are incompatible with how self-hosted runners work. However, if you do need to use self-hosted runners with GitHub AE and understand the security implications, you can contact GitHub support for a security exception that will enable self-hosted runners.

If you don't need self-hosted runners, then you can use AE hosted runners to run your workflows. For more information, see "About AE hosted runners."

Introduction

In this guide, you'll create a GitHub Actions workflow to test your code and then publish it to Paquetes de GitHub.

Publishing your package

  1. Create a new repository on GitHub, adding the .gitignore for Node. For more information, see "Creating a new repository."

  2. Clone the repository to your local machine.

    $ git clone https://YOUR-HOSTNAME/YOUR-USERNAME/YOUR-REPOSITORY.git
    $ cd YOUR-REPOSITORY
  3. Create an index.js file and add a basic alert to say "Hello world!"

    JavaScript
    alert("Hello, World!");
  4. 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 to exit 0. This will generate a package.json file with information about your package.

    $ npm init
      ...
      package name: @YOUR-USERNAME/YOUR-REPOSITORY
      ...
      test command: exit 0
      ...    
  1. Run npm install to generate the package-lock.json file, then commit and push your changes to GitHub.

    $ npm install
    $ git add index.js package.json package-lock.json
    $ git commit -m "initialize npm package"
    $ git push
  2. Create a .github/workflows directory. In that directory, create a file named release-package.yml.

  3. Copy the following YAML content into the release-package.yml file, replacing YOUR-HOSTNAME with the name of your enterprise.

    YAML
    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.YOUR-HOSTNAME.com/
          - run: npm ci
          - run: npm publish
            env:
              NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
  4. Commit and push your changes to GitHub.

    $ git add .github/workflows/release-package.yml
    $ git commit -m "workflow to publish package"
    $ git push
  5. 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 Paquetes de GitHub.

    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.

  1. En GitHub Enterprise, visita la página principal del repositorio.

  2. A la derecha de la lista de archivos, da clic en Paquetes.

    Enlace de paquetes en la página de resumen

  3. Da clic en el nombre del paquete que quieres ver. Nombre del paquete

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 Paquetes de GitHub. 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 Paquetes de GitHub and GitHub 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 Paquetes de GitHub and GitHub Actions:

¿Te ayudó este documento?

Privacy policy

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

O, learn how to contribute.