@@ -147,10 +147,33 @@ commands:
147
147
exit 1
148
148
fi
149
149
150
+ fetch-latest-hardhat-release-tag :
151
+ description : " Uses GitHub API to fetch the latest hardhat release version."
152
+ steps :
153
+ - run :
154
+ name : Retrieve Hardhat latest release tag
155
+ command : |
156
+ # Make authenticated requests when the Github token is available
157
+ if [[ -n "$GITHUB_ACCESS_TOKEN" ]]; then
158
+ EXTRA_HEADERS=(--header "Authorization: Bearer ${GITHUB_ACCESS_TOKEN}")
159
+ fi
160
+ HARDHAT_LATEST_RELEASE_TAG=$(
161
+ curl \
162
+ --silent \
163
+ --location \
164
+ --fail \
165
+ --show-error \
166
+ "${EXTRA_HEADERS[@]}" \
167
+ https://api.github.com/repos/nomiclabs/hardhat/releases/latest \
168
+ | jq --raw-output .tag_name \
169
+ )
170
+ echo "export HARDHAT_LATEST_RELEASE_TAG='${HARDHAT_LATEST_RELEASE_TAG}'" >> "$BASH_ENV"
171
+
150
172
provision-hardhat-with-packaged-solcjs :
151
173
description : " Clones Hardhat repository and configures it to use a local clone of solc-js."
152
174
steps :
153
- - run : git clone --depth 1 "https://github.com/nomiclabs/hardhat" hardhat/
175
+ - fetch-latest-hardhat-release-tag
176
+ - run : git clone --depth 1 https://github.com/nomiclabs/hardhat.git --branch "$HARDHAT_LATEST_RELEASE_TAG" hardhat/
154
177
- install-dependencies :
155
178
cache-id : hardhat
156
179
path : hardhat
@@ -315,12 +338,15 @@ jobs:
315
338
- install-dependencies :
316
339
cache-id : hardhat-hackathon-boilerplate
317
340
path : boilerplate
341
+ - fetch-latest-hardhat-release-tag
318
342
- run :
319
343
name : Update to the latest Hardhat release
320
344
command : |
321
345
# We can just use a release here because injection does not require rebuilding it.
322
346
cd boilerplate/
323
- npm update hardhat
347
+ # Install the latest release of Hardhat if the version matches the expected format.
348
+ [[ "${HARDHAT_LATEST_RELEASE_TAG}" =~ ^hardhat@([0-9]+\.){2}[0-9]+$ ]] && npm install ${HARDHAT_LATEST_RELEASE_TAG}
349
+
324
350
- inject-solc-js-tarball :
325
351
path : boilerplate/
326
352
- run :
0 commit comments