-
Notifications
You must be signed in to change notification settings - Fork 722
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5202 from WalletConnect/feat/auto-publish
feat: auto publish to npm
- Loading branch information
Showing
4 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Publish to NPM | ||
on: | ||
release: | ||
types: [created] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "20.x" | ||
registry-url: "https://registry.npmjs.org" | ||
- name: Install dependencies and build 🔧 | ||
run: npm ci && npm run build | ||
- name: Publish package on NPM 📦 | ||
run: npm run npm-publish:latest | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
# Context: https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ | ||
set -Eeuo pipefail | ||
|
||
file_location="packages/web3wallet/package.json" | ||
|
||
# Get the next version from lerna.json. | ||
lerna_file="lerna.json" | ||
lerna_version=$(grep -E '"version": "(.*)"' $lerna_file | sed -E 's/"version": "(.*)"/\1/' | sed 's/^[[:space:]]*//') | ||
|
||
IFS='.' read -r -a VERSION_PARTS <<< "$lerna_version" | ||
MAJOR_VERSION=${VERSION_PARTS[0]} | ||
MINOR_VERSION=${VERSION_PARTS[1]} | ||
PATCH_VERSION=${VERSION_PARTS[2]} | ||
echo "major version: $MAJOR_VERSION" | ||
echo "minor version: $MINOR_VERSION" | ||
echo "patch version: $PATCH_VERSION" | ||
|
||
# web3wallet version is always one major & one minor version behind the lerna version | ||
next_web3wallet_version="$((MAJOR_VERSION - 1)).$((MINOR_VERSION - 1)).$PATCH_VERSION" | ||
|
||
echo "[SCRIPT] Updating Web3wallet version to $next_web3wallet_version in $file_location..." | ||
# Use sed to update the value in the file | ||
if [ "$(uname)" = "Darwin" ]; then | ||
# MacOS requires an empty string as the second argument to -i | ||
sed -i '' -E "s/\"version\": \"[^\"]+\"/\"version\": \"$next_web3wallet_version\"/" "$file_location" | ||
else | ||
sed -i -E "s/\"version\": \"[^\"]+\"/\"version\": \"$next_web3wallet_version\"/" "$file_location" | ||
fi | ||
|
||
echo "[SCRIPT] Version updated to $next_web3wallet_version in $file_location" | ||
|
||
echo "[SCRIPT] ...Done!" |