48 lines
1.4 KiB
PowerShell
48 lines
1.4 KiB
PowerShell
# Enable strict mode
|
|
Set-StrictMode -Version Latest
|
|
|
|
# Run Python setup.py
|
|
Write-Host "Running setup.py..."
|
|
python setup.py
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error "Python script failed. Exiting."
|
|
exit 1
|
|
}
|
|
|
|
# Get the latest Git tag
|
|
Write-Host "Fetching the latest Git tag..."
|
|
$latestTag = git describe --tags --abbrev=0
|
|
if (-not $latestTag) {
|
|
Write-Error "No Git tags found. Exiting."
|
|
exit 1
|
|
}
|
|
Write-Host "Latest tag: $latestTag"
|
|
|
|
# Read the changelog for the current version
|
|
Write-Host "Reading changelog for version $latestTag..."
|
|
$changelogPath = "changelog.md"
|
|
if (-not (Test-Path $changelogPath)) {
|
|
Write-Error "Changelog file not found at $changelogPath. Exiting."
|
|
exit 1
|
|
}
|
|
|
|
# Extract the changes for the current version from the changelog
|
|
$changelogContent = Get-Content $changelogPath -Raw
|
|
$changesPattern = "(?s)# $latestTag\b(.*?)(?=^#|\Z)"
|
|
$changes = if ($changelogContent -match $changesPattern) {
|
|
$matches[1].Trim()
|
|
} else {
|
|
Write-Error "No changes found for version $latestTag in the changelog. Exiting."
|
|
exit 1
|
|
}
|
|
|
|
# Create a new release with tea
|
|
Write-Host "Creating a new release with tea..."
|
|
$releaseTitle = "LibrarySystem - Version $latestTag"
|
|
$rel_comment = "Changes in this release: `n$changes`n"
|
|
$rel = tea release create --title $releaseTitle --note $rel_comment --tag $latestTag
|
|
if (-not $rel) {
|
|
Write-Error "Failed to create a new release. Exiting."
|
|
exit 1
|
|
}
|