-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (58 loc) · 1.93 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Build and Publish
on:
push:
branches: [ main ]
jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
scope: '@marherb-work'
- name: Check package.json version change
id: check_version
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
CURRENT_VERSION=$(node -p "require('./package.json').version")
NPM_VERSION=$(npm view $PACKAGE_NAME version || echo "0.0.0")
if [ "$(printf '%s\n' "$NPM_VERSION" "$CURRENT_VERSION" | sort -V | tail -n1)" != "$NPM_VERSION" ] || [ "$NPM_VERSION" == "0.0.0" ]; then
echo "Current version is greater than npm version, or package has not been published to npm yet."
echo "version_changed=true" >> $GITHUB_ENV
else
echo "Current version is less than or equal to npm version."
echo "version_changed=false" >> $GITHUB_ENV
fi
- name: Install dependencies
if: env.version_changed == 'true'
run: yarn install
- name: Build package
if: env.version_changed == 'true'
run: yarn build
- name: Publish to NPM
if: env.version_changed == 'true'
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-page:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install dependencies
run: yarn install
- name: Build package
run: yarn cosmos-export
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./cosmos-export