Skip to content

Commit 12d3026

Browse files
[Backport 7.11] Create version bump automation (#5494)
Co-authored-by: Martijn Laarman <Mpdreamz@gmail.com>
1 parent 713ff05 commit 12d3026

File tree

7 files changed

+74
-19
lines changed

7 files changed

+74
-19
lines changed

.ci/make.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ case $CMD in
103103
exit 1
104104
fi
105105
echo -e "\033[36;1mTARGET: bump to version $VERSION\033[0m"
106-
TASK=bump
106+
TASK="set-version"
107107
# VERSION is BRANCH here for now
108108
TASK_ARGS=("$VERSION")
109109
;;

.github/workflows/make-bump.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Version Bump
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
branch:
6+
description: 'The branch to perform bump on'
7+
required: true
8+
version:
9+
description: 'The new version number to branch'
10+
required: true
11+
12+
jobs:
13+
createBranches:
14+
name: "Branch ${{ github.event.inputs.version }} Clients"
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
ref: "${{ github.event.inputs.branch }}"
20+
- run: "./.ci/make.sh bump ${{ github.event.inputs.version }}"
21+
name: "Bump ${{ github.event.inputs.version }} on ${{ github.event.inputs.branch }}"
22+
- name: "Version bump PR ${{ github.event.inputs.version }}"
23+
# fixate to known release.
24+
uses: peter-evans/create-pull-request@052fc72b4198ba9fbc81b818c6e1859f747d49a8
25+
with:
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
branch: "feature/${{ github.event.inputs.branch }}/bump-version"
28+
base: "${{ github.event.inputs.version }}"
29+
delete-branch: true
30+
commit-message: "[version] ${{ github.event.inputs.version }} bump"
31+
title: '[version] ${{ github.event.inputs.version }} bump'
32+
body: |
33+
Updates ${{ github.event.inputs.branch }} to version ${{ github.event.inputs.version }}.
34+
labels: "infra,code-gen"
35+
# Add version and backport labels automatically
36+
- uses: actions/setup-dotnet@v1
37+
with:
38+
dotnet-version: '5.0.100'
39+
- name: Install dotnet-script
40+
run: dotnet tool install release-notes --tool-path dotnet-tool
41+
42+
- name: Run build script
43+
run: >
44+
dotnet-tool/release-notes apply-labels --version ${{ github.event.inputs.version }} ${{ github.event.organization.name }} ${{ github.event.repository.name }}
45+
--token ${{ secrets.GITHUB_TOKEN }} --backportlabelformat "Backport BRANCH"

build/scripts/Commandline.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ Execution hints can be provided anywhere on the command line
206206
| "codegen" :: branch :: tail ->
207207
{ parsed with CommandArguments = CodeGen { Branch = branch }; RemainingArguments = tail }
208208

209+
| ["set-version"; version] -> { parsed with CommandArguments = SetVersion { Version = version; OutputLocation = None }; }
209210
| ["release"; version] -> { parsed with CommandArguments = SetVersion { Version = version; OutputLocation = None }; }
210211
| ["release"; version; path] ->
211212
if (not <| System.IO.Directory.Exists path) then failwithf "'%s' is not an existing directory" (Path.getFullName path)

build/scripts/Targets.fs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ module Main =
112112

113113
command "codegen" [ ] <| fun _ -> ReposTooling.GenerateApi parsed
114114

115+
target "set-version" <| fun _ -> Versioning.WriteVersion buildVersions
116+
117+
115118
command "rest-spec-tests" [ ] <| fun _ ->
116119
ReposTooling.RestSpecTests parsed.RemainingArguments
117120

build/scripts/Versioning.fs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,24 @@ module Versioning =
9292
| None -> NoChange(Current = AnchoredVersion currentVersion)
9393
| Some v -> Update(New = AnchoredVersion v, Old = AnchoredVersion currentVersion)
9494

95+
let WriteVersion version =
96+
match version with
97+
| NoChange _ -> failwithf "cannot run update versions because no explicit version number was passed on the command line"
98+
| Update (newVersion, currentVersion) ->
99+
match newVersion.Full.PreRelease with
100+
| Some v when v.Name.StartsWith("SNAPSHOT", StringComparison.OrdinalIgnoreCase) ->
101+
printfn "Building snapshot, foregoing persisting version information"
102+
| _ ->
103+
// fail if current is greater than the new version
104+
if (currentVersion > newVersion) then
105+
failwithf "Can not release %O as it's lower then current %O" newVersion.Full currentVersion.Full
106+
writeVersionIntoGlobalJson newVersion.Full
107+
writeVersionIntoAutoLabel (currentVersion.Full.ToString()) (newVersion.Full.ToString())
108+
95109
let Validate target version =
96110
match (target, version) with
97111
| ("release", version) ->
98-
match version with
99-
| NoChange _ -> failwithf "cannot run release because no explicit version number was passed on the command line"
100-
| Update (newVersion, currentVersion) ->
101-
match newVersion.Full.PreRelease with
102-
| Some v when v.Name.StartsWith("SNAPSHOT", StringComparison.OrdinalIgnoreCase) ->
103-
printfn "Building snapshot, foregoing persisting version information"
104-
| _ ->
105-
// fail if current is greater than the new version
106-
if (currentVersion > newVersion) then
107-
failwithf "Can not release %O as it's lower then current %O" newVersion.Full currentVersion.Full
108-
writeVersionIntoGlobalJson newVersion.Full
109-
writeVersionIntoAutoLabel (currentVersion.Full.ToString()) (newVersion.Full.ToString())
112+
WriteVersion version
110113
| _ -> ignore()
111114

112115
let ArtifactsVersion buildVersions =

build/scripts/scripts.fsproj

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,9 @@
2828
<Content Include="..\..\.github\workflows\test-jobs.yml"><Link>test-jobs.yml</Link></Content>
2929
<Content Include="..\..\.github\workflows\stale-jobs.yml"><Link>stale-jobs.yml</Link></Content>
3030
<Content Include="..\..\.github\workflows\integration-jobs.yml"><Link>integration-jobs.yml</Link></Content>
31-
<Content Include="..\..\.github\workflows\unified-release.yml">
32-
<Link>unified-release.yml</Link>
33-
</Content>
34-
<Content Include="..\..\.github\workflows\make-codegen.yml">
35-
<Link>make-codegen.yml</Link>
36-
</Content>
31+
<Content Include="..\..\.github\workflows\unified-release.yml"><Link>unified-release.yml</Link></Content>
32+
<Content Include="..\..\.github\workflows\make-codegen.yml"><Link>make-codegen.yml</Link></Content>
33+
<Content Include="..\..\.github\workflows\make-bump.yml"><Link>make-bump.yml</Link></Content>
3734
</ItemGroup>
3835
<ItemGroup>
3936
<PackageReference Include="FSharp.Core" Version="5.0.0" />

dotnet-tools.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
"commands": [
2020
"nupkg-validator"
2121
]
22+
},
23+
"release-notes": {
24+
"version": "0.3.1",
25+
"commands": [
26+
"release-notes"
27+
]
2228
}
2329
}
2430
}

0 commit comments

Comments
 (0)