Publish #4
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: Publish | |
on: | |
workflow_dispatch: | |
release: | |
types: [published] | |
env: | |
BRANCH_NAME: ${{ github.event.release.target_commitish }} | |
SOLUTION_NAME: ${{ vars.SOLUTION_NAME }} | |
DOTNET_VERSION: '8.0.x' | |
NUGET_SOURCE: 'https://api.nuget.org/v3/index.json' | |
BUILD_CONFIGURATION: '' | |
VERSION_SUFFIX: '' | |
jobs: | |
build-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Release Configuration | |
if: ${{ env.BRANCH_NAME == 'main' && (github.event.release.prerelease == false || github.event_name == 'workflow_dispatch') }} | |
run: | | |
echo "BUILD_CONFIGURATION=Release" >> $GITHUB_ENV | |
echo "VERSION_SUFFIX=" >> $GITHUB_ENV | |
- name: Debug Configuration | |
if: ${{ (github.event.release.prerelease || github.event_name == 'workflow_dispatch') }} | |
run: | | |
echo "BUILD_CONFIGURATION=Debug" >> $GITHUB_ENV | |
echo "VERSION_SUFFIX=develop.$(date +'%y%m%d%H%M%S')" >> $GITHUB_ENV | |
- name: Check Build Configuration | |
if: ${{ env.BUILD_CONFIGURATION == '' }} | |
run: | | |
echo "Invalid Build Configuration" | |
exit 1 | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Restore Dependencies | |
run: dotnet restore ${{ env.SOLUTION_NAME }} | |
- name: Build | |
run: dotnet build --no-restore --configuration ${{ env.BUILD_CONFIGURATION }} ${{ env.SOLUTION_NAME }} | |
- name: Test | |
run: dotnet test --no-build --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} ${{ env.SOLUTION_NAME }} | |
- name: Pack and Push | |
run: dotnet pack --no-build --configuration ${{ env.BUILD_CONFIGURATION }} -p:PackageOutputPath=../../output --version-suffix "${{ env.VERSION_SUFFIX }}" -p:PackageSource='${{ env.NUGET_SOURCE }}' -p:PushAfterPack=true -p:PackageApiKey='${{ secrets.NUGET_API_KEY }}' |