-
Notifications
You must be signed in to change notification settings - Fork 64
72 lines (64 loc) · 2.39 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: Publish
on:
push:
branches:
- develop
jobs:
publish:
if: false
#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
current_version=$(npm pkg get version | sed 's/"//g')
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: |
yarn install
yarn build:oxd
cp LICENSE dist/LICENSE
cp README.md dist/README.md
cp THIRD-PARTY-LICENSE dist/THIRD-PARTY-LICENSE
(cat package.json | jq '.peerDependencies += {"vue": "3.x"}' | jq 'del(.private, .scripts, .dependencies.vue, .devDependencies)') > dist/package.json
- name: Upload build files
uses: actions/upload-artifact@v3
with:
name: oxd-build
path: dist
- name: Publish
if: ${{ env.fetched_current_version == '' }}
run: |
cd dist
npm publish --tag dev
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}