Skip to content

tag latest npm packages #3

tag latest npm packages

tag latest npm packages #3

name: tag latest npm packages
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to run the workflow on'
required: true
default: 'main'
release:
types:
- released
jobs:
tag-latest:
runs-on: ubuntu-latest
steps:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Get list of packages
run: |
npx lerna list --json > pckg-list.json
- name: Tag latest npm packages
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
PACKAGE_DATA=$(cat pckg-list.json)
PACKAGE_COUNT=$(echo "$PACKAGE_DATA" | jq length)
for i in $(seq 0 $(($PACKAGE_COUNT-1))); do
PACKAGE=$(echo "$PACKAGE_DATA" | jq -r ".[$i].name")
VERSION=$(echo "$PACKAGE_DATA" | jq -r ".[$i].version")
npm dist-tag add "$PACKAGE@$VERSION" latest
done