-
Notifications
You must be signed in to change notification settings - Fork 3
41 lines (35 loc) · 1.03 KB
/
npm_publish.yml
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
41
name: Publish Package to NPM
on:
workflow_dispatch:
push:
branches:
- main
jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 18.12.1
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build --workspaces
- name: Get changed packages
id: changed
run: |
CHANGED=$(git diff --name-only HEAD^ HEAD | grep "^packages/" | cut -d/ -f2 | sort -u | jq -R -s -c 'split("\n")[:-1]')
echo "packages=$CHANGED" >> $GITHUB_OUTPUT
- name: Publish changed packages
if: steps.changed.outputs.packages != '[]'
run: |
PACKAGES=$(echo '${{ steps.changed.outputs.packages }}' | jq -r '.[]')
for PKG in $PACKAGES; do
cd packages/$PKG
npm publish
cd ../..
done
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}