Skip to content

Commit

Permalink
Merge branch 'develop' into review/asset-streamer
Browse files Browse the repository at this point in the history
  • Loading branch information
zpl-zak committed Feb 21, 2025
2 parents 465a20e + ef072ec commit 162d109
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 28 deletions.
6 changes: 5 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ If you feel up for it, feel free to code and pull request any changes you've mad

We loosely follow semver to enforce build requirements between networked peers.

Please ensure your PR modifies the VERSION file and bumps:
We separate and bump versions based on these criteria:
* PATCH when changes were made to either side that do not affect sync between peers nor the scripting layer itself (could also be cosmetic/meta changes)
* MINOR when a change is made in the scripting layer
* MAJOR when a change is made to the netcode, shared ecs modules or sync flow between peers (requires both client and the server side to be updated)

Our PR workflow automates version bumping for you based on files that have been modified. This way we ensure each PR properly communicates potential dependency changes.

Make sure to tag your PR as [PATCH] in case you wish to hotfix an existing code.

## Code submission policy

Please follow the following rules when contributing to the project:
Expand Down
92 changes: 92 additions & 0 deletions .github/bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash
set -e

# Get the PR title from the first argument.
PR_TITLE="$1"
if [[ -z "$PR_TITLE" ]]; then
echo "Error: PR title must be passed as the first argument."
exit 1
fi

echo "PR Title: $PR_TITLE"

# Get the list of changed files between the merge commit and its first parent.
mapfile -t changed_files < <(git diff --name-only HEAD^ HEAD)
echo "Changed files: ${changed_files[@]}"

# Default bump type is patch.
BUMP_TYPE="patch"

# Define arrays for directories that trigger a major or minor bump.
major_paths=(
"code/framework/src/networking/messages"
"code/framework/src/networking/rpc"
)
minor_paths=(
"code/framework/src/scripting/builtins"
"code/framework/src/integrations/server/scripting/builtins"
)

pr_title_lower=$(echo "$PR_TITLE" | tr '[:upper:]' '[:lower:]')

# Check if PR title enforces a PATCH bump.
if [[ "$pr_title_lower" == *"[patch]"* ]]; then
echo "PR title contains [patch]. Enforcing PATCH bump."
BUMP_TYPE="patch"
else
# Check for major bump directories.
for file in "${changed_files[@]}"; do
for major in "${major_paths[@]}"; do
if [[ "$file" == "$major"* ]]; then
BUMP_TYPE="major"
break 2
fi
done
done

# If no major changes were found, check for minor bump directories.
if [[ "$BUMP_TYPE" != "major" ]]; then
for file in "${changed_files[@]}"; do
for minor in "${minor_paths[@]}"; do
if [[ "$file" == "$minor"* ]]; then
BUMP_TYPE="minor"
break 2
fi
done
done
fi
fi

echo "Determined bump type: $BUMP_TYPE"

# Ensure VERSION file exists.
if [ ! -f VERSION ]; then
echo "VERSION file not found. Creating VERSION with default value 0.0.0."
echo "0.0.0" > VERSION
fi

# Read the current version from the VERSION file.
CURRENT_VERSION=$(cat VERSION)
echo "Current version: $CURRENT_VERSION"

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

# Calculate the new version based on the bump type.
case "$BUMP_TYPE" in
major)
NEW_MAJOR=$((MAJOR + 1))
NEW_VERSION="$NEW_MAJOR.0.0"
;;
minor)
NEW_MINOR=$((MINOR + 1))
NEW_VERSION="$MAJOR.$NEW_MINOR.0"
;;
patch)
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
;;
esac

# Update the VERSION file with the new version.
echo "$NEW_VERSION" > VERSION
echo "Updated version set to: $NEW_VERSION"
26 changes: 24 additions & 2 deletions .github/workflows/pr_tag_commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,32 @@ on:
types: [closed]
branches: [develop]

jobs:
evaluate-release:
jobs:
bump-semver:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure full history for diff comparisons

- name: Run bump semver script
run: |
chmod +x ./.github/bump_version.sh
./.github/bump_version.sh "${{ github.event.pull_request.title }}"
- name: Commit version bump
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add VERSION
git diff-index --quiet HEAD || git commit -m "Bump version to $(cat VERSION) [skip ci]"
git push origin HEAD:develop --follow-tags
evaluate-release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
needs: bump-semver
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
24 changes: 0 additions & 24 deletions .github/workflows/pr_version_check.yml

This file was deleted.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
1.8.1

0 comments on commit 162d109

Please sign in to comment.