Update npm-publish.yml #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Package to npm | |
on: | |
push: | |
branches: | |
- master # Trigger on push to master branch | |
tags: | |
- 'v*' # Trigger when any tag is pushed | |
jobs: | |
publish-npm: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '16.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Setup .npmrc | |
run: | | |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
echo "Created .npmrc:" | |
cat ~/.npmrc | |
- name: Verify package info | |
run: | | |
echo "Package name:" | |
npm pkg get name | |
echo "Package version:" | |
npm pkg get version | |
echo "Package.json content:" | |
cat package.json | |
- name: Publish to NPM | |
run: | | |
ORG="jito-labs" | |
PACKAGE_NAME=$(npm pkg get name | sed 's/"//g') | |
if [[ $PACKAGE_NAME != @$ORG/* ]]; then | |
NEW_NAME="@$ORG/${PACKAGE_NAME#@*/}" | |
npm pkg set name="$NEW_NAME" | |
echo "Updated package name to $NEW_NAME" | |
fi | |
npm publish --verbose --access public | |
- name: Debug publish failure | |
if: failure() | |
run: | | |
echo "NPM logs:" | |
cat /home/runner/.npm/_logs/*.log |