Update cd.yml #10
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: CD | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: macos-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build solution | |
run: dotnet build --configuration Release --no-restore | |
- name: Run tests | |
run: dotnet test --no-restore --verbosity normal | |
- name: Set up Git | |
run: | | |
git config --global user.name 'github-actions' | |
git config --global user.email 'github-actions@github.com' | |
- name: Determine version number | |
id: get_version | |
run: echo "::set-output name=version::$(dotnet run --project ./PrsianDate/PrsianDate.csproj --configuration Release --no-build --no-restore)" | |
- name: Delete existing tag if it exists | |
id: delete_tag | |
run: | | |
if git rev-parse "v${{ steps.get_version.outputs.version }}" >/dev/null 2>&1; then | |
git tag -d "v${{ steps.get_version.outputs.version }}" | |
git push --delete origin "v${{ steps.get_version.outputs.version }}" | |
fi | |
continue-on-error: true | |
- name: Check if tag deletion was successful | |
id: check_tag_deletion | |
run: | | |
if git rev-parse "v${{ steps.get_version.outputs.version }}" >/dev/null 2>&1; then | |
echo "Tag deletion failed" | |
exit 1 | |
else | |
echo "Tag deletion successful" | |
fi | |
- name: Publish NuGet package | |
run: dotnet nuget push ./PrsianDate/bin/Release/*.nupkg -k ${{ secrets.NUGET_APIKEY }} -s https://api.nuget.org/v3/index.json |