Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/auto-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: 'Auto Tag on Merge'

on:
push:
branches:
- main

jobs:
tag:
name: 'Create and push tag'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: 'Checkout'
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 'Get latest tag'
id: get-latest-tag
run: |
# Get the latest tag, default to v0.0.0 if no tags exist
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "Latest tag: $LATEST_TAG"
echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT

- name: 'Bump version'
id: bump-version
run: |
LATEST_TAG="${{ steps.get-latest-tag.outputs.latest_tag }}"

# Remove 'v' prefix if present
VERSION=${LATEST_TAG#v}

# Split version into major, minor, patch
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"

# Check commit message for version bump hints
COMMIT_MSG=$(git log -1 --pretty=%B)

if echo "$COMMIT_MSG" | grep -qiE '\[major\]|breaking change'; then
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
elif echo "$COMMIT_MSG" | grep -qiE '\[minor\]|feature'; then
MINOR=$((MINOR + 1))
PATCH=0
else
PATCH=$((PATCH + 1))
fi

NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}"
echo "New version: $NEW_VERSION"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT

- name: 'Create and push tag'
env:
NEW_VERSION: ${{ steps.bump-version.outputs.new_version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

git tag -a "$NEW_VERSION" -m "Auto-generated release $NEW_VERSION"
git push origin "$NEW_VERSION"

echo "Created and pushed tag: $NEW_VERSION"

- name: 'Create summary'
run: |
echo "### 🏷️ Auto-tagged release" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ steps.bump-version.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY
echo "**Previous:** ${{ steps.get-latest-tag.outputs.latest_tag }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Tip:** Use \`[major]\`, \`[minor]\` in commit messages to control version bumps. Default is patch." >> $GITHUB_STEP_SUMMARY
9 changes: 7 additions & 2 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ on:
required: false
type: string
default: "ubuntu-latest"
enable-dependency-cache:
description: 'Enable dependency check caching'
required: false
type: boolean
default: true

jobs:
build:
Expand Down Expand Up @@ -94,7 +99,7 @@ jobs:
echo "version=v$VERSION" >> $GITHUB_OUTPUT

- name: 'Restore Dependency Check Cache'
if: ${{ inputs.full-run == true }}
if: ${{ inputs.full-run == true && inputs.enable-dependency-cache == true }}
id: cache-restore
uses: actions/cache/restore@v4
with:
Expand All @@ -107,7 +112,7 @@ jobs:
run: ./gradlew dependencyCheckAnalyze

- name: 'Save Dependency Check Cache'
if: ${{ inputs.full-run == true }}
if: ${{ inputs.full-run == true && inputs.enable-dependency-cache == true }}
uses: actions/cache/save@v4
id: cache-save
with:
Expand Down