Skip to content

Commit 98442e1

Browse files
committed
Skip subpackage publish if version already exists
1 parent 2b5df39 commit 98442e1

File tree

1 file changed

+54
-22
lines changed

1 file changed

+54
-22
lines changed

.github/workflows/build-test-deploy.yml

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,35 @@ jobs:
9898
tag="beta"
9999
fi
100100
101-
if [[ "$tag" ]]; then
102-
yarn workspace @connext/nxtp-utils npm publish --access public --tag $tag
103-
yarn workspace @connext/smart-contracts npm publish --access public --tag $tag
104-
yarn workspace @connext/nxtp-txservice npm publish --access public --tag $tag
105-
yarn workspace @connext/nxtp-adapters-subgraph npm publish --access public --tag $tag
106-
yarn workspace @connext/nxtp-adapters-cache npm publish --access public --tag $tag
107-
yarn workspace @connext/sdk npm publish --access public --tag $tag
108-
else
109-
yarn workspace @connext/nxtp-utils npm publish --access public
110-
yarn workspace @connext/smart-contracts npm publish --access public
111-
yarn workspace @connext/nxtp-txservice npm publish --access public
112-
yarn workspace @connext/nxtp-adapters-subgraph npm publish --access public
113-
yarn workspace @connext/nxtp-adapters-cache npm publish --access public
114-
yarn workspace @connext/sdk npm publish --access public
115-
fi
101+
workspaces=(
102+
"packages/nxtp-utils:@connext/nxtp-utils"
103+
"packages/smart-contracts:@connext/smart-contracts"
104+
"packages/nxtp-txservice:@connext/nxtp-txservice"
105+
"packages/nxtp-adapters-subgraph:@connext/nxtp-adapters-subgraph"
106+
"packages/nxtp-adapters-cache:@connext/nxtp-adapters-cache"
107+
"packages/agents/sdk:@connext/sdk"
108+
)
109+
110+
for entry in "${workspaces[@]}"; do
111+
IFS=":"; read -ra split_entry <<< "$entry"
112+
directory="${split_entry[0]}"
113+
workspace="${split_entry[1]}"
114+
subpackage_version=$(cat $directory/package.json | jq -r '.version')
115+
116+
echo "Checking $workspace for existing version..."
117+
published_version=$(npm view $workspace version)
118+
119+
if [[ "$published_version" != "$subpackage_version" ]]; then
120+
echo "Publishing $workspace with version $subpackage_version"
121+
if [[ "$tag" ]]; then
122+
yarn workspace $workspace npm publish --access public --tag $tag
123+
else
124+
yarn workspace $workspace npm publish --access public
125+
fi
126+
else
127+
echo "Skipping $workspace as version $subpackage_version already exists"
128+
fi
129+
done
116130
117131
- name: Extract version, determine tag, and publish contracts
118132
if: ${{ startsWith(github.ref, 'refs/tags/contracts-v') }}
@@ -127,13 +141,31 @@ jobs:
127141
tag="beta"
128142
fi
129143
130-
if [[ "$tag" ]]; then
131-
yarn workspace @connext/nxtp-utils npm publish --access public --tag $tag
132-
yarn workspace @connext/smart-contracts npm publish --access public --tag $tag
133-
else
134-
yarn workspace @connext/nxtp-utils npm publish --access public
135-
yarn workspace @connext/smart-contracts npm publish --access public
136-
fi
144+
workspaces=(
145+
"packages/nxtp-utils:@connext/nxtp-utils"
146+
"packages/smart-contracts:@connext/smart-contracts"
147+
)
148+
149+
for entry in "${workspaces[@]}"; do
150+
IFS=":"; read -ra split_entry <<< "$entry"
151+
directory="${split_entry[0]}"
152+
workspace="${split_entry[1]}"
153+
subpackage_version=$(cat $directory/package.json | jq -r '.version')
154+
155+
echo "Checking $workspace for existing version..."
156+
published_version=$(npm view $workspace version)
157+
158+
if [[ "$published_version" != "$subpackage_version" ]]; then
159+
echo "Publishing $workspace with version $subpackage_version"
160+
if [[ "$tag" ]]; then
161+
yarn workspace $workspace npm publish --access public --tag $tag
162+
else
163+
yarn workspace $workspace npm publish --access public
164+
fi
165+
else
166+
echo "Skipping $workspace as version $subpackage_version already exists"
167+
fi
168+
done
137169
138170
build-and-push-router-publisher-image:
139171
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/testnet-prod' || github.ref == 'refs/heads/prod'

0 commit comments

Comments
 (0)