diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index 6e8ca9f..994974b 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -2,15 +2,12 @@ name: .NET Build, Test, and Publish Nuget Package on: push: - branches: - - "**" + branches: [ "main", "develop"] tags: - "v[0-9]+.[0-9]+.[0-9]+" - pull_request: - branches: - - "**" + env: - VERSION: 1.0.0 + VERSION: none defaults: run: @@ -21,11 +18,22 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set Version Variable + - name: Set Release Version Variable if: ${{ github.ref_type == 'tag' }} env: TAG: ${{ github.ref_name }} run: echo "VERSION=${TAG#v}" >> $GITHUB_ENV + - name: Set outputs + if: ${{ github.ref_type == 'branch' }} + id: vars + run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + - name: Set Branch Version Variable + if: ${{ github.ref_type == 'branch' }} + env: + TAG: ${{ github.ref_name }} + MAJOR_VERSION: ${{ vars.MAJOR_VERSION }} + SHA_SHORT: ${{ steps.vars.outputs.sha_short }} + run: echo "VERSION=${MAJOR_VERSION}-${TAG#v}-${SHA_SHORT}-preview" >> $GITHUB_ENV - name: Setup .NET uses: actions/setup-dotnet@v4 with: @@ -33,11 +41,9 @@ jobs: - name: Restore dependencies run: dotnet restore - name: Build - run: dotnet build --no-restore /p:Version=$VERSION - - name: Test - run: dotnet test --no-build --verbosity normal + run: dotnet build -c Release --no-restore /p:Version=$VERSION - name: pack nuget packages run: dotnet pack --output nupkgs --no-restore --no-build /p:PackageVersion=$VERSION - name: upload nuget package - if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') +# if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') run: dotnet nuget push nupkgs/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json \ No newline at end of file