Skip to content

Commit be0add6

Browse files
authored
Merge pull request #739 from ethereum/ci-hardhat-releases
Use hardhat latest releases instead of main branch
2 parents 4ab32d8 + 4164296 commit be0add6

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

.circleci/config.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,33 @@ commands:
147147
exit 1
148148
fi
149149
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+
150172
provision-hardhat-with-packaged-solcjs:
151173
description: "Clones Hardhat repository and configures it to use a local clone of solc-js."
152174
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/
154177
- install-dependencies:
155178
cache-id: hardhat
156179
path: hardhat
@@ -315,12 +338,15 @@ jobs:
315338
- install-dependencies:
316339
cache-id: hardhat-hackathon-boilerplate
317340
path: boilerplate
341+
- fetch-latest-hardhat-release-tag
318342
- run:
319343
name: Update to the latest Hardhat release
320344
command: |
321345
# We can just use a release here because injection does not require rebuilding it.
322346
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+
324350
- inject-solc-js-tarball:
325351
path: boilerplate/
326352
- run:

0 commit comments

Comments
 (0)