File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,16 @@ name: Promote Release (stable)
22
33on :
44 workflow_dispatch :
5+ inputs :
6+ bump :
7+ description : " Bump version on develop before promoting (patch is always auto-incremented by nbgv)"
8+ type : choice
9+ required : true
10+ default : none
11+ options :
12+ - none
13+ - minor
14+ - major
515
616permissions :
717 contents : write
1424 with :
1525 ssh-key : ${{ secrets.DEPLOY_KEY }}
1626 fetch-depth : 0
17- - name : Fast-forward master branch
27+ ref : develop
28+
29+ - name : Bump version on develop
30+ if : ${{ inputs.bump != 'none' }}
31+ shell : pwsh
32+ run : |
33+ $json = Get-Content version.json -Raw | ConvertFrom-Json
34+ $parts = $json.version.Split('.')
35+ $major = [int]$parts[0]
36+ $minor = [int]$parts[1]
37+ if ('${{ inputs.bump }}' -eq 'major') {
38+ $major++
39+ $minor = 0
40+ } else {
41+ $minor++
42+ }
43+ $newVersion = "$major.$minor"
44+
45+ # Replace only the version field to preserve the file's formatting
46+ $content = Get-Content version.json -Raw
47+ $content = $content -replace '("version"\s*:\s*")[^"]*"', "`${1}$newVersion`""
48+ Set-Content version.json -Value $content -NoNewline
49+ Write-Host "Bumped version.json to $newVersion"
50+
51+ git config user.name "github-actions[bot]"
52+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
53+ git commit -am "Bump version to $newVersion"
54+ git push origin develop
55+
56+ - name : Fast-forward master to develop
1857 run : |
1958 git checkout master
2059 git merge develop --ff-only
21- git push
60+ git push origin master
You can’t perform that action at this time.
0 commit comments