Update actions/setup-dotnet action to v4 (#36) #41
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 Nuget | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set VERSION variable from latest tag (if existing) plus date and commit | |
run: | | |
LATEST_TAG=$(git ls-remote --tags origin | tail -n 1 | awk '{ print $2; }' | sed 's/.*v//') | |
echo "LATEST_TAG: ${LATEST_TAG}" | |
LATEST_TAG=${LATEST_TAG:=0.0.1} | |
VERSION=${LATEST_TAG}-next.$(date +%Y%m%d).${GITHUB_RUN_NUMBER} | |
echo "VERSION: ${VERSION}" | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: Set SOLUTION variable to point to solution file | |
run: | | |
SOLUTION=$(find . -name '*.sln' -printf "%p" -quit) | |
echo "SOLUTION: ${SOLUTION}" | |
echo "SOLUTION=${SOLUTION}" >> $GITHUB_ENV | |
- name: Build | |
run: dotnet build --configuration Release /p:Version=${VERSION} ${SOLUTION} | |
- name: Pack with debug symbols | |
run: dotnet pack --configuration Release /p:Version=${VERSION} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output . ${SOLUTION} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: package | |
path: '*.*nupkg' | |
push: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: package | |
- name: Push to NuGet | |
run: dotnet nuget push *.nupkg --source https://nuget.pkg.github.com/${GITHUB_REPOSITORY%/*}/index.json --api-key ${GITHUB_TOKEN} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |