Update ReadMe.md #150
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: CI-CD Pipeline | |
on: | |
push: | |
pull_request: | |
release: | |
types: | |
- published | |
env: | |
# Performance optimisations | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
# Filename shortcuts | |
PROJECT_NAME: FluentValidationLister.Filter | |
TESTS_NAME: FluentValidationLister.Tests | |
# GitHub params | |
GITHUB_FEED: https://nuget.pkg.github.com/scandal-uk/ | |
GITHUB_USER: scandal-uk | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# NuGet params | |
NUGET_FEED: https://api.nuget.org/v3/index.json | |
NUGET_TOKEN: ${{ secrets.NUGET_KEY }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '8.x' | |
# Build and run the unit tests | |
- name: Restore project | |
run: dotnet restore $PROJECT_NAME/$PROJECT_NAME.csproj | |
- name: Build project | |
run: dotnet build $PROJECT_NAME/$PROJECT_NAME.csproj --no-restore --configuration Release | |
- name: Restore tests | |
run: dotnet restore $TESTS_NAME/$TESTS_NAME.csproj | |
- name: Build tests | |
run: dotnet build $TESTS_NAME/$TESTS_NAME.csproj --no-restore --configuration Release | |
- name: Run tests | |
run: dotnet test --no-restore --no-build --configuration Release | |
prerelease: | |
# Push the prerelease build to the GitHub feed for anything targeting develop branch | |
needs: build | |
if: github.ref == 'refs/heads/develop' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '8.x' | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y.%m.%d')" | |
# Package artifact using the date and rc (release candidate) version suffix | |
- name: Package project | |
run: | | |
VERSION=${{ steps.date.outputs.date }}-rc | |
dotnet pack -v normal -c Debug --include-symbols --include-source -p:PackageVersion=$VERSION $PROJECT_NAME/$PROJECT_NAME.csproj | |
- name: Push build to GitHub feed | |
run: | | |
dotnet nuget push ./${{ env.PROJECT_NAME }}/bin/Debug/*.nupkg --source $GITHUB_FEED --api-key $GITHUB_TOKEN | |
deploy: | |
# Push a fresh build to Nuget when a new release version is applied | |
needs: build | |
if: github.event_name == 'release' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '8.x' | |
- name: Create build with released version number | |
run: | | |
arrTag=(${GITHUB_REF//\// }) | |
VERSION="${arrTag[2]}" | |
echo Version: $VERSION | |
VERSION="${VERSION//v}" | |
echo Version Number: $VERSION | |
dotnet pack -v normal -c Release --include-symbols --include-source -p:PackageVersion=$VERSION $PROJECT_NAME/$PROJECT_NAME.csproj | |
- name: Push build to NuGet feed | |
run: dotnet nuget push ./${{ env.PROJECT_NAME }}/bin/Release/*.nupkg --source $NUGET_FEED --api-key $NUGET_TOKEN |