GitHub 上如何使用 GitHub Packages 发布 npm 包 All In One
GitHub 上如何使用 GitHub Packages 发布 npm 包 All In One
npm publish
PAT === Personal Access Token
# xgqfrms
$ npm login --registry=https://npm.pkg.github.com
# 输入 PAT 密码
$ npm publish
# 指定 scope @xgqfrms
$ npm login --registry=https://npm.pkg.github.com --scope=@xgqfrms
# 输入 PAT 密码
$ npm publish
https://github.com/xgqfrms/wcui/packages/1587375
GitHub Packages
only
supportsscoped
npm packages.
GitHub Actions
CI/CD
https://github.com/xgqfrms/wcui/actions/new
https://github.com/xgqfrms/wcui/actions/new?category=none&query=npm
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
name: Node.js Package
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm test
publish-gpr:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://npm.pkg.github.com/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
GITHUB_TOKEN
https://github.com/xgqfrms/wcui/settings/secrets/actions
https://github.com/xgqfrms/wcui/releases/new
https://github.com/xgqfrms/wcui/runs/7739088278?check_suite_focus=true#step:4:26
https://github.com/xgqfrms/wcui/blob/main/.github/workflows/npm-publish-github-packages.yml
demo
before
after ✅
git delete tags
# delete local tag '12345'
$ git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
$ git push origin :refs/tags/12345
# alternative approach
$ git push --delete origin tagName
$ git tag -d tagName
https://github.com/xgqfrms/wcui/issues/9
# 查看所有 tags
$ git tag
# 删除 tag v1.1.1 ❌
$ git tag -d v1.1.1
$ git push origin :refs/tags/v1.1.1
# 删除 tag v1.1.2 ❌
$ git tag -d v1.1.2
$ git push origin :refs/tags/v1.1.2
.npmrc
& publishConfig
https://docs.github.com/en/packages/quickstart
docs
https://github.com/features/packages
token
GitHub package bugs All In One
https://gist.github.com/xgqfrms/c837e1b27674eeea350f2db7d401ee0f
https://github.com/xgqfrms/wcui/issues/10
https://github.com/orgs/community/discussions/28844
refs
https://gist.github.com/xgqfrms/795719e59dbb7f7be562307a3c1cbe51
https://docs.github.com/cn/packages
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/16565524.html
未经授权禁止转载,违者必究!