-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (49 loc) · 1.47 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Publish to npm
on:
push:
branches:
- main
paths:
- "*/package.json"
jobs:
build-and-publish:
runs-on: ubuntu-latest
strategy:
matrix:
plugin: ["vite-plugin-tsc-build"]
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Check version change
id: check_version
run: |
VERSION_CHANGE=$(git diff HEAD^ HEAD -- "${{ matrix.plugin }}/package.json" | grep -P "^\+.*\"version\"")
if [[ -z "$VERSION_CHANGE" ]]; then
echo "No version change detected for ${{ matrix.plugin }}, skipping publish."
echo "version_changed=false" >> $GITHUB_OUTPUT
else
echo "Version change detected for ${{ matrix.plugin }}, publishing to npm."
echo "version_changed=true" >> $GITHUB_OUTPUT
fi
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 16
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: |
cd "${{ matrix.plugin }}"
npm ci
- name: Build
run: |
cd "${{ matrix.plugin }}"
npm run build
- name: Publish to npm
if: steps.check_version.outputs.version_changed == 'true'
run: |
cd "${{ matrix.plugin }}"
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}