From 735966e6ba2bb2da68e639c2caa7e881bc2a4461 Mon Sep 17 00:00:00 2001 From: juanonsoftware Date: Sun, 20 Jul 2025 11:12:33 +0700 Subject: [PATCH 1/4] Correct readme --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index ec25114..abbd2c3 100644 --- a/Readme.md +++ b/Readme.md @@ -1,3 +1,3 @@ -#PowerSell Versioning Script +# PowerSell Versioning Script This script contains functions to manage git tags for software versions \ No newline at end of file From b028fd20a286b7f4545b358bf88de237467dd6f0 Mon Sep 17 00:00:00 2001 From: juanonsoftware Date: Sun, 20 Jul 2025 13:53:00 +0700 Subject: [PATCH 2/4] Adding CI for develop branch --- .github/workflows/ci-develop.yml | 17 ++++++++ .../VersionManager.ps1 | 43 ++++++++++++++++--- 2 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/ci-develop.yml rename VersionManager.ps1 => Scripts/VersionManager.ps1 (55%) diff --git a/.github/workflows/ci-develop.yml b/.github/workflows/ci-develop.yml new file mode 100644 index 0000000..30e8745 --- /dev/null +++ b/.github/workflows/ci-develop.yml @@ -0,0 +1,17 @@ +name: CI on Develop branch +on: + push: + branches: [ develop ] + workflow_dispatch: + +jobs: + create-new-tag: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create new tag + shell: pwsh + run: | + . ./Scripts/VersionManager.ps1 + New-Tag -Branch "develop" + \ No newline at end of file diff --git a/VersionManager.ps1 b/Scripts/VersionManager.ps1 similarity index 55% rename from VersionManager.ps1 rename to Scripts/VersionManager.ps1 index 7acf21e..2a7bc95 100644 --- a/VersionManager.ps1 +++ b/Scripts/VersionManager.ps1 @@ -1,6 +1,39 @@ ################################# # This script contains funtions to create git tags following GitFlow ################################# +function New-Tag +{ + param ( + [Parameter(Mandatory=$true)] + [string]$Branch + ) + + $version = Get-CurrentVersion + $patch = Get-NewPatch + $prefix = "" + + if ($Branch -eq "release") + { + $version = ([decimal]$currentVersion + 0.1).ToString() + $prefix = "Beta-" + } + if ($Branch -eq "develop") + { + $version = ([decimal]$currentVersion + 0.1).ToString() + $prefix = "Dev-" + } + if ($Branch -eq "hotfix") + { + $version = ([decimal]$currentVersion + 0.1).ToString() + $prefix = "HF-" + } + + $tag = "v$version.$prefix$patch" + + Invoke-Expression "git tag $tag" + + return $tag +} function Get-CurrentVersion { @@ -35,17 +68,17 @@ function Get-CurrentVersion function Get-NewPatch { - param ( + param ( [Parameter(Mandatory=$false)] [string]$Prefix = "" ) - if ($Prefix -ne "") + if ($Prefix -eq "") { - return $Prefix + "-" + (Get-Date).ToString("yyMMddhhmmss") + return (Get-Date).ToString("yyMMddhhmmss") } - return (Get-Date).ToString("yyMMddhhmmss") + return $Prefix + "-" + (Get-Date).ToString("yyMMddhhmmss") } function Get-NextVersion @@ -58,4 +91,4 @@ function Get-GitTags { $tags = Invoke-Expression "git tag --list" $tags -} +} \ No newline at end of file From 05d50e1f8911cfdd3256db9c21da136aed0361ab Mon Sep 17 00:00:00 2001 From: juanonsoftware Date: Sun, 20 Jul 2025 14:00:17 +0700 Subject: [PATCH 3/4] Add push tags --- .github/workflows/ci-develop.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-develop.yml b/.github/workflows/ci-develop.yml index 30e8745..f5dad35 100644 --- a/.github/workflows/ci-develop.yml +++ b/.github/workflows/ci-develop.yml @@ -14,4 +14,6 @@ jobs: run: | . ./Scripts/VersionManager.ps1 New-Tag -Branch "develop" - \ No newline at end of file + - name: Push tags + run: | + git push --tags \ No newline at end of file From 1bba865621c84e674232f2dd7b8f48e51b4b6c2b Mon Sep 17 00:00:00 2001 From: juanonsoftware Date: Sun, 20 Jul 2025 14:06:11 +0700 Subject: [PATCH 4/4] Add CI Master + update script --- .github/workflows/ci-develop.yml | 9 +++------ .github/workflows/ci-master.yml | 16 ++++++++++++++++ Scripts/VersionManager.ps1 | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/ci-master.yml diff --git a/.github/workflows/ci-develop.yml b/.github/workflows/ci-develop.yml index f5dad35..e7a83b9 100644 --- a/.github/workflows/ci-develop.yml +++ b/.github/workflows/ci-develop.yml @@ -1,4 +1,4 @@ -name: CI on Develop branch +name: CI on Develop on: push: branches: [ develop ] @@ -9,11 +9,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Create new tag + - name: Create and Push new tag shell: pwsh run: | . ./Scripts/VersionManager.ps1 - New-Tag -Branch "develop" - - name: Push tags - run: | - git push --tags \ No newline at end of file + New-Tag -Branch "develop" \ No newline at end of file diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml new file mode 100644 index 0000000..b9c6a43 --- /dev/null +++ b/.github/workflows/ci-master.yml @@ -0,0 +1,16 @@ +name: CI on Master +on: + push: + branches: [ master ] + workflow_dispatch: + +jobs: + create-new-tag: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create and Push new tag + shell: pwsh + run: | + . ./Scripts/VersionManager.ps1 + New-Tag -Branch "master" \ No newline at end of file diff --git a/Scripts/VersionManager.ps1 b/Scripts/VersionManager.ps1 index 2a7bc95..f1b515c 100644 --- a/Scripts/VersionManager.ps1 +++ b/Scripts/VersionManager.ps1 @@ -31,6 +31,7 @@ function New-Tag $tag = "v$version.$prefix$patch" Invoke-Expression "git tag $tag" + Invoke-Expression "git push origin $tag" return $tag }