Skip to content

Commit

Permalink
chore: confirm the release version is the latest
Browse files Browse the repository at this point in the history
  • Loading branch information
zakir-code committed Aug 5, 2024
1 parent de4d336 commit 2fda1ec
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,31 @@ on:
push:
tags:
- "v*.*.*"
pull_request:
paths:
- 'solidity/**.sol'
- 'solidity/package.json'
- 'solidity/release.sh'
- '.github/workflows/npm.yml'

jobs:
build:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- run: |

- name: Set ENV
id: env
if: github.event_name != 'pull_request'
run: echo "NODE_AUTH_TOKEN=${{secrets.NPM_TOKEN}}" >> $GITHUB_ENV

- name: Release
run: |
chmod +x ./solidity/release.sh
./solidity/release.sh
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NODE_AUTH_TOKEN: ${{ steps.env.outputs.NODE_AUTH_TOKEN }}
13 changes: 12 additions & 1 deletion solidity/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ if [ -d "$project_dir/solidity" ]; then
solidity_dir="$project_dir/solidity"
fi

package_name=$(jq -r '.name' "$solidity_dir/package.json")
last_version=$(npm info "$package_name" version)
latest_version=$(jq -r '.version' "$solidity_dir/package.json")
if [ "$last_version" == "$latest_version" ]; then
echo "The latest version of $package_name is already published." && exit 0
fi

if [ ! -f "$solidity_dir/hardhat.config.ts" ]; then
echo "This script must be run from the root of the repository." && exit 1
fi
Expand Down Expand Up @@ -42,5 +49,9 @@ done
# publish contracts package
(
cd "$solidity_dir/contracts"
npm publish --access public
if [ -z "$NODE_AUTH_TOKEN" ]; then
npm publish --dry-run
else
npm publish --access public
fi
)

0 comments on commit 2fda1ec

Please sign in to comment.