-
Notifications
You must be signed in to change notification settings - Fork 0
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 #50 from mrc-ide/mrc-4863
Add script to check version numbers
- Loading branch information
Showing
4 changed files
with
82 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,24 @@ | ||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
- main | ||
|
||
name: Check Version | ||
|
||
jobs: | ||
all: | ||
runs-on: ubuntu-latest | ||
|
||
name: Check Version | ||
|
||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Check version format and availability | ||
run: ./scripts/check_version |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: hipercow | ||
Title: High Performance Computing | ||
Version: 0.1.0 | ||
Version: 0.2.0 | ||
Authors@R: c(person("Rich", "FitzJohn", role = c("aut", "cre"), | ||
email = "[email protected]"), | ||
person("Wes", "Hinsley", role = "aut"), | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: hipercow.windows | ||
Title: DIDE HPC Support for Windows | ||
Version: 0.1.0 | ||
Version: 0.2.0 | ||
Authors@R: c(person("Rich", "FitzJohn", role = c("aut", "cre"), | ||
email = "[email protected]"), | ||
person("Wes", "Hinsley", role = "aut"), | ||
|
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,56 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
# Usage: | ||
# check_version [<version>] | ||
# | ||
# If version is not given as a positional argument, then we'll read it | ||
# from the DESCRIPTION file. | ||
# | ||
# We assume that a version already exists as a tag. | ||
VERSION=${1:-$(grep '^Version' DESCRIPTION | sed 's/.*: *//')} | ||
TAG="v${VERSION}" | ||
|
||
echo "Proposed version number '$VERSION'" | ||
|
||
if echo "$VERSION" | grep -Eq "[0-9]+[.][0-9]+[.][0-9]+"; then | ||
echo "[OK] Version number in correct format" | ||
else | ||
echo "[ERROR] Invalid format version number '$VERSION' must be in format 'x.y.z'" | ||
exit 1 | ||
fi | ||
|
||
EXIT_CODE=0 | ||
|
||
LAST_VERSION=$(git show origin/main:DESCRIPTION | grep '^Version' | sed 's/.*: *//') | ||
|
||
echo "Last version was '$LAST_VERSION'" | ||
|
||
MAJOR=$(echo $VERSION | cut -d. -f1) | ||
MINOR=$(echo $VERSION | cut -d. -f2) | ||
PATCH=$(echo $VERSION | cut -d. -f3) | ||
|
||
LAST_VERSION=$(echo "$LAST_VERSION" | sed 's/^v//') | ||
LAST_MAJOR=$(echo $LAST_VERSION | cut -d. -f1) | ||
LAST_MINOR=$(echo $LAST_VERSION | cut -d. -f2) | ||
LAST_PATCH=$(echo $LAST_VERSION | cut -d. -f3) | ||
|
||
if (( $MAJOR > $LAST_MAJOR )); then | ||
echo "[OK] ${VERSION} increases MAJOR version over old version ${LAST_VERSION}" | ||
elif (( $MINOR > $LAST_MINOR )); then | ||
echo "[OK] ${VERSION} increases MINOR version over old version ${LAST_VERSION}" | ||
elif (( $PATCH > $LAST_PATCH )); then | ||
echo "[OK] ${VERSION} increases PATCH version over old version ${LAST_VERSION}" | ||
else | ||
echo "[ERROR] Version number has not increased relative to $LAST_VERSION" | ||
EXIT_CODE=1 | ||
fi | ||
|
||
WINDOWS_VERSION=$(grep '^Version' drivers/windows/DESCRIPTION | sed 's/.*: *//') | ||
if [[ $WINDOWS_VERSION == $VERSION ]]; then | ||
echo "[OK] windows driver version agrees" | ||
else | ||
echo "[ERROR] windows driver version (${WINDOWS_VERSION}) disagrees with this version (${VERSION})" | ||
EXIT_CODE=1 | ||
fi | ||
|
||
exit $EXIT_CODE |