Skip to content

Commit 6d48da5

Browse files
Merge pull request #8 from APK-Arjun-Developer/feature/auto-version-on-merge
Add automatic patch version increment on every master merge
2 parents 7ea2368 + f0c5eeb commit 6d48da5

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

.github/workflows/deploy-monsterasp-ftp.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ jobs:
2525
steps:
2626
- name: Checkout
2727
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Compute next version
32+
id: version
33+
shell: pwsh
34+
run: |
35+
git fetch --tags --quiet
36+
$latest = git tag --sort=-v:refname | Where-Object { $_ -match '^v\d+\.\d+\.\d+$' } | Select-Object -First 1
37+
if (-not $latest) {
38+
$newVersion = "1.0.0"
39+
} else {
40+
$parts = $latest.TrimStart('v') -split '\.'
41+
$newVersion = "$([int]$parts[0]).$([int]$parts[1]).$([int]$parts[2] + 1)"
42+
}
43+
Write-Host "Next version: $newVersion (tag: v$newVersion)"
44+
"version=$newVersion" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
45+
"tag=v$newVersion" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
2846
2947
- name: Validate required GitHub secrets
3048
shell: pwsh
@@ -82,6 +100,7 @@ jobs:
82100
--output ./publish
83101
--runtime win-x86
84102
--no-restore
103+
-p:Version=${{ steps.version.outputs.version }}
85104
86105
- name: Write production appsettings from GitHub secrets
87106
shell: pwsh
@@ -248,3 +267,12 @@ jobs:
248267
-MaxAttempts 10 `
249268
-InitialDelaySeconds 45 `
250269
-RetryDelaySeconds 15
270+
271+
- name: Tag release
272+
shell: pwsh
273+
run: |
274+
git config user.name "github-actions[bot]"
275+
git config user.email "github-actions[bot]@users.noreply.github.com"
276+
git tag ${{ steps.version.outputs.tag }}
277+
git push origin ${{ steps.version.outputs.tag }}
278+
Write-Host "Tagged ${{ steps.version.outputs.tag }}"

Directory.Build.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project>
2+
<PropertyGroup>
3+
<!-- Fallback version for local builds. CI overrides this via -p:Version during dotnet publish. -->
4+
<Version>1.0.0</Version>
5+
<AssemblyVersion>1.0.0.0</AssemblyVersion>
6+
<FileVersion>1.0.0.0</FileVersion>
7+
</PropertyGroup>
8+
</Project>

0 commit comments

Comments
 (0)