v2.0.1 #22
Workflow file for this run
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 | |
- name: Debug Configuration | |
if: ${{ (github.event.release.prerelease || github.event_name == 'workflow_dispatch') }} | |
run: | | |
echo "BUILD_CONFIGURATION=Debug" >> $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: Get Current Version | |
id: get_version | |
shell: pwsh | |
run: | | |
Import-Module ./solution-helper.psm1 -Force | |
$build_version = Get-Version | |
echo "build_version=$build_version" | Out-File -FilePath $env:GITHUB_ENV -Append | |
- name: Get Version Suffix | |
id: get_version_suffix | |
shell: bash | |
run: | | |
# Fetch the list of releases | |
releases=$(gh release list --json createdAt,tagName --limit 100) | |
# Filter the releases based on the starting version number, sort them by date, and extract the most recent one | |
latest_release=$(echo "$releases" | jq -r --arg build_version "$build_version" 'map(select(.tagName | startswith($build_version))) | sort_by(.createdAt) | reverse | .[0] | .tagName') | |
version_suffix=${latest_release#*$build_version-} | |
if [ "$version_suffix" == "$build_version" ]; then | |
version_suffix="" | |
fi | |
echo "VERSION_SUFFIX=$version_suffix" >> $GITHUB_ENV | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- 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 }}' |