chore: migrate to bash scripts
This commit is contained in:
@@ -15,17 +15,12 @@ jobs:
|
|||||||
uses: actions/setup-dotnet@v4
|
uses: actions/setup-dotnet@v4
|
||||||
with:
|
with:
|
||||||
dotnet-version: 10.0.x
|
dotnet-version: 10.0.x
|
||||||
- name: Setup PowerShell
|
|
||||||
run: |
|
|
||||||
sudo apk update
|
|
||||||
sudo apk add powershell
|
|
||||||
- name: Determine version
|
- name: Determine version
|
||||||
id: version
|
id: version
|
||||||
run: pwsh -File scripts/determine-version.ps1 -Branch main | tee -a $env:GITHUB_OUTPUT
|
run: ./scripts/determine-version.sh main | tee -a $GITHUB_OUTPUT
|
||||||
shell: pwsh
|
|
||||||
- name: Update version in csproj
|
- name: Update version in csproj
|
||||||
if: steps.version.outputs.VERSION
|
if: steps.version.outputs.VERSION
|
||||||
run: pwsh -File scripts/update-version.ps1 -Version "${{ steps.version.outputs.VERSION }}"
|
run: ./scripts/update-version.sh "${{ steps.version.outputs.VERSION }}"
|
||||||
- name: Create commit
|
- name: Create commit
|
||||||
if: steps.version.outputs.VERSION
|
if: steps.version.outputs.VERSION
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
branch="${1:-main}"
|
||||||
|
|
||||||
|
commits=$(git log "$branch..HEAD" --format="%s")
|
||||||
|
major=0
|
||||||
|
minor=0
|
||||||
|
patch=0
|
||||||
|
|
||||||
|
while IFS= read -r message; do
|
||||||
|
if [[ -n "$message" ]] && [[ "$message" =~ " BREAKING CHANGE|!:" ]]; then
|
||||||
|
major=1
|
||||||
|
elif [[ -n "$message" ]] && [[ "$message" =~ ^feat(\(.*\))?: ]]; then
|
||||||
|
minor=1
|
||||||
|
elif [[ -n "$message" ]] && [[ "$message" =~ ^fix(\(.*\))?: ]]; then
|
||||||
|
patch=1
|
||||||
|
fi
|
||||||
|
done <<< "$commits"
|
||||||
|
|
||||||
|
if [[ "$major" -eq 1 ]]; then
|
||||||
|
minor=0
|
||||||
|
patch=0
|
||||||
|
elif [[ "$minor" -eq 1 ]]; then
|
||||||
|
patch=0
|
||||||
|
elif [[ "$patch" -eq 0 ]] && [[ -n "$commits" ]]; then
|
||||||
|
patch=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
currentVersion="0.0.0"
|
||||||
|
tag=$(git describe --tags --abbrev=0 2>/dev/null)
|
||||||
|
hasExistingTag=false
|
||||||
|
|
||||||
|
if [[ -n "$tag" ]]; then
|
||||||
|
hasExistingTag=true
|
||||||
|
currentVersion="${tag#v}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
IFS='.' read -r majorCurrent minorCurrent patchCurrent <<< "$currentVersion"
|
||||||
|
|
||||||
|
majorNew=$((majorCurrent + major))
|
||||||
|
|
||||||
|
if [[ "$major" -eq 1 ]]; then
|
||||||
|
minorNew=0
|
||||||
|
else
|
||||||
|
minorNew=$((minorCurrent + minor))
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$major" -eq 1 ]] || [[ "$minor" -eq 1 ]]; then
|
||||||
|
patchNew=0
|
||||||
|
else
|
||||||
|
patchNew=$((patchCurrent + patch))
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$majorNew" -eq "$majorCurrent" ]] && [[ "$minorNew" -eq "$minorCurrent" ]] && [[ "$patchNew" -eq "$patchCurrent" ]]; then
|
||||||
|
if [[ "$hasExistingTag" == "false" ]]; then
|
||||||
|
version="0.0.0"
|
||||||
|
echo "VERSION=$version"
|
||||||
|
echo "First release: publishing version 0.0.0"
|
||||||
|
else
|
||||||
|
echo "No version bump needed, skipping release"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
version="$majorNew.$minorNew.$patchNew"
|
||||||
|
echo "VERSION=$version"
|
||||||
|
fi
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
version="${1:-}"
|
||||||
|
csprojPath="${2:-src/StevanFreeborn.Results/StevanFreeborn.Results.csproj}"
|
||||||
|
|
||||||
|
if [[ -z "$version" ]]; then
|
||||||
|
echo "Error: Version is required"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
content=$(cat "$csprojPath")
|
||||||
|
|
||||||
|
if [[ "$content" =~ \<Version\>.*?\</Version\> ]]; then
|
||||||
|
content=$(echo "$content" | sed "s|<Version>.*</Version>|<Version>$version</Version>|")
|
||||||
|
elif [[ "$content" =~ \<PropertyGroup\> ]]; then
|
||||||
|
content=$(echo "$content" | sed "s|<PropertyGroup>|<PropertyGroup>\\n <Version>$version</Version>|")
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$content" > "$csprojPath"
|
||||||
Reference in New Issue
Block a user