File tree 1 file changed +28
-12
lines changed
1 file changed +28
-12
lines changed Original file line number Diff line number Diff line change 1
- name : Publish to NuGet
1
+ name : Auto-version and Publish
2
2
3
3
on :
4
4
push :
5
- tags :
6
- - ' v* '
5
+ branches :
6
+ - main
7
7
8
8
jobs :
9
- build :
9
+ version-and-publish :
10
10
runs-on : ubuntu-latest
11
+ permissions :
12
+ contents : write
11
13
12
14
steps :
13
15
- uses : actions/checkout@v3
16
+ with :
17
+ fetch-depth : 0
18
+
19
+ - name : Update Version and Create Tag
20
+ run : |
21
+ CSPROJ_FILE="$(find . -name "*.csproj" | head -n 1)"
22
+ CURRENT_VERSION=$(grep -oP '(?<=<Version>)[^<]+' "$CSPROJ_FILE")
23
+ IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
24
+ NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$((VERSION_PARTS[2] + 1))"
25
+ sed -i "s|<Version>$CURRENT_VERSION</Version>|<Version>$NEW_VERSION</Version>|" "$CSPROJ_FILE"
26
+
27
+ git config user.name "GitHub Actions"
28
+ git config user.email "[email protected] "
29
+ git add "$CSPROJ_FILE"
30
+ git commit -m "bump version to $NEW_VERSION"
31
+ git tag "v$NEW_VERSION"
32
+ git push && git push --tags
14
33
15
34
- name : Setup .NET
16
35
uses : actions/setup-dotnet@v3
17
36
with :
18
37
dotnet-version : ' 9.0.x'
19
38
20
- - name : Restore dependencies
21
- run : dotnet restore
22
-
23
- - name : Build
24
- run : dotnet build --configuration Release --no-restore
25
-
26
- - name : Test
27
- run : dotnet test --no-restore --verbosity normal
39
+ - name : Build and Test
40
+ run : |
41
+ dotnet restore
42
+ dotnet build --configuration Release
43
+ dotnet test --no-restore
28
44
29
45
- name : Pack
30
46
run : dotnet pack --configuration Release --no-build --output nupkgs
You can’t perform that action at this time.
0 commit comments