-
-
Notifications
You must be signed in to change notification settings - Fork 149
40 lines (38 loc) · 1.09 KB
/
tag-npm-packages.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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@v2
with:
node-version: 18
- name: Checkout repository
uses: actions/checkout@v2
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