1919 outputs :
2020 # Used to conditionally run publish steps and notifications
2121 client_version : ${{steps.calc_version.outputs.version}}
22+ should_publish : ${{steps.check_changes.outputs.has_changes}}
23+
2224 permissions :
2325 contents : write
2426 pull-requests : write
@@ -32,18 +34,43 @@ jobs:
3234 path : Xero-NetStandard
3335 fetch-depth : 0 # Fetch all history for git diff
3436
35- - name : Calculate OAuth2Client version
36- id : calc_version
37+ - name : Check for changes
38+ id : check_changes
3739 run : |
3840 # Get last client tag
3941 LAST_CLIENT_TAG=$(git tag -l 'client-*' --sort=-v:refname | head -n 1)
42+ echo "Found last client tag: $LAST_CLIENT_TAG"
43+ echo "last_client_tag=$LAST_CLIENT_TAG" >> $GITHUB_OUTPUT
44+
45+ if [ -z "$LAST_CLIENT_TAG" ]; then
46+ echo "No previous client tag found. Treating as changed (initial release)."
47+ echo "has_changes=true" >> $GITHUB_OUTPUT
48+ exit 0
49+ fi
50+
51+ # Check if OAuth2Client files changed since last client tag
52+ if git diff --name-only $LAST_CLIENT_TAG HEAD | grep -q 'Xero.NetStandard.OAuth2Client/'; then
53+ echo "Changes detected in Xero.NetStandard.OAuth2Client/"
54+ echo "has_changes=true" >> $GITHUB_OUTPUT
55+ else
56+ echo "No changes detected in Xero.NetStandard.OAuth2Client/"
57+ echo "has_changes=false" >> $GITHUB_OUTPUT
58+ fi
59+ working-directory : Xero-NetStandard
60+ env :
61+ GH_TOKEN : ${{secrets.GITHUB_TOKEN}}
62+
63+ - name : Calculate OAuth2Client version
64+ id : calc_version
65+ if : steps.check_changes.outputs.has_changes == 'true'
66+ run : |
67+ LAST_CLIENT_TAG="${{ steps.check_changes.outputs.last_client_tag }}"
4068
4169 if [ -z "$LAST_CLIENT_TAG" ]; then
4270 # No previous client tag, start with version from csproj
4371 CURRENT_VERSION=$(grep '<Version>' ./Xero.NetStandard.OAuth2Client/Xero.NetStandard.OAuth2Client.csproj | sed 's/.*<Version>\(.*\)<\/Version>.*/\1/')
4472 echo "No previous client tag found, using csproj version: $CURRENT_VERSION"
4573 echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
46- echo "should_publish=true" >> $GITHUB_OUTPUT
4774 exit 0
4875 fi
4976
@@ -71,28 +98,18 @@ jobs:
7198 fi
7299 echo "Detected bump type: $BUMP_TYPE"
73100
74- # Check if OAuth2Client files changed since last client tag
75- if git diff --name-only $LAST_CLIENT_TAG HEAD | grep -q 'Xero.NetStandard.OAuth2Client/'; then
76- echo "OAuth2Client files have changed since $LAST_CLIENT_TAG"
77-
78- # Increment version based on bump type
79- IFS='.' read -r c1 c2 c3 <<< "$LAST_VERSION"
80- if [ "$BUMP_TYPE" == "major" ]; then
81- NEW_VERSION="$((c1 + 1)).0.0"
82- elif [ "$BUMP_TYPE" == "minor" ]; then
83- NEW_VERSION="${c1}.$((c2 + 1)).0"
84- else
85- NEW_VERSION="${c1}.${c2}.$((c3 + 1))"
86- fi
87-
88- echo "Incrementing version ($BUMP_TYPE): $LAST_VERSION -> $NEW_VERSION"
89- echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
90- echo "should_publish=true" >> $GITHUB_OUTPUT
101+ # Increment version based on bump type
102+ IFS='.' read -r c1 c2 c3 <<< "$LAST_VERSION"
103+ if [ "$BUMP_TYPE" == "major" ]; then
104+ NEW_VERSION="$((c1 + 1)).0.0"
105+ elif [ "$BUMP_TYPE" == "minor" ]; then
106+ NEW_VERSION="${c1}.$((c2 + 1)).0"
91107 else
92- echo "No changes to OAuth2Client since $LAST_CLIENT_TAG"
93- echo "version=$LAST_VERSION" >> $GITHUB_OUTPUT
94- echo "should_publish=false" >> $GITHUB_OUTPUT
108+ NEW_VERSION="${c1}.${c2}.$((c3 + 1))"
95109 fi
110+
111+ echo "Incrementing version ($BUMP_TYPE): $LAST_VERSION -> $NEW_VERSION"
112+ echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
96113 working-directory : Xero-NetStandard
97114 env :
98115 GH_TOKEN : ${{secrets.GITHUB_TOKEN}}
0 commit comments