Skip to content

Commit

Permalink
refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWoolfenden committed Dec 6, 2024
1 parent 76424b0 commit 067d249
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 9 deletions.
48 changes: 40 additions & 8 deletions bump.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
$version = $( git describe --tags --abbrev=0 )
$splitter = $version.split(".")
$build = [int]($splitter[2]) + 1
$newVersion = $splitter[0] + "." + $splitter[1] + "." + $build

write-host $newVersion
git tag -a $newVersion -m "new release"
git push origin $newVersion
param(
[Parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[string]$message = "new release"
)

$versionPattern = '^\d+\.\d+\.\d+$'
$version = $null

try
{
$version = $( git describe --tags --abbrev=0 )
if ($version -notmatch $versionPattern)
{
Write-Error "Invalid version format. Expected: x.y.z"
exit 1
}

$splitter = $version.split(".")
$build = [int]($splitter[2]) + 1
[string]$newVersion = $splitter[0] + "." + $splitter[1] + "." + $build.ToString()

if ([version]$newVersion -le [version]$version)
{
Write-Error "New version must be greater than current version"
exit 1
}

Write-Host "Current version: $version"
Write-Host "New version: $newVersion"
Write-Host "Creating new tag..."

git tag -a $newVersion -m "$message"
git push origin $newVersion
}
catch
{
Write-Error "An error occurred: $_"
exit 1
}
34 changes: 34 additions & 0 deletions bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Parameters
message="${1:-new release}"

# Version pattern
versionPattern='^[0-9]+\.[0-9]+\.[0-9]+$'
version=''

# Get the current version
version=$(git describe --tags --abbrev=0 2>/dev/null)
if [[ ! $version =~ $versionPattern ]]; then
echo "Invalid version format. Expected: x.y.z"
exit 1
fi

# Split the version and increment the build number
IFS='.' read -r major minor build <<< "$version"
newBuild=$((build + 1))
newVersion="$major.$minor.$newBuild"

if [[ ! "$newVersion" > "$version" ]]; then
echo "New version must be greater than current version"
exit 1
fi

# Output the current and new version
echo "Current version: $version"
echo "New version: $newVersion"
echo "Creating new tag..."

# Create a new tag and push it
git tag -a "$newVersion" -m "$message"
git push origin "$newVersion"
21 changes: 20 additions & 1 deletion set-version.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
#!/bin/sh
latesttag=$(git describe --tags)
# set-version.sh: Updates version.go file with latest git tag
# Usage: ./set-version.sh
# Requires: git
set -e # Exit on error

if ! latesttag=$(git describe --tags); then
echo "Error: Failed to get git tag" >&2
exit 1
fi

if [ -z "$latesttag" ]; then
echo "Error: No git tags found" >&2
exit 1
fi

if ! echo "$latesttag" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+'; then
echo "Error: Invalid version tag format" >&2
exit 1
fi

echo "Updating version file with new tag: $latesttag"
echo "package version" > src/version/version.go
echo "" >> src/version/version.go
Expand Down
1 change: 1 addition & 0 deletions src/arm/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

// ParseData writes out to data.tf.
func ParseData(result map[string]interface{}, funcMap tftemplate.FuncMap, destination string) error {

if result["data"] == nil {
return nil
}
Expand Down

0 comments on commit 067d249

Please sign in to comment.