From 95a10583e500336fbb1e9da10fae1c2e10e72413 Mon Sep 17 00:00:00 2001 From: Daniil Tolstov Date: Tue, 26 Mar 2024 17:20:11 +0100 Subject: [PATCH] Add publish nuget git action --- .github/FUNDING.yml | 4 ---- .github/workflows/build.yml | 30 ------------------------- .github/workflows/publish-nuget.yml | 34 +++++++++++++++++++++++++++++ .github/workflows/publish.yml | 29 ------------------------ 4 files changed, 34 insertions(+), 63 deletions(-) delete mode 100644 .github/FUNDING.yml delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/publish-nuget.yml delete mode 100644 .github/workflows/publish.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 876d1ec..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,4 +0,0 @@ -# These are supported funding model platforms - -github: shibayan -custom: paypal.me/shibayan \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index a4eebc6..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Build - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -env: - DOTNET_VERSION: 7.0.x - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Use .NET ${{ env.DOTNET_VERSION }} - uses: actions/setup-dotnet@v3 - with: - dotnet-version: ${{ env.DOTNET_VERSION }} - - - name: Build project - run: dotnet build -c Release - - - name: Run test cases - run: dotnet test -c Release --no-build - - - name: Lint C# code - run: dotnet format --verify-no-changes --verbosity detailed --no-restore diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml new file mode 100644 index 0000000..3e30119 --- /dev/null +++ b/.github/workflows/publish-nuget.yml @@ -0,0 +1,34 @@ +name: Build and publish package + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + push: + branches: [ master ] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@master + + - name: Setup .NET environment + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '6.0.100' + + - name: Build project + working-directory: ./CsvHelper.FastDynamic + run: dotnet build --configuration Release + + - name: Generate a NuGet package + working-directory: ./CsvHelper.FastDynamic + run: dotnet pack --no-build -c Release -o . + + - name: Push to GitHub package registry + working-directory: ./CsvHelper.FastDynamic + run: dotnet nuget push "*.nupkg" -k ${{secrets.NUGETORGTOKEN}} -s https://api.nuget.org/v3/index.json --skip-duplicate diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 15db58a..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Publish - -on: - push: - tags: [ v* ] - -env: - DOTNET_VERSION: 7.0.x - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Use .NET ${{ env.DOTNET_VERSION }} - uses: actions/setup-dotnet@v3 - with: - dotnet-version: ${{ env.DOTNET_VERSION }} - - - name: Setup Version - id: setup_version - run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_OUTPUT - - - name: Pack NuGet Package - run: dotnet pack CsvHelper.FastDynamic/CsvHelper.FastDynamic.csproj -c Release -o ./dist -p:Version=${{ steps.setup_version.outputs.VERSION }} - - - name: Publish - run: dotnet nuget push dist/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json