Skip to content

chore(*): update npm auth and publish steps in workflow #42

chore(*): update npm auth and publish steps in workflow

chore(*): update npm auth and publish steps in workflow #42

Workflow file for this run

name: release
on:
push:
branches:
- master
jobs:
build:
name: build-and-publish
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm ci
- name: Install Angular CLI
run: npm install -g @angular/cli
- name: Build package
run: npm run build:lib
- name: Publish to npm
# if: startsWith(github.event.head_commit.message, 'chore(release):')
working-directory: ./@packaged/angular-star-rating
run: |
VERSION=$(node -p "require('./package.json').version")
echo "Publishing version $VERSION"
# configure npm auth (use NPM_TOKEN)
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
touch .npmrc
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
# publish to npm
npm publish
# configure git
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
# create + push tag
git tag "v$VERSION"
git push origin "v$VERSION"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}