GitHub action to automatically publish packages to npm.
Create a new .github/workflows/npm-publish.yml
file:
name: npm-publish
on:
push:
branches:
- main # Change this to your default branch
jobs:
npm-publish:
name: npm-publish
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Publish if version has been updated
uses: pascalgn/npm-publish-action@1.3.8
with: # All of theses inputs are optional
tag_name: "v%s"
tag_message: "v%s"
create_tag: "true"
commit_pattern: "^Release (\\S+)"
workspace: "."
publish_command: "yarn"
publish_args: "--non-interactive"
env: # More info about the environment variables in the README
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings
Now, when someone changes the version in package.json
to 1.2.3 and pushes a commit with the message Release 1.2.3
, the npm-publish
action will create a new tag v1.2.3
and publish the package to the npm registry.
These inputs are optional: that means that if you don't enter them, default values will be used and it'll work just fine.
tag_name
: the name pattern of the new tagtag_message
: the message pattern of the new tagcreate_tag
: whether to create a git tag or not (defaults to "true"
)commit_pattern
: pattern that the commit message needs to followworkspace
: custom workspace directory that contains the package.json
filepublish_command
: custom publish command (defaults to yarn
)publish_args
: publish command arguments (for example --prod --verbose
, defaults to empty)GITHUB_TOKEN
: this is a token that GitHub generates automatically, you only need to pass it to the action as in the exampleNPM_AUTH_TOKEN
: this is the token the action will use to authenticate to npm. You need to generate one in npm, then you can add it to your secrets (settings -> secrets) so that it can be passed to the action. DO NOT put the token directly in your workflow file.Modify package distribution tags npm dist-tag add @ [] npm dist-tag rm npm dist-tag ls [] aliases: dist-tags Add, remove, and enumerate distribution tags on a package: add: Tags the specified version
记一次完整的npm包开发 — 发布过程 前言 本人也是菜鸟一枚,现学现开发的,各个文档也尚未熟练,主要面向百度开发,因此文章中只会列出用到的API,更具体的API说明文档请参考最下边的参考链接部分, 如果有能力, 籍此可以尝试开发 CLI 工具 一、npm包初始化 创建目录并初始化npm mkdir auto_whs && cd auto_whs && npm init 在 git 创建仓库, 初
1.npm 是什么? npm是随同NodeJS一起安装的包管理工具,能解决NodeJS代码部署上的很多问题,常见的使用场景有以下几种: 允许用户从npm服务器下载别人编写的第三方包到本地使用。 允许用户从npm服务器下载并安装别人编写的命令行程序到本地使用。 允许用户将自己编写的包或命令行程序上传到npm服务器供别人使用。 由于新版的Nodejs已经集成了npm,所以之前npm也一并安装好了。同样
很多人都还没有自己发布过npm包,今天我就来讲解一下,写一个最简单的npm包,并发布上去。 1、本地创建一个文件夹,并初始化项目 mkdir my-npm-demo cd my-npm-demo npm init 2、新建入口文件 新建入口文件index.js, 里面我们写个小函数, module.exports = function(req) { console.log(req); }
npm 发布到github In my last post, I showed you how to create, test, and build a monorepo repository. In this article, I will show you how to automate the publishing of your monorepo to NPM using GitHub A
Fast, easy publishing to NPM Features �� Smart Only publishes if the version number in package.json differs from the latest on NPM �� Configurable Customize the version-checking behavior, the registry
PUBLISH channel message 将信息 message 发送到指定的频道 channel 。 可用版本: >= 2.0.0 时间复杂度: O(N+M),其中 N 是频道 channel 的订阅者数量,而 M 则是使用模式订阅(subscribed patterns)的客户端的数量。 返回值: 接收到信息 message 的订阅者数量。 # 对没有订阅者的频道发送信息 redis>
publish 将 Observable 转换为可被连接的 Observable publish 会将 Observable 转换为可被连接的 Observable。可被连接的 Observable 和普通的 Observable 十分相似,不过在被订阅后不会发出元素,直到 connect 操作符被应用为止。这样一来你可以控制 Observable 在什么时候开始发出元素。 演示 let intS
publish 函数签名: publish() : ConnectableObservable 共享源 observable 并通过调用 connect 方法使其变成热的。 示例 示例 1: 在订阅之后调用 observable 的 connect 方法 ( StackBlitz | jsBin | jsFiddle ) // RxJS v6+ import { interval } from '
(要求Workerman版本>=3.3.0) void ChannelClient::publish(string $event_name, mixed $event_data) 发布某个事件,所有这个事件的订阅者会收到这个事件并触发on($event_name, $callback)注册的回调$callback 参数 $event_name 发布的事件名称,可以是任意的字符串。如果事件没有任何订
Publishes a package to the npm registry. Once a package is published, you can never modify that specific version, so take care before publishing. yarn publish Publishes the package defined by the pack