-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (53 loc) · 2.38 KB
/
Deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Deploy to NuGet
on:
workflow_dispatch: # Manueller Trigger
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v2
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: '8.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Increment version numbers
run: |
# Retrieve the old version numbers from your .csproj file
OLD_VERSION=$(grep -oP '(?<=<Version>).*?(?=</Version>)' TablerForNet.csproj)
OLD_ASSEMBLY_VERSION=$(grep -oP '(?<=<AssemblyVersion>).*?(?=</AssemblyVersion>)' TablerForNet.csproj)
OLD_FILE_VERSION=$(grep -oP '(?<=<FileVersion>).*?(?=</FileVersion>)' TablerForNet.csproj)
# Parse out the individual parts of the version
MAJOR=$(echo $OLD_VERSION | cut -d'.' -f1)
MINOR=$(echo $OLD_VERSION | cut -d'.' -f2)
PATCH=$(echo $OLD_VERSION | cut -d'.' -f3)
# Increment the version number
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH.0"
NEW_ASSEMBLY_VERSION="$MAJOR.$MINOR.$NEW_PATCH.0"
NEW_FILE_VERSION="$MAJOR.$MINOR.$NEW_PATCH.0"
# Update the .csproj file with the new version numbers
sed -i "s/<Version>$OLD_VERSION<\/Version>/<Version>$NEW_VERSION<\/Version>/" TablerForNet.csproj
sed -i "s/<AssemblyVersion>$OLD_ASSEMBLY_VERSION<\/AssemblyVersion>/<AssemblyVersion>$NEW_ASSEMBLY_VERSION<\/AssemblyVersion>/" TablerForNet.csproj
sed -i "s/<FileVersion>$OLD_FILE_VERSION<\/FileVersion>/<FileVersion>$NEW_FILE_VERSION<\/FileVersion>/" TablerForNet.csproj
- name: Build and Pack
run: |
dotnet build --configuration Release
dotnet pack --no-build -c Release -o out
- name: Push new version
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add TablerForNet.csproj
git commit -m "Increment version to $NEW_VERSION"
git push origin master
- name: Push to NuGet
run: dotnet nuget push out/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json