Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): include version/cli checks in tagged releases #7331

Merged
merged 1 commit into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ jobs:
- run: sudo apt-get install npm
- run:
command: make buildall
- run:
name: check tag and version output match
command: ./scripts/version-check.sh ./lotus
- store_artifacts:
path: lotus
- store_artifacts:
Expand Down Expand Up @@ -383,6 +386,9 @@ jobs:
- run:
command: make build
no_output_timeout: 30m
- run:
name: check tag and version output match
command: ./scripts/version-check.sh ./lotus
- store_artifacts:
path: lotus
- store_artifacts:
Expand Down
6 changes: 6 additions & 0 deletions .circleci/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ jobs:
- run: sudo apt-get install npm
- run:
command: make buildall
- run:
name: check tag and version output match
command: ./scripts/version-check.sh ./lotus
- store_artifacts:
path: lotus
- store_artifacts:
Expand Down Expand Up @@ -383,6 +386,9 @@ jobs:
- run:
command: make build
no_output_timeout: 30m
- run:
name: check tag and version output match
command: ./scripts/version-check.sh ./lotus
- store_artifacts:
path: lotus
- store_artifacts:
Expand Down
39 changes: 39 additions & 0 deletions scripts/version-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -ex

# Validate lotus version matches the current tag
# $1 - lotus path to execute
# $2 - lotus git tag for this release
function validate_lotus_version_matches_tag(){
# sanity checks
if [[ $# != 2 ]]; then
echo "expected 2 args for validate_lotus_version, got ${$#}"
exit 100
fi

# extract version from `lotus --version` response
lotus_path=$1
# get version
lotus_raw_version=`${lotus_path} --version`
# grep for version string
lotus_actual_version=`echo ${lotus_raw_version} | grep -oE '[0-9]+.[0-9]+.[0-9]+'`

# trim leading 'v'
tag=${2#v}
# trim possible -rc[0-9]
expected_version=${tag%-*}

# check the versions are consistent
if [[ ${expected_version} != ${lotus_actual_version} ]]; then
echo "lotus version does not match build tag"
exit 101
fi
}

_lotus_path=$1

if [[ ! -z "${CIRCLE_TAG}" ]]; then
validate_lotus_version_matches_tag "${_lotus_path}" "${CIRCLE_TAG}"
else
echo "No CI tag found. Skipping version check."
fi