From 73ac3a397159690ef89f402f8db90e7324bb8cab Mon Sep 17 00:00:00 2001 From: Aleksandr Chikovani Date: Sun, 27 Aug 2023 21:38:31 -0400 Subject: [PATCH] feat: blah --- .github/workflows/docker-publish.yml | 65 +++++++++++++++++++++++----- .github/workflows/gradle-build.yml | 1 + 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index d38867c01..00d873556 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -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: diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml index 5071e2937..e95a17211 100644 --- a/.github/workflows/gradle-build.yml +++ b/.github/workflows/gradle-build.yml @@ -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}}