Skip to content

Commit

Permalink
fix nuget action
Browse files Browse the repository at this point in the history
  • Loading branch information
izharikov committed May 14, 2024
1 parent f665d94 commit 9706a29
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions .github/workflows/nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -21,23 +18,32 @@ 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:
dotnet-version: 8.0.x
- 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

0 comments on commit 9706a29

Please sign in to comment.