-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚀 Bump version to 0.2.21 (2024-03-17)
- Loading branch information
Showing
3 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,74 @@ | ||
|
||
task bump { | ||
cd .. | ||
# Define the path to Cargo.toml | ||
$cargoTomlPath = "./Cargo.toml" | ||
|
||
|
||
# Read the Cargo.toml content into a variable | ||
$cargoTomlContent = Get-Content -Path $cargoTomlPath -Raw | ||
|
||
# Use a regular expression to find the version line | ||
$matched = $cargoTomlContent -match 'version = "([^"]+)"' | ||
|
||
if (-Not $matched) { | ||
Write-Output "❌ Version line not found in Cargo.toml" | ||
Write-Output "Please ensure the Cargo.toml file contains a valid version line." | ||
exit 1 | ||
} | ||
|
||
$versionLine = $matches[1] | ||
|
||
# Split the version into major, minor, and patch | ||
$versionParts = $versionLine.Split('.') | ||
$major = $versionParts[0] | ||
$minor = $versionParts[1] | ||
$patch = [int]$versionParts[2] | ||
|
||
|
||
# Increment the patch version | ||
$patch += 1 | ||
|
||
# Construct the new version string | ||
$newVersion = "$major.$minor.$patch" | ||
|
||
# Replace the old version with the new version in the Cargo.toml content | ||
$newCargoTomlContent = $cargoTomlContent -replace ('version = "' + [regex]::Escape($versionLine) + '"'), ('version = "' + $newVersion + '"') | ||
|
||
# Write the new Cargo.toml content back to the file | ||
Set-Content -Path $cargoTomlPath -Value $newCargoTomlContent | ||
|
||
Write-Output "✅ Updated version to $newVersion in Cargo.toml" | ||
|
||
# Get the current date | ||
$publishDate = Get-Date -Format "yyyy-MM-dd" | ||
|
||
# Commit messages with publish date | ||
$commitMessage = "🚀 Bump version to $newVersion ($publishDate)" | ||
$releaseMessage = "Release v$newVersion ($publishDate)" | ||
|
||
# Add ALL files to git | ||
git add . | ||
|
||
# Commit the change with the commit message | ||
git commit -m "$commitMessage" | ||
|
||
# Tag the commit as a release with the release message | ||
git tag -a "v$newVersion" -m "$releaseMessage" | ||
|
||
# Push the commit and tag to your repository | ||
Write-Output "🎉 Pushing changes and tags to the repository..." | ||
git push && git push --tags | ||
|
||
# Publish the package to crates.io | ||
Write-Output "📦 Publishing package to crates.io..." | ||
cargo publish | ||
|
||
if ($LASTEXITCODE -eq 0) { Write-Output "✨ Package successfully published to crates.io!" } else { Write-Output "❌ Failed to publish package to crates.io."} | ||
if ($LASTEXITCODE -eq 0) { | ||
Write-Output "✨ Package successfully published to crates.io!" | ||
} else { | ||
Write-Output "❌ Failed to publish package to crates.io." | ||
Write-Output "Please check the output above for more details." | ||
} | ||
|
||
Write-Output "🎉 Release v$newVersion completed!" | ||
}:ps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters