mirror of
https://github.com/msberends/AMR.git
synced 2025-07-29 06:45:27 +02:00
(v3.0.0.9017) semantic versioning only on branch main
This commit is contained in:
87
.github/prehooks/pre-commit
vendored
87
.github/prehooks/pre-commit
vendored
@ -68,49 +68,56 @@ echo ""
|
|||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
echo "Updating semantic versioning and date..."
|
echo "Updating semantic versioning and date..."
|
||||||
|
|
||||||
# Get tags from remote and remove tags not on remote
|
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
||||||
git fetch origin --prune --prune-tags --quiet
|
if [ "$current_branch" != "main" ]; then
|
||||||
currenttagfull=$(git describe --tags --abbrev=0)
|
echo "- Current branch is '$current_branch'; skipping version/date update (only runs on 'main')"
|
||||||
currenttag=$(git describe --tags --abbrev=0 | sed 's/v//')
|
|
||||||
|
|
||||||
# Assume main branch to be 'main' or 'master'
|
|
||||||
defaultbranch=$(git branch | cut -c 3- | grep -E '^master$|^main$')
|
|
||||||
if [ "$currenttag" = "" ]; then
|
|
||||||
currenttag="0.0.1"
|
|
||||||
currentcommit=$(git rev-list --count ${defaultbranch})
|
|
||||||
echo "- No git tags found, creating one in format 'v(x).(y).(z)' - currently ${currentcommit} previous commits in '${defaultbranch}'"
|
|
||||||
else
|
else
|
||||||
currentcommit=$(git rev-list --count ${currenttagfull}..${defaultbranch})
|
# Version update logic begins here
|
||||||
echo "- Latest tag is '${currenttagfull}', with ${currentcommit} previous commits in '${defaultbranch}'"
|
|
||||||
fi
|
# Get tags from remote and remove tags not on remote
|
||||||
|
git fetch origin --prune --prune-tags --quiet
|
||||||
# Combine tag and commit number
|
currenttagfull=$(git describe --tags --abbrev=0)
|
||||||
currentversion="$currenttag.$((currentcommit + 9001))"
|
currenttag=$(git describe --tags --abbrev=0 | sed 's/v//')
|
||||||
echo "- ${currentpkg} pkg version set to ${currentversion}"
|
|
||||||
|
# Assume main branch to be 'main' or 'master'
|
||||||
# Update version number and date in DESCRIPTION
|
defaultbranch=$(git branch | cut -c 3- | grep -E '^master$|^main$')
|
||||||
sed -i -- "s/^Version: .*/Version: ${currentversion}/" DESCRIPTION
|
if [ "$currenttag" = "" ]; then
|
||||||
sed -i -- "s/^Date: .*/Date: $(date '+%Y-%m-%d')/" DESCRIPTION
|
currenttag="0.0.1"
|
||||||
echo "- Updated version number and date in ./DESCRIPTION"
|
currentcommit=$(git rev-list --count ${defaultbranch})
|
||||||
rm -f DESCRIPTION--
|
echo "- No git tags found, creating one in format 'v(x).(y).(z)' - currently ${currentcommit} previous commits in '${defaultbranch}'"
|
||||||
git add DESCRIPTION
|
else
|
||||||
|
currentcommit=$(git rev-list --count ${currenttagfull}..${defaultbranch})
|
||||||
# Update version number in NEWS.md
|
echo "- Latest tag is '${currenttagfull}', with ${currentcommit} previous commits in '${defaultbranch}'"
|
||||||
if [ -e "NEWS.md" ]; then
|
|
||||||
if [ "$currentpkg" = "your" ]; then
|
|
||||||
currentpkg=""
|
|
||||||
fi
|
fi
|
||||||
sed -i -- "1s/.*/# ${currentpkg} ${currentversion}/" NEWS.md
|
|
||||||
echo "- Updated version number in ./NEWS.md"
|
# Combine tag and commit number
|
||||||
rm -f NEWS.md--
|
currentversion="$currenttag.$((currentcommit + 9001))"
|
||||||
git add NEWS.md
|
echo "- ${currentpkg} pkg version set to ${currentversion}"
|
||||||
else
|
|
||||||
echo "- No NEWS.md found!"
|
# Update version number and date in DESCRIPTION
|
||||||
|
sed -i -- "s/^Version: .*/Version: ${currentversion}/" DESCRIPTION
|
||||||
|
sed -i -- "s/^Date: .*/Date: $(date '+%Y-%m-%d')/" DESCRIPTION
|
||||||
|
echo "- Updated version number and date in ./DESCRIPTION"
|
||||||
|
rm -f DESCRIPTION--
|
||||||
|
git add DESCRIPTION
|
||||||
|
|
||||||
|
# Update version number in NEWS.md
|
||||||
|
if [ -e "NEWS.md" ]; then
|
||||||
|
if [ "$currentpkg" = "your" ]; then
|
||||||
|
currentpkg=""
|
||||||
|
fi
|
||||||
|
sed -i -- "1s/.*/# ${currentpkg} ${currentversion}/" NEWS.md
|
||||||
|
echo "- Updated version number in ./NEWS.md"
|
||||||
|
rm -f NEWS.md--
|
||||||
|
git add NEWS.md
|
||||||
|
else
|
||||||
|
echo "- No NEWS.md found!"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Save the version number for use in the commit-msg hook
|
||||||
|
echo "${currentversion}" > .git/commit_version.tmp
|
||||||
fi
|
fi
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Save the version number for use in the commit-msg hook
|
|
||||||
echo "${currentversion}" > .git/commit_version.tmp
|
|
||||||
|
|
||||||
git add data-raw/*
|
git add data-raw/*
|
||||||
git add data/*
|
git add data/*
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 3.0.0.9016
|
Version: 3.0.0.9017
|
||||||
Date: 2025-07-23
|
Date: 2025-07-28
|
||||||
Title: Antimicrobial Resistance Data Analysis
|
Title: Antimicrobial Resistance Data Analysis
|
||||||
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||||
data analysis and to work with microbial and antimicrobial properties by
|
data analysis and to work with microbial and antimicrobial properties by
|
||||||
|
Reference in New Issue
Block a user