62 lines (55 loc) · 1.97 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
name: Publish
on:
push:
branches:
- develop
jobs:
publish:
if: github.repository == 'orangehrm/oxd'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Check version already published
run: |
set -x
npm -v
cd scripts
current_version=$(node ./current-version.js)
fetched_current_version=$(npm show @ohrm/oxd@$current_version version) || fetched_current_version=''
echo "current_version=$current_version" >> $GITHUB_ENV
echo "fetched_current_version=$fetched_current_version" >> $GITHUB_ENV
echo "current_published_version=$(npm show @ohrm/oxd version)" >> $GITHUB_ENV
- name: Allow only make patch, pre-releases
if: ${{ env.fetched_current_version == '' }}
run: |
npm i -g semver
current_published_version=${{ env.current_published_version }}
current_version=${{ env.current_version }}
fetched_current_version=${{ env.fetched_current_version }}
allowed_max_version=$(semver $current_published_version -i minor)
echo "-----"
echo "Latest published: $current_published_version"
echo "Allowed upper bound: $allowed_max_version"
echo "Current version: $current_version"
echo "-----"
version=$(semver -r ">$current_published_version <$allowed_max_version" $current_version -p)
if [[ $version != $current_version ]];
then
exit 1
fi
- name: Build
if: ${{ env.fetched_current_version == '' }}
run: |
cd scripts
node ./build.js
- name: Publish
if: ${{ env.fetched_current_version == '' }}
run: |
cd build
npm publish --tag dev
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}