Coder Social home page Coder Social logo

apustobaev / publish Goto Github PK

View Code? Open in Web Editor NEW

This project forked from primer/publish

0.0 1.0 0.0 210 KB

The GitHub Action that publishes Primer packages to npm

Home Page: https://npm.im/@primer/publish

License: MIT License

JavaScript 88.18% HCL 2.54% Dockerfile 2.93% Shell 6.35%

publish's Introduction

primer/publish

This GitHub Action publishes to npm with the following conventions:

  1. If we're on the master branch, the version field is used as-is and we just run npm publish --access public.
    • After publishing a new version on the master branch, we tag the commit SHA with v{version} via the GitHub API.
    • If the version in package.json is already published, we exit with a 0 code. Previously, we exited with a 78 code, which was Actions v1-speak for "neutral", but this has been removed from Actions v2.
  2. If we're on a release-<version> branch, we publish a release candidate to the next npm dist-tag with the version in the form: <version>-rc.<sha>.
    • A status check is created with the context npm version noting whether the version field in package.json matches the <version> portion of the branch. If it doesn't, the check's status is marked as pending.
  3. Otherwise, we publish a "canary" release, which has a version in the form: 0.0.0-<sha>.

Status checks

Depending on the branch, a series of statuses will be created by this action in your checks: publish is the action's check, and publish {package-name} is a commit status created by the action that reports the version published and links to unpkg.com via "Details":

image

If you're on a release branch (release-<version>) and the <version> portion of the branch name doesn't match the version field in package.json, you'll get a pending status reminding you to update it:

image

Usage

You will need to provide an npm access token with publish permissions via the NPM_AUTH_TOKEN secret in the Actions visual editor if you haven't already. The GITHUB_TOKEN secret is also required to create tags after releasing on the master branch.

We suggest that you place this action after any linting and/or testing actions to catch as many errors as possible before publishing.

Actions v2

To use this in an Actions v2 workflow, add the following YAML to one or more of your steps:

- uses: primer/publish@master
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

You can pass additional options via the args key:

โ€‹- uses: primer/publish@master
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
+   args: '--dry-run -- --unsafe-perm'

Actions v1

To use this in an Actions v1 workflow, add the following snippet to .github/main.workflow:

action "publish" {
  uses = "primer/publish@master"
  secrets = [
    "GITHUB_TOKEN",
    "NPM_AUTH_TOKEN",
  ]
}

Options

--dry-run

Default: false

Does everything publish would do except actually publishing to the registry. Reports the details of what would have been published.

Example

action "publish" {
  uses = "primer/publish@master"
  secrets = ["GITHUB_TOKEN", "NPM_AUTH_TOKEN"]
  args = "--dry-run"
}

--dir=<path>

Default: .

Accepts a path to the directory that contains the package.json to publish.

Example

action "publish" {
  uses = "primer/publish@master"
  secrets = ["GITHUB_TOKEN", "NPM_AUTH_TOKEN"]
  args = "--dir=packages/example"
}

npm CLI arguments

It's possible to pass additional arguments to npm via the args field in your workflow action. Because the primer-publish CLI accepts options of its own (such as --dry-run), you need to prefix any npm arguments with --:

action "publish" {
  uses = "primer/publish@master"
+  args = ["--", "--registry=https://registry.your.org"]

publish's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.