@@ -22,21 +22,31 @@ jobs:
22
22
steps :
23
23
- uses : actions/checkout@v4
24
24
25
- - name : Extract and set version
25
+ - name : Validate version consistency
26
26
run : |
27
27
# Extract version from commit message (e.g., "Release 1.2.3" -> "1.2.3")
28
28
$COMMIT_MSG = "${{ github.event.head_commit.message }}"
29
- $VERSION = [regex]::Match($COMMIT_MSG, '[0-9]+\.[0-9]+\.[0-9]+').Value
30
- Write-Host "Detected version : $VERSION "
29
+ $COMMIT_VERSION = [regex]::Match($COMMIT_MSG, '[0-9]+\.[0-9]+\.[0-9]+').Value
30
+ Write-Host "Version in commit message : $COMMIT_VERSION "
31
31
32
- if ([string]::IsNullOrEmpty($VERSION )) {
32
+ if ([string]::IsNullOrEmpty($COMMIT_VERSION )) {
33
33
Write-Host "No version found in commit message, skipping"
34
34
exit 1
35
35
}
36
36
37
- # Update Cargo.toml with the EXACT version from commit message (no auto-increment)
38
- (Get-Content Cargo.toml) -replace '^version = ".*"', "version = `"$VERSION`"" | Set-Content Cargo.toml
39
- Write-Host "Updated Cargo.toml to EXACT version $VERSION (from commit message)"
37
+ # Check that Cargo.toml version matches commit message
38
+ $CARGO_VERSION = (Select-String -Path "Cargo.toml" -Pattern '^version = "([^"]+)"').Matches[0].Groups[1].Value
39
+ Write-Host "Version in Cargo.toml: $CARGO_VERSION"
40
+
41
+ if ($CARGO_VERSION -ne $COMMIT_VERSION) {
42
+ Write-Host "ERROR: Version mismatch!"
43
+ Write-Host " Commit message version: $COMMIT_VERSION"
44
+ Write-Host " Cargo.toml version: $CARGO_VERSION"
45
+ Write-Host "Please update Cargo.toml version to match commit message before releasing."
46
+ exit 1
47
+ }
48
+
49
+ Write-Host "✓ Version consistency validated: $COMMIT_VERSION"
40
50
41
51
- name : Install Rust
42
52
uses : dtolnay/rust-toolchain@stable
@@ -196,21 +206,31 @@ jobs:
196
206
steps :
197
207
- uses : actions/checkout@v4
198
208
199
- - name : Extract and set version
209
+ - name : Validate version consistency
200
210
run : |
201
211
# Extract version from commit message (e.g., "Release 1.2.3" -> "1.2.3")
202
212
COMMIT_MSG="${{ github.event.head_commit.message }}"
203
- VERSION =$(echo "$COMMIT_MSG" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
204
- echo "Detected version : $VERSION "
213
+ COMMIT_VERSION =$(echo "$COMMIT_MSG" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
214
+ echo "Version in commit message : $COMMIT_VERSION "
205
215
206
- if [ -z "$VERSION " ]; then
216
+ if [ -z "$COMMIT_VERSION " ]; then
207
217
echo "No version found in commit message, skipping"
208
218
exit 1
209
219
fi
210
220
211
- # Update Cargo.toml with the EXACT version from commit message (no auto-increment)
212
- sed -i '' "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
213
- echo "Updated Cargo.toml to EXACT version $VERSION (from commit message)"
221
+ # Check that Cargo.toml version matches commit message
222
+ CARGO_VERSION=$(grep '^version = ' Cargo.toml | head -1 | cut -d '"' -f 2)
223
+ echo "Version in Cargo.toml: $CARGO_VERSION"
224
+
225
+ if [ "$CARGO_VERSION" != "$COMMIT_VERSION" ]; then
226
+ echo "ERROR: Version mismatch!"
227
+ echo " Commit message version: $COMMIT_VERSION"
228
+ echo " Cargo.toml version: $CARGO_VERSION"
229
+ echo "Please update Cargo.toml version to match commit message before releasing."
230
+ exit 1
231
+ fi
232
+
233
+ echo "✓ Version consistency validated: $COMMIT_VERSION"
214
234
215
235
- name : Install Rust
216
236
uses : dtolnay/rust-toolchain@stable
@@ -290,21 +310,31 @@ jobs:
290
310
steps :
291
311
- uses : actions/checkout@v4
292
312
293
- - name : Extract and set version
313
+ - name : Validate version consistency
294
314
run : |
295
315
# Extract version from commit message (e.g., "Release 1.2.3" -> "1.2.3")
296
316
COMMIT_MSG="${{ github.event.head_commit.message }}"
297
- VERSION =$(echo "$COMMIT_MSG" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
298
- echo "Detected version : $VERSION "
317
+ COMMIT_VERSION =$(echo "$COMMIT_MSG" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
318
+ echo "Version in commit message : $COMMIT_VERSION "
299
319
300
- if [ -z "$VERSION " ]; then
320
+ if [ -z "$COMMIT_VERSION " ]; then
301
321
echo "No version found in commit message, skipping"
302
322
exit 1
303
323
fi
304
324
305
- # Update Cargo.toml with the EXACT version from commit message (no auto-increment)
306
- sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
307
- echo "Updated Cargo.toml to EXACT version $VERSION (from commit message)"
325
+ # Check that Cargo.toml version matches commit message
326
+ CARGO_VERSION=$(grep '^version = ' Cargo.toml | head -1 | cut -d '"' -f 2)
327
+ echo "Version in Cargo.toml: $CARGO_VERSION"
328
+
329
+ if [ "$CARGO_VERSION" != "$COMMIT_VERSION" ]; then
330
+ echo "ERROR: Version mismatch!"
331
+ echo " Commit message version: $COMMIT_VERSION"
332
+ echo " Cargo.toml version: $CARGO_VERSION"
333
+ echo "Please update Cargo.toml version to match commit message before releasing."
334
+ exit 1
335
+ fi
336
+
337
+ echo "✓ Version consistency validated: $COMMIT_VERSION"
308
338
309
339
- name : Install Rust
310
340
uses : dtolnay/rust-toolchain@stable
0 commit comments