Skip to content

Commit 59c4bfa

Browse files
authored
[DX-3569] ci: update update-version.yml (#173)
* ci: update update-version.yml * ci: update update-version.yml * ci: fix update-version.yml pr step
1 parent fadfd4a commit 59c4bfa

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

.github/workflows/update-version.yml

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ name: "Update engine SDK version in ImmutableDataTypes.h"
44
on:
55
workflow_dispatch:
66
inputs:
7-
version:
8-
description: 'Version to update to (e.g. 1.20.0)'
7+
upgrade_type:
8+
type: choice
9+
description: Upgrade Type
10+
options:
11+
- patch
12+
- minor
13+
# - major
914
required: true
15+
default: patch
1016

1117
jobs:
1218
update:
@@ -33,15 +39,47 @@ jobs:
3339
id: replace_engine_sdk_version
3440
run: |
3541
FILE=./Source/Immutable/Public/Immutable/ImmutableDataTypes.h
36-
VERSION=${{ github.event.inputs.version }}
37-
sed -i -E "s/#define ENGINE_SDK_VERSION TEXT\(\"[0-9]+\.[0-9]+\.[0-9]+\"\)/#define ENGINE_SDK_VERSION TEXT(\"$VERSION\")/g" $FILE
42+
UPGRADE_TYPE=${{ github.event.inputs.upgrade_type }}
43+
44+
RAW_VERSION=$(grep -oP '#define ENGINE_SDK_VERSION TEXT\("\K[0-9]+\.[0-9]+\.[0-9]+(\.[a-zA-Z]+)?' $FILE)
45+
46+
VERSION=$(echo "$RAW_VERSION" | grep -oP '^[0-9]+\.[0-9]+\.[0-9]+')
47+
48+
IFS='.' read -r major minor patch <<< "$VERSION"
49+
50+
# If the version had an alpha suffix, adjust the version bump behavior
51+
if [[ "$RAW_VERSION" == *".alpha" ]]; then
52+
if [ "$UPGRADE_TYPE" == "patch" ]; then
53+
# Remove alpha suffix, keep the same version
54+
UPDATED_VERSION="$major.$minor.$patch"
55+
elif [ "$UPGRADE_TYPE" == "minor" ]; then
56+
# E.g. skip 1.3.0, go directly to 1.4.0
57+
minor=$((minor + 1))
58+
patch=0
59+
UPDATED_VERSION="$major.$minor.$patch"
60+
fi
61+
else
62+
# Increment patch or minor
63+
if [ "$UPGRADE_TYPE" == "patch" ]; then
64+
patch=$((patch + 1))
65+
elif [ "$UPGRADE_TYPE" == "minor" ]; then
66+
minor=$((minor + 1))
67+
patch=0
68+
fi
69+
UPDATED_VERSION="$major.$minor.$patch"
70+
fi
71+
72+
sed -i -E "s/#define ENGINE_SDK_VERSION TEXT\(\"[0-9]+\.[0-9]+\.[0-9]+(\.[a-zA-Z]+)?\"\)/#define ENGINE_SDK_VERSION TEXT(\"$UPDATED_VERSION\")/g" $FILE
73+
74+
echo "Updated version: $UPDATED_VERSION"
75+
echo "version=$UPDATED_VERSION" >> "$GITHUB_OUTPUT"
3876

3977
- uses: gr2m/create-or-update-pull-request-action@v1
4078
env:
4179
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4280
with:
4381
title: "chore: update version"
4482
body: "Update version in ImmutableDataTypes.h"
45-
branch: "chore/update-version-${{ github.event.inputs.version }}"
83+
branch: "chore/update-version-${{ steps.replace_engine_sdk_version.outputs.version }}"
4684
commit-message: "chore: update version"
4785
labels: release

0 commit comments

Comments
 (0)