diff --git a/.github/workflows/hotfix_branch.yml b/.github/workflows/hotfix_branch.yml new file mode 100644 index 00000000..e02a5b6b --- /dev/null +++ b/.github/workflows/hotfix_branch.yml @@ -0,0 +1,32 @@ +name: Hotfix Branch + +on: + workflow_dispatch: + inputs: + tag_version: + description: 'Tag version' + required: true + +jobs: + create-branch: + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + steps: + - name: Checkout project + uses: actions/checkout@v4 + with: + token: ${{ secrets.CI_CD_TOKEN }} + + - name: Create hotfix branch + run: | + START_TAG=v${{ github.event.inputs.tag_version }} + echo "Start from tag $START_TAG" + MAJOR_MINOR_DIGIT=$(echo "$START_TAG" | cut -d '.' -f 1-2) + PATCH_DIGIT=$(echo "$START_TAG" | cut -d '.' -f 3) + NEW_PATCH_DIGIT=$((PATCH_DIGIT + 1)) + HOTFIX_VERSION="${MAJOR_MINOR_DIGIT}.${NEW_PATCH_DIGIT}" + HOTFIX_BRANCH_NAME="hotfix/$HOTFIX_VERSION" + echo "Create hotfix branch $HOTFIX_BRANCH_NAME" + git fetch --all + git checkout tags/$START_TAG -b $HOTFIX_BRANCH_NAME + git push origin $HOTFIX_BRANCH_NAME \ No newline at end of file diff --git a/.github/workflows/on_pull_request.yml b/.github/workflows/on_pull_request.yml index 42ebf3e3..f82eff9b 100644 --- a/.github/workflows/on_pull_request.yml +++ b/.github/workflows/on_pull_request.yml @@ -1,8 +1,8 @@ -name: Pull request +name: Pull Request on: pull_request: - branches: [ master ] + branches: [ master, hotfix/* ] jobs: build: @@ -33,7 +33,7 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: ${{ runner.os }}-gradle - - name: Check Style + - name: Check style run: ./gradlew checkstyleMain checkstyleTest - name: Build and analyze diff --git a/.github/workflows/on_push_master.yml b/.github/workflows/on_push_master.yml index f34618c9..7d788ab2 100644 --- a/.github/workflows/on_push_master.yml +++ b/.github/workflows/on_push_master.yml @@ -1,4 +1,4 @@ -name: Continuous integration +name: Continuous Integration on: push: diff --git a/.github/workflows/on_push_tag.yml b/.github/workflows/on_push_tag.yml index 7dc884e6..b6059729 100644 --- a/.github/workflows/on_push_tag.yml +++ b/.github/workflows/on_push_tag.yml @@ -45,7 +45,15 @@ jobs: report_paths: '**/build/test-results/test/TEST-*.xml' - name: Docker - run: ./gradlew dockerBuild dockerPush -PreleaseLatest + run: | + LATEST_VERSION=$(git tag -l --sort=-version:refname | head -1 | cut -d 'v' -f 2) + if [ "$LATEST_VERSION" == "${{ steps.build_jar.outputs.current_version }}" ]; then + echo "Latest version is $LATEST_VERSION. Current version is ${{ steps.build_jar.outputs.current_version }}. Pushing latest tag." + ./gradlew dockerBuild dockerPush -PreleaseLatest + else + echo "Latest version is $LATEST_VERSION. Current version is ${{ steps.build_jar.outputs.current_version }}. Not pushing latest tag." + ./gradlew dockerBuild dockerPush + fi - name: Generate release changelog uses: mikepenz/release-changelog-builder-action@v5 diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 476dc63f..1b115475 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -10,7 +10,7 @@ on: jobs: tag: runs-on: ubuntu-latest - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/hotfix/v') steps: - name: Checkout project uses: actions/checkout@v4