-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (46 loc) · 1.68 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
name: Publish Orochi Smart Contracts
on:
push:
branches: ['main']
env:
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
jobs:
publish:
name: Build & Publish package
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Publish smart contracts
env:
NPM_TOKEN: ${{ env.NPM_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > ~/.npmrc
cd ./package
PACKAGE_NAME=$(node -p "require('./package.json').name")
NPM_VERSION=$(npm show "$PACKAGE_NAME" version 2>/dev/null || echo 0.0.0)
PACKAGE_VERSION=$(node -p "require('./package.json').version")
NPM_NUMBER=$(echo $NPM_VERSION | sed 's/[^0-9]//g')
PACKAGE_NUMBER=$(echo $PACKAGE_VERSION | sed 's/[^0-9]//g')
max_length=$((${#NPM_NUMBER} > ${#PACKAGE_NUMBER} ? ${#NPM_NUMBER} : ${#PACKAGE_NUMBER}))
FIXED_NPM_VERSION=$(echo $NPM_NUMBER$(printf -- 0%.s $(seq -s ' ' $((max_length-${#NPM_NUMBER})))))
FIXED_PACKAGE_NUMBER=$(echo $PACKAGE_NUMBER$(printf -- 0%.s $(seq -s ' ' $((max_length-${#PACKAGE_NUMBER})))))
if [ ${FIXED_NPM_VERSION} -ge ${FIXED_PACKAGE_NUMBER} ]; then
echo "Ignore ${PACKAGE_NAME} since no changes"
else
cd ../
yarn
yarn run build:all
cd ./package
npm run release
fi