-
Notifications
You must be signed in to change notification settings - Fork 3
56 lines (40 loc) · 1.57 KB
/
continuous-integration-nuget.yaml
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
name: .NET 8 Continuous Integration with GitHub, GitHub Actions and Nuget Packages
on:
push:
branches: main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Move to folder
run: |
cd ./Tapioca.HATEOAS/
# Increment version in your project file (e.g., .csproj)
# Replace the placeholder with your actual project file name
PROJECT_FILE=Tapioca.HATEOAS.csproj
CURRENT_VERSION=$(grep -oP '<Version>\K[^<]+' $PROJECT_FILE)
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{$NF+=1; OFS="."; print $0}')
# Replace spaces with dots
NEW_VERSION=$(echo $NEW_VERSION | tr ' ' '.')
# Update the version in the project file
sed -i "s|<Version>$CURRENT_VERSION</Version>|<Version>$NEW_VERSION</Version>|" $PROJECT_FILE
# Commit the version change
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -m "Increment version to $NEW_VERSION" -a
git push
- name: Generate Release
run: dotnet build -c release
- name: Generate Package
run: dotnet pack -c release -o ./dist/
- name: Publish Package
run: dotnet nuget push "./dist/*" -k ${{ secrets.NUGET_API_KEY }} -s "https://api.nuget.org/v3/index.json" --skip-duplicate