-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# .github/workflows/deploy-to-nuget.yml | ||
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@v1 | ||
with: | ||
dotnet-version: '7.x' # Update to your project's .NET version | ||
|
||
- 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 number | ||
run: | | ||
# Retrieve the old version number from your .csproj file | ||
OLD_VERSION=$(grep -oP '(?<=<Version>).*?(?=</Version>)' 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) | ||
- 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: Pack | ||
run: dotnet pack --no-build -c Release -o out | ||
|
||
- name: Push new version | ||
run: | | ||
git config --local user.email "action@github.com" | ||
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 |