This is about :
- publishing to an NPM registry
- ... which is the Github Packaged registry (for NPM)
- ... with semantic-release
- ... in a Github Actions CI workflow
- in package.json, the package must be named "@context/repo-name", where
context
is either a Github username (in lowercase) or a Github organization (in lowercase). Eg :
"name": "@rupertbarrow/rapido-sf-plugin"
- in package.json, the repository must be named with an url, like this :
"repository": {
"url": "git+https://github.com/RupertBarrow/rapido-sf-plugin.git"
}
- in package.json, the
publishConfig
entry must follow the following syntax (note, NO username) :
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
}
- in Github Actions workflow, call run the semantic release like this :
- run: npx semantic-release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# Github personal access token (classic, not fine-grained) with these permissions :
# repo, write:packages, read:packages and delete:packages
- in Github, create a personal access token as described above and paste its value into the repository or organization secret called NPM_TOKEN
- I use this NPM_TOKEN, and not the GITHUB_TOKEN
I am publishing to a private repository. This is why I will need to authenticate to be able to install use my npm package in my work environment.
For this, I have created a file named ~/.npmrc
with :
//npm.pkg.github.com/:_authToken=ghp_myGithubPersonalAccessToken
@rupertbarrow:registry=https://npm.pkg.github.com
- the Github Personal Access token I created and used in
NPM_TOKEN
is placed in the first line - my username appears on the second line, WITH an @
I can now install my sf plugin
like this, for example :
sf plugin install @rupertbarrow/[email protected]