feat: blah

This commit is contained in:
Aleksandr Chikovani 2023-08-27 21:38:31 -04:00
parent f6dda5c99a
commit 73ac3a3971
2 changed files with 56 additions and 10 deletions

View file

@ -21,21 +21,66 @@ jobs:
- name: Codestyle
id: semantic
run: |
# Get the current branch name
set -x
function bump_version {
# Split the version string into Major, Minor and Patch numbers
local VERSION=(${1//"v"})
local BRANCH_NAME="$2"
local MAJOR=${VERSION[0]}
local MINOR=${VERSION[1]}
local PATCH=${VERSION[2]}
# Increment the version number
if [[ "$BRANCH_NAME" == "development" ]]; then
MINOR=$((MINOR + 1))
PATCH=0
rc="-rc"
elif [[ "$BRANCH_NAME" == release-* ]]; then
PATCH=$((PATCH + 1))
rc=""
fi
# Build the new version string
NEXT_VERSION="v${MAJOR}.${MINOR}.${PATCH}${rc}"
}
CURRENT_BRANCH=$(git symbolic-ref -q HEAD)
CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/}
CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD}
echo "Current branch: $CURRENT_BRANCH"
git fetch --tags
# Get a list of all tags in the repository
git fetch --prune --unshallow --tags
TAG_LIST=$(git tag)
echo "Available tags: $TAG_LIST"
TAGS=$(git tag)
HAS_TAGS=$(echo "$TAGS" | wc -l | tr -d ' ')
if [[ "$HAS_TAGS" -eq 0 ]]; then
# No tags found
if [[ "$CURRENT_BRANCH" == "development" ]]; then
# For development branch with no tags, set the next version to 0.1.0-rc
NEXT_VERSION="v0.1.0-rc"
fi
else
# Tags found
if [[ "$CURRENT_BRANCH" == "development" ]]; then
CURRENT_VERSION=$(git describe --tags --abbrev=0)
NEXT_VERSION=$(bump_version "${CURRENT_VERSION}" "${CURRENT_BRANCH}")
elif [[ "${CURRENT_BRANCH}" == release-* ]]; then
# For release branch with tags, bump patch version, e.g. v2.3.4 -> v2.3.5
CURRENT_VERSION=$(git describe --tags --abbrev=0 --match "v${CURRENT_BRANCH#"release-"}.*" 2>/dev/null)
if [[ -n "$CURRENT_VERSION" ]]; then
NEXT_VERSION=$(bump_version "${CURRENT_VERSION}" "${CURRENT_BRANCH}")
else
# If no tags match the release branch, set the next version to release number with 0 patch version, e.g. v-0.1.0
BRANCH_VERSION=${CURRENT_BRANCH#"release-"}
NEXT_VERSION="v${BRANCH_VERSION}.0"
fi
else
exit 2
fi
fi
echo "::set-output name=current_version::${CURRENT_VERSION}"
echo "::set-output name=next_version::${NEXT_VERSION}"
# Get the messages of the last three commits on the current branch
COMMIT_MESSAGES=$(git log --pretty=format:%s -n 1)
echo "Last commit message:"
echo "$COMMIT_MESSAGES"
#- uses: docker://ghcr.io/codfish/semantic-release-action@sha256:4675eae74abbabc869298ca798833fef291ce30fb9edfac76787746e7d9d3904
# id: semantic
# with:

View file

@ -21,6 +21,7 @@ jobs:
code_checks:
runs-on: ubuntu-latest
#TODO: cache for libs
steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{matrix.java}}