Skip to content

Commit

Permalink
Add hotfix management
Browse files Browse the repository at this point in the history
  • Loading branch information
loicgreffier committed Oct 31, 2024
1 parent e87da07 commit 9313d41
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/hotfix_branch.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions .github/workflows/on_pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Pull request
name: Pull Request

on:
pull_request:
branches: [ master ]
branches: [ master, hotfix/* ]

jobs:
build:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on_push_master.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Continuous integration
name: Continuous Integration

on:
push:
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/on_push_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9313d41

Please sign in to comment.