diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml new file mode 100644 index 00000000..f00ef79c --- /dev/null +++ b/.github/workflows/ci-cd.yml @@ -0,0 +1,75 @@ +name: OData.QueryBuilder ci\cd +on: + push: + branches: + - main + pull_request: +env: + DOTNET_VERSION: '3.1.x' +jobs: + ci: + name: build&test&coverage(${{matrix.os}}) + runs-on: ${{ matrix.os }} + environment: ci + strategy: + matrix: + os: [ubuntu-latest] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup .NET SDK ${{ matrix.dotnet-version }} + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + - name: Build + run: dotnet build -c ${{ vars.CONFIGURATION }} + - name: Test + run: dotnet test -c ${{ vars.CONFIGURATION }} --no-build + - name: Coveralls + run: | + dotnet minicover instrument + dotnet minicover reset + dotnet test -c ${{ vars.CONFIGURATION }} --no-build + dotnet minicover uninstrument + dotnet minicover report + dotnet minicover coverallsreport --service-name "github" \ + --service-job-id ${{ github.run_id }} \ + --repo-token ${{ secrets.COVERALLS_REPO_TOKEN }} \ + --branch ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} \ + --commit ${{ github.sha }} + cd: + needs: ci + if: github.ref == 'refs/heads/main' + name: publish&release + runs-on: ubuntu-latest + environment: cd + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Create tag + id: create_tag + run: | + git fetch --tags --force &> /dev/null + PR_TITLE=$(git log -1 --pretty='%f') + LAST_TAG=$(echo $(git describe --tags $(git rev-list --tags --max-count=1)) | cut -d'v' -f 2) + CURRENT_MAJOR=$(echo $LAST_TAG | cut -d. -f 1) + CURRENT_MINOR=$(echo $LAST_TAG | cut -d. -f 2) + CURRENT_PATCH=$(echo $(echo $LAST_TAG | cut -d. -f 3) | cut -d- -f 1) + RC=$(echo $(echo $LAST_TAG | cut -d. -f 3) | cut -d- -f 2) + MAJOR=$(([ "$RC" == "rc" ] && echo $CURRENT_MAJOR) || ([ "$(echo $PR_TITLE | grep -oP 'release')" == "release" ] && echo $(($CURRENT_MAJOR+1))) || echo $CURRENT_MAJOR) + MINOR=$(([ "$RC" == "rc" ] && echo $CURRENT_MINOR) || ([ "$(echo $PR_TITLE | grep -oP 'release')" == "release" ] && echo 0) || ([ "$(echo $PR_TITLE | grep -oP 'feature')" == "feature" ] && echo $(($CURRENT_MINOR+1))) || echo $CURRENT_MINOR) + PATCH=$(([ "$RC" == "rc" ] && echo $CURRENT_PATCH) || ([ "$(echo $PR_TITLE | grep -oP 'release')" == "release" ] && echo 0) || ([ "$(echo $PR_TITLE | grep -oP 'feature')" == "feature" ] && echo 0) || echo $(($CURRENT_PATCH+1))) + NEW_TAG=$(echo $MAJOR.$MINOR.$PATCH) + PACKAGE_VERSION=${NEW_TAG:-${{ vars.DEFAULT_PACKAGE_VERSION }}} + echo "release_package_version=$PACKAGE_VERSION" >> "$GITHUB_OUTPUT" + echo $PACKAGE_VERSION + - name: Pack + run: dotnet pack -c ${{ vars.CONFIGURATION }} -p:PackageVersion=${{ steps.create_tag.outputs.release_package_version }} + - name: Release + env: + GH_TOKEN: ${{ secrets.ACCSESS_TOKEN }} + run: | + dotnet nuget push ./src/OData.QueryBuilder/bin/Release/OData.QueryBuilder.${{ steps.create_tag.outputs.release_package_version }}.nupkg -k ${{ secrets.NUGET_API_KEY }} -s ${{ vars.NUGET_SOURCE }} + git tag v${{ steps.create_tag.outputs.release_package_version }} + git push origin v${{ steps.create_tag.outputs.release_package_version }} + gh release create v${{ steps.create_tag.outputs.release_package_version }} --generate-notes \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a8bbf9fa..00000000 --- a/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -language: csharp -dotnet: 3.1 -mono: none -solution: OData.QueryBuilder.sln -branches: - only: - - main -before_script: - - dotnet restore -script: - - dotnet build - - dotnet test ./test/OData.QueryBuilder.Test -c $CONFIGURATION -f netcoreapp3.1 -after_success: - - dotnet minicover instrument - - dotnet minicover reset - - dotnet test --no-build ./test/OData.QueryBuilder.Test -c $CONFIGURATION -f netcoreapp3.1 - - dotnet minicover uninstrument - - dotnet minicover report - - dotnet minicover coverallsreport --service-name "travis-ci" --service-job-id $TRAVIS_JOB_ID -before_deploy: - - git checkout origin/main && git fetch && git remote set-url origin https://${GITHUB_OAUTH_TOKEN}@github.com/ZEXSM/OData.QueryBuilder.git - - PR_TITLE=$(git log -1 --pretty='%f') - - LAST_TAG=$(echo $(git describe --tags $(git rev-list --tags --max-count=1)) | cut -d'v' -f 2) - - CURRENT_MAJOR=$(echo $LAST_TAG | cut -d. -f 1) - - CURRENT_MINOR=$(echo $LAST_TAG | cut -d. -f 2) - - CURRENT_PATCH=$(echo $(echo $LAST_TAG | cut -d. -f 3) | cut -d- -f 1) - - RC=$(echo $(echo $LAST_TAG | cut -d. -f 3) | cut -d- -f 2) - - MAJOR=$(([ "$RC" == "rc" ] && echo $CURRENT_MAJOR) || ([ "$(echo $PR_TITLE | grep -oP 'release')" == "release" ] && echo $(($CURRENT_MAJOR+1))) || echo $CURRENT_MAJOR) - - MINOR=$(([ "$RC" == "rc" ] && echo $CURRENT_MINOR) || ([ "$(echo $PR_TITLE | grep -oP 'release')" == "release" ] && echo 0) || ([ "$(echo $PR_TITLE | grep -oP 'feature')" == "feature" ] && echo $(($CURRENT_MINOR+1))) || echo $CURRENT_MINOR) - - PATCH=$(([ "$RC" == "rc" ] && echo $CURRENT_PATCH) || ([ "$(echo $PR_TITLE | grep -oP 'release')" == "release" ] && echo 0) || ([ "$(echo $PR_TITLE | grep -oP 'feature')" == "feature" ] && echo 0) || echo $(($CURRENT_PATCH+1))) - - NEW_TAG=$(echo $MAJOR.$MINOR.$PATCH) - - PACKAGE_VERSION=${NEW_TAG:-$DEFAULT_PACKAGE_VERSION} - - git tag v$PACKAGE_VERSION && git push origin v$PACKAGE_VERSION - - dotnet pack -c $CONFIGURATION -p:PackageVersion=$PACKAGE_VERSION -deploy: - provider: releases - name: v$PACKAGE_VERSION - token: $GITHUB_OAUTH_TOKEN - cleanup: true - repo: ZEXSM/OData.QueryBuilder - on: - branch: main -after_deploy: - - dotnet nuget push ./src/OData.QueryBuilder/bin/Release/OData.QueryBuilder.$PACKAGE_VERSION.nupkg -k $NUGET_API_KEY -s $NUGET_SOURCE \ No newline at end of file diff --git a/OData.QueryBuilder.sln b/OData.QueryBuilder.sln index 308a2b38..61cab4c1 100644 --- a/OData.QueryBuilder.sln +++ b/OData.QueryBuilder.sln @@ -14,7 +14,6 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "items", "items", "{179F88B9-A06D-4505-9266-A5D66004601C}" ProjectSection(SolutionItems) = preProject .gitignore = .gitignore - .travis.yml = .travis.yml README.md = README.md EndProjectSection EndProject @@ -27,6 +26,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OData.QueryBuilder.Benchmar EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OData.QueryBuilder.Fakes", "test\OData.QueryBuilder.Fakes\OData.QueryBuilder.Fakes.csproj", "{421FF96A-2F4E-4589-AF2A-604FDC8BE2AC}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "github", "github", "{C1D8FFE9-07E2-4EA7-AF59-C5A68F7DB89C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{D95B88FB-7257-421E-8AA3-BD85C63ECBE6}" + ProjectSection(SolutionItems) = preProject + .github\workflows\ci-cd.yml = .github\workflows\ci-cd.yml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -59,6 +65,8 @@ Global {B8F31CF9-EDE2-4813-A9AC-EBF3514FFE82} = {179F88B9-A06D-4505-9266-A5D66004601C} {3C66CF4E-8FA0-4E81-90DB-B22234A2670C} = {26982440-340F-48A2-9D73-44DB6C52EBF1} {421FF96A-2F4E-4589-AF2A-604FDC8BE2AC} = {26982440-340F-48A2-9D73-44DB6C52EBF1} + {C1D8FFE9-07E2-4EA7-AF59-C5A68F7DB89C} = {179F88B9-A06D-4505-9266-A5D66004601C} + {D95B88FB-7257-421E-8AA3-BD85C63ECBE6} = {C1D8FFE9-07E2-4EA7-AF59-C5A68F7DB89C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D51B9A3-94B0-48DF-BFF5-110B13303535} diff --git a/README.md b/README.md index 1a1e71df..bb2dd894 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Library for creating complex OData queries (OData version 4.01) based on data models with linq syntax. [![Build Status](https://travis-ci.com/ZEXSM/OData.QueryBuilder.svg?branch=main)](https://travis-ci.com/ZEXSM/OData.QueryBuilder) -[![Coverage Status](https://coveralls.io/repos/github/ZEXSM/OData.QueryBuilder/badge.svg?branch=master)](https://coveralls.io/github/ZEXSM/OData.QueryBuilder?branch=master) +[![Coverage Status](https://coveralls.io/repos/github/ZEXSM/OData.QueryBuilder/badge.svg?branch=master)](https://coveralls.io/github/ZEXSM/OData.QueryBuilder?branch=main) [![Nuget Status](https://img.shields.io/nuget/dt/OData.QueryBuilder.svg)](https://www.nuget.org/packages/OData.QueryBuilder) ## Benefits diff --git a/src/OData.QueryBuilder/OData.QueryBuilder.csproj b/src/OData.QueryBuilder/OData.QueryBuilder.csproj index 4d3d26ca..3f379831 100644 --- a/src/OData.QueryBuilder/OData.QueryBuilder.csproj +++ b/src/OData.QueryBuilder/OData.QueryBuilder.csproj @@ -5,7 +5,7 @@ true snupkg netstandard2.0 - OData.QueryBuilder + DotNetToolTest $(PackageVersion) MIT true diff --git a/test/OData.QueryBuilder.Benchmark/OData.QueryBuilder.Benchmark.csproj b/test/OData.QueryBuilder.Benchmark/OData.QueryBuilder.Benchmark.csproj index 275f079c..9b013683 100644 --- a/test/OData.QueryBuilder.Benchmark/OData.QueryBuilder.Benchmark.csproj +++ b/test/OData.QueryBuilder.Benchmark/OData.QueryBuilder.Benchmark.csproj @@ -1,17 +1,18 @@ - - Exe - netcoreapp3.1 - + + Exe + false + netcoreapp3.1 + - - - + + + - - - - + + + + diff --git a/test/OData.QueryBuilder.Fakes/OData.QueryBuilder.Fakes.csproj b/test/OData.QueryBuilder.Fakes/OData.QueryBuilder.Fakes.csproj index 9f5c4f4a..5daedb11 100644 --- a/test/OData.QueryBuilder.Fakes/OData.QueryBuilder.Fakes.csproj +++ b/test/OData.QueryBuilder.Fakes/OData.QueryBuilder.Fakes.csproj @@ -1,7 +1,8 @@ - - netstandard2.0 - + + netstandard2.0 + false + diff --git a/test/OData.QueryBuilder.Test/OData.QueryBuilder.Test.csproj b/test/OData.QueryBuilder.Test/OData.QueryBuilder.Test.csproj index 939f71ec..465c6f0e 100644 --- a/test/OData.QueryBuilder.Test/OData.QueryBuilder.Test.csproj +++ b/test/OData.QueryBuilder.Test/OData.QueryBuilder.Test.csproj @@ -1,16 +1,16 @@  - - netcoreapp3.1 - false - - - - - - - - - - - + + netcoreapp3.1 + false + + + + + + + + + + + \ No newline at end of file