Skip to content

Merge pull request #62 from orochi-network/feature/release_new_contra… #32

Merge pull request #62 from orochi-network/feature/release_new_contra…

Merge pull request #62 from orochi-network/feature/release_new_contra… #32

Workflow file for this run

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: Prepare environment
env:
DEV_ENV_VARS: ${{ secrets.DEV_ENV_VARS }}
run: echo $DEV_ENV_VARS | base64 -d >> .env
- 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
cd ./package
npm run release
fi