Skip to content

Merge pull request #47 from stricq/dev #55

Merge pull request #47 from stricq/dev

Merge pull request #47 from stricq/dev #55

Workflow file for this run

name: Build and Publish
on: [create, push, workflow_dispatch]
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NUGET_DIR: ${{ github.workspace }}/nuget
jobs:
unit_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .Net
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x
cache: true
cache-dependency-path: '**/packages.lock.json'
- name: Restore Nuget Packages
run: dotnet restore --locked-mode
- name: Clean Debug
run: dotnet clean --configuration Debug
- name: Build Debug
run: dotnet build --configuration Debug --no-restore --packages ./.nuget/packages
- name: Unit Tests
run: dotnet test --configuration Debug --no-build --filter TestCategory=Unit
build_publish:
if: ${{ startsWith(github.ref_name, 'prerelease') || startsWith(github.ref_name, 'release') }}
runs-on: ubuntu-latest
needs: [unit_tests]
steps:
- uses: actions/checkout@v4
- name: Setup .Net
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x
cache: true
cache-dependency-path: '**/packages.lock.json'
- name: Setup Environment Variables
run: |
github_sha_hash=${{ github.sha }}
git_hash="${github_sha_hash:0:7}"
TZ=America/Denver
printf -v jdate '%(%y%j%H%M)T'
branch_name=${{ github.ref_name }}
values=(${branch_name//_/ })
branch=${values[0]}
version=${values[1]}
if [ $branch == 'release' ]; then
branch_version="${version}+${git_hash}"
else
branch_version="${version}-pre.${jdate}+${git_hash}"
fi
echo $branch_version
echo "BRANCH_VERSION=${branch_version}" >> "$GITHUB_ENV"
- name: Restore Nuget Packages
run: dotnet restore --locked-mode
- name: Clean Release
run: dotnet clean --configuration Release
- name: Build Release
run: dotnet build --configuration Release --no-restore -p:Version="$BRANCH_VERSION" -p:PublishRepositoryUrl=true
- name: Package Nuget
run: dotnet pack --configuration Release --no-build --include-symbols -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -p:PackageVersion="$BRANCH_VERSION" --output "$NUGET_DIR"
- name: Publish Nuget
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push "$NUGET_DIR/*.nupkg" -k "$NUGET_API_KEY" -s https://api.nuget.org/v3/index.json --skip-duplicate