4747 working-directory : ./rust/main
4848 run : |
4949 # Get latest agents-v* tag
50- LATEST_TAG=$(git tag -l "agents-v*" --sort=-version:refname | grep -E "^ agents-v[0-9]+\.[0-9]+\.[0-9]+$" | head -1 )
50+ LATEST_TAG=$(../scripts/get-latest- agents-tag.sh )
5151
5252 if [ -z "$LATEST_TAG" ]; then
5353 echo "No previous release found"
@@ -70,12 +70,12 @@ jobs:
7070 working-directory : ./rust/main
7171 run : |
7272 # Get current version from Cargo.toml workspace.package.version
73- CURRENT_VERSION=$(grep -A 10 '^\[workspace\.package\]' Cargo.toml | grep '^version = ' | head -1 | sed 's/ version = "\(.*\)"/\1/' )
73+ CURRENT_VERSION=$(../scripts/get-workspace- version.sh )
7474 echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
7575 echo "Current workspace version: $CURRENT_VERSION"
7676
7777 # Get latest agents-v* tag
78- LATEST_TAG=$(git tag -l "agents-v*" --sort=-version:refname | grep -E "^ agents-v[0-9]+\.[0-9]+\.[0-9]+$" | head -1 )
78+ LATEST_TAG=$(../scripts/get-latest- agents-tag.sh )
7979
8080 if [ -z "$LATEST_TAG" ]; then
8181 echo "latest_version=" >> $GITHUB_OUTPUT
@@ -109,63 +109,14 @@ jobs:
109109 - uses : dtolnay/rust-toolchain@stable
110110 - name : Determine next version from conventional commits
111111 id : next_version
112- working-directory : ./rust/main
113112 env :
114113 CURRENT_VERSION : ${{ needs.check-release-status.outputs.current_version }}
115114 run : |
116- # Get commits since last release
117- LATEST_TAG=$(git tag -l "agents-v*" --sort=-version:refname | grep -E "^agents-v[0-9]+\.[0-9]+\.[0-9]+$" | head -1)
118-
119- if [ -z "$LATEST_TAG" ]; then
120- COMMITS=$(git log --oneline --no-merges -- .)
121- else
122- COMMITS=$(git log "${LATEST_TAG}..HEAD" --oneline --no-merges -- .)
123- fi
124-
125- # Parse current version
126- IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
127-
128- # Analyze commits for conventional commit types
129- HAS_BREAKING=false
130- HAS_MINOR=false
131- HAS_PATCH=false
132-
133- while IFS= read -r commit; do
134- if echo "$commit" | grep -qE "^[a-f0-9]+ [a-z]+(\(.+\))?!:"; then
135- HAS_BREAKING=true
136- elif echo "$commit" | grep -qE "^[a-f0-9]+ (feat|refactor|perf|chore)(\(.+\))?:"; then
137- HAS_MINOR=true
138- elif echo "$commit" | grep -qE "^[a-f0-9]+ (fix|docs|test|ci|style|build)(\(.+\))?:"; then
139- HAS_PATCH=true
140- fi
141-
142- # Check commit body for BREAKING CHANGE
143- COMMIT_HASH=$(echo "$commit" | cut -d' ' -f1)
144- if git show -s --format=%B "$COMMIT_HASH" | grep -q "BREAKING CHANGE:"; then
145- HAS_BREAKING=true
146- fi
147- done <<< "$COMMITS"
148-
149- # Determine version bump
150- if [ "$HAS_BREAKING" = true ]; then
151- MAJOR=$((MAJOR + 1))
152- MINOR=0
153- PATCH=0
154- BUMP_TYPE="major"
155- elif [ "$HAS_MINOR" = true ]; then
156- MINOR=$((MINOR + 1))
157- PATCH=0
158- BUMP_TYPE="minor"
159- elif [ "$HAS_PATCH" = true ]; then
160- PATCH=$((PATCH + 1))
161- BUMP_TYPE="patch"
162- else
163- # Default to patch for any other changes
164- PATCH=$((PATCH + 1))
165- BUMP_TYPE="patch"
166- fi
115+ # Use helper script to determine next version
116+ OUTPUT=$(./rust/scripts/determine-next-version.sh "$CURRENT_VERSION")
117+ NEW_VERSION=$(echo "$OUTPUT" | sed -n '1p')
118+ BUMP_TYPE=$(echo "$OUTPUT" | sed -n '2p')
167119
168- NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
169120 echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
170121 echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT
171122 echo "Next version: $NEW_VERSION ($BUMP_TYPE bump from $CURRENT_VERSION)"
@@ -175,7 +126,7 @@ jobs:
175126 NEW_VERSION : ${{ steps.next_version.outputs.new_version }}
176127 run : |
177128 # Get commit range for changelog generation
178- LATEST_TAG=$(git tag -l "agents-v*" --sort=-version:refname | grep -E "^ agents-v[0-9]+\.[0-9]+\.[0-9]+$" | head -1 )
129+ LATEST_TAG=$(./rust/scripts/get-latest- agents-tag.sh )
179130
180131 if [ -z "$LATEST_TAG" ]; then
181132 COMMIT_RANGE=""
@@ -203,25 +154,14 @@ jobs:
203154 # Generate per-workspace CHANGELOG.md files
204155 ./rust/scripts/generate-workspace-changelog.sh "$COMMIT_RANGE" "" --write-to-workspace "$NEW_VERSION"
205156 - name : Update version files
206- working-directory : ./rust/main
207157 env :
208158 NEW_VERSION : ${{ steps.next_version.outputs.new_version }}
209159 run : |
210160 # Update workspace version in Cargo.toml
211- # Use awk to find [workspace.package] section and update version within it
212- awk -v new_version="$NEW_VERSION" '
213- /^\[workspace\.package\]/ { in_workspace=1 }
214- /^\[/ && !/^\[workspace\.package\]/ { in_workspace=0 }
215- in_workspace && /^version = / {
216- print "version = \"" new_version "\""
217- next
218- }
219- { print }
220- ' Cargo.toml > Cargo.toml.new
221- mv Cargo.toml.new Cargo.toml
222- echo "Updated Cargo.toml workspace version to $NEW_VERSION"
161+ ./rust/scripts/update-workspace-version.sh "$NEW_VERSION"
223162
224163 # Update Cargo.lock in rust/main
164+ cd rust/main
225165 cargo update --workspace --offline 2>/dev/null || cargo update --workspace
226166 echo "Updated rust/main/Cargo.lock"
227167
0 commit comments