Deploy to NuGet #71
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
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 "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 |