Skip to content

Semantic Version Bump #1193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
75 changes: 75 additions & 0 deletions .github/workflows/semantic-bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Semantic Version Bump (Conventional Commits)

on:
push:
branches:
- main

jobs:
semver-bump:
runs-on: ubuntu-latest
if: github.event.head_commit.author.name != 'github-actions[bot]'

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Determine bump type from commit message
id: bump
run: |
COMMIT_MSG="${{ github.event.head_commit.message }}"
echo "🔍 Commit message: $COMMIT_MSG"

if echo "$COMMIT_MSG" | grep -qE 'BREAKING CHANGE|!:'; then
echo "bump=major" >> $GITHUB_OUTPUT
elif echo "$COMMIT_MSG" | grep -qE '^feat(\(.+\))?:'; then
echo "bump=minor" >> $GITHUB_OUTPUT
elif echo "$COMMIT_MSG" | grep -qE '^fix(\(.+\))?:'; then
echo "bump=patch" >> $GITHUB_OUTPUT
else
echo "bump=none" >> $GITHUB_OUTPUT
fi

- name: Bump version in fxmanifest.lua
if: steps.bump.outputs.bump != 'none'
run: |
FILE="fxmanifest.lua"
VERSION_LINE=$(grep -E "version ['\"]?[0-9]+\.[0-9]+\.[0-9]+['\"]?" "$FILE")
VERSION=$(echo "$VERSION_LINE" | grep -oE "[0-9]+\.[0-9]+\.[0-9]+")

IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"

case "${{ steps.bump.outputs.bump }}" in
major)
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
minor)
MINOR=$((MINOR + 1))
PATCH=0
;;
patch)
PATCH=$((PATCH + 1))
;;
esac

NEW_VERSION="$MAJOR.$MINOR.$PATCH"
sed -i "s/version ['\"]$VERSION['\"]/version '$NEW_VERSION'/" "$FILE"
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV

- name: Commit and push version bump
if: steps.bump.outputs.bump != 'none'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add fxmanifest.lua

if git diff --cached --quiet; then
echo "⚠️ No version changes to commit."
exit 0
fi

COMMIT_MSG="${{ github.event.head_commit.message }}"
git commit -m "ci: bump fxmanifest version to ${{ env.new_version }} – $COMMIT_MSG"
git push
6 changes: 2 additions & 4 deletions server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ QBCore.UsableItems = {}
-- Get your player first and then trigger a function on them
-- ex: local player = QBCore.Functions.GetPlayer(source)
-- ex: local example = player.Functions.functionname(parameter)

---Gets the coordinates of an entity
---@param entity number
---@return vector4
Expand Down Expand Up @@ -395,9 +394,9 @@ function QBCore.Functions.CreateVehicle(source, model, vehtype, coords, warp)
end

function PaycheckInterval()
if not next(QBCore.Players) then
if not next(QBCore.Players) then
SetTimeout(QBCore.Config.Money.PayCheckTimeOut * (60 * 1000), PaycheckInterval) -- Prevent paychecks from stopping forever once 0 players
return
return
end
for _, Player in pairs(QBCore.Players) do
if not Player then return end
Expand Down Expand Up @@ -734,6 +733,5 @@ for functionName, func in pairs(QBCore.Functions) do
exports(functionName, func)
end
end

-- Access a specific function directly:
-- exports['qb-core']:Notify(source, 'Hello Player!')