idek anymore atp #9
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 NuGet Package | |
on: | |
push: | |
branches: | |
- dev | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: '7.x' | |
- name: Determine project name | |
id: project_name | |
run: | | |
csproj_file=$(find ${GITHUB_WORKSPACE} -name '*.csproj' -print -quit) | |
project_name=$(basename "$csproj_file" .csproj) | |
echo "::set-output name=name::$project_name" | |
- name: Determine version | |
id: version | |
run: | | |
version=$(grep -oP '<Version>.*?</Version>' ${GITHUB_WORKSPACE}/${{ steps.project_name.outputs.name }}.csproj | grep -oP '\d+\.\d+\.\d+') | |
echo "::set-output name=version::$version" | |
- name: Pack | |
run: | | |
base_version="${{ steps.version.outputs.version }}" | |
version="${base_version}-dev0.$((${GITHUB_RUN_NUMBER} / 100)).$((${GITHUB_RUN_NUMBER} % 100))" | |
dotnet pack --configuration Release /p:Version=$version --output nupkgs | |
- name: Publish to NuGet | |
run: dotnet nuget push nupkgs/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json |