Skip to content

Commit 1844cd8

Browse files
author
Ryan McCarthy
committed
[PETOSS-829] updated version to match bump of main sdk so a bump of 0.0.1 in the main will do the same to this package
1 parent 0dce143 commit 1844cd8

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

.github/workflows/publish-Oauth2Client-package.yml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
type: string
99
push:
1010
tags:
11-
- '[0-9]+.[0-9]+.[0-9]+' # Triggers on main SDK version tags
11+
- '[0-9]+.[0-9]+.[0-9]+' # Triggers on main SDK version tags to check if Client SDK needs update
1212

1313
jobs:
1414
check-and-publish:
@@ -17,6 +17,7 @@ jobs:
1717
environment: prod
1818

1919
outputs:
20+
# Used to conditionally run publish steps and notifications
2021
client_version: ${{steps.calc_version.outputs.version}}
2122
should_publish: ${{steps.calc_version.outputs.should_publish}}
2223

@@ -51,15 +52,42 @@ jobs:
5152
LAST_VERSION=${LAST_CLIENT_TAG#client-}
5253
echo "Last OAuth2Client version: $LAST_VERSION (tag: $LAST_CLIENT_TAG)"
5354
55+
# Determine Bump Type from Main SDK tags
56+
BUMP_TYPE="patch"
57+
if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
58+
CURRENT_MAIN_TAG=$GITHUB_REF_NAME
59+
# Find previous main tag (exclude current)
60+
PREV_MAIN_TAG=$(git tag -l '[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | grep -v "^$CURRENT_MAIN_TAG$" | head -n 1)
61+
62+
if [ ! -z "$PREV_MAIN_TAG" ]; then
63+
echo "Main SDK Bump: $PREV_MAIN_TAG -> $CURRENT_MAIN_TAG"
64+
IFS='.' read -r m1 m2 m3 <<< "$CURRENT_MAIN_TAG"
65+
IFS='.' read -r p1 p2 p3 <<< "$PREV_MAIN_TAG"
66+
67+
if [ "$m1" != "$p1" ]; then
68+
BUMP_TYPE="major"
69+
elif [ "$m2" != "$p2" ]; then
70+
BUMP_TYPE="minor"
71+
fi
72+
fi
73+
fi
74+
echo "Detected bump type: $BUMP_TYPE"
75+
5476
# Check if OAuth2Client files changed since last client tag
5577
if git diff --name-only $LAST_CLIENT_TAG HEAD | grep -q 'Xero.NetStandard.OAuth2Client/'; then
5678
echo "OAuth2Client files have changed since $LAST_CLIENT_TAG"
5779
58-
# Increment patch version
59-
IFS='.' read -r major minor patch <<< "$LAST_VERSION"
60-
NEW_VERSION="${major}.${minor}.$((patch + 1))"
80+
# Increment version based on bump type
81+
IFS='.' read -r c1 c2 c3 <<< "$LAST_VERSION"
82+
if [ "$BUMP_TYPE" == "major" ]; then
83+
NEW_VERSION="$((c1 + 1)).0.0"
84+
elif [ "$BUMP_TYPE" == "minor" ]; then
85+
NEW_VERSION="${c1}.$((c2 + 1)).0"
86+
else
87+
NEW_VERSION="${c1}.${c2}.$((c3 + 1))"
88+
fi
6189
62-
echo "Incrementing version: $LAST_VERSION -> $NEW_VERSION"
90+
echo "Incrementing version ($BUMP_TYPE): $LAST_VERSION -> $NEW_VERSION"
6391
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
6492
echo "should_publish=true" >> $GITHUB_OUTPUT
6593
else

0 commit comments

Comments
 (0)