diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5f69f72 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,74 @@ +name: Build + +on: + push: + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0.9.10 + with: + versionSpec: "5.7.0" + + - name: Determine Version + id: gitversion + uses: gittools/actions/gitversion/execute@v0.9.10 + with: + useConfigFile: true + configFilePath: "GitVersion.yml" + + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.x + + # Cache packages for faster subsequent runs + - uses: actions/cache@v2 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} + restore-keys: | + ${{ runner.os }}-nuget- + + - name: Restore + working-directory: ./src + run: >- + dotnet nuget add source --username USERNAME --password ${{ secrets.GH_PACKAGES_TOKEN }} --store-password-in-clear-text --name github https://nuget.pkg.github.com/CenterEdge/index.json + && dotnet restore ./CenterEdge.Async.sln + + - name: Build + working-directory: ./src + run: dotnet build --no-restore -c Release /p:Version=${{ steps.gitversion.outputs.semVer }} ./CenterEdge.Async.sln + + - name: Test + working-directory: ./src + run: dotnet test --no-build -c Release -f net5.0 -l 'trx;LogFileName=${{ runner.temp }}/results.trx' ./CenterEdge.Async.sln + + - name: Test Report + uses: dorny/test-reporter@v1 + if: success() || failure() # run this step even if previous step failed + with: + name: Unit Tests + path: ${{ runner.temp }}/results.trx + reporter: dotnet-trx + + - name: Pack + working-directory: ./src + run: dotnet pack --no-build -c Release /p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }} ./CenterEdge.Async.sln + + - name: Push + working-directory: ./src + # Publish CI packages from PRs and tagged releases + if: ${{ startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/pull/') }} + run: dotnet nuget push **/*.${{ steps.gitversion.outputs.nuGetVersionV2 }}.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s github diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 0000000..d0e31f6 --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,10 @@ +mode: ContinuousDelivery +branches: + pull-request: + mode: ContinuousDeployment + tag: ci-pr- + track-merge-target: true +ignore: + sha: [] +merge-message-formats: {} +tag-prefix: "" diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 130bc7a..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,76 +0,0 @@ -def version -def pushTarget - -pipeline { - agent none - - stages { - stage('Build') { - agent { - docker { - image 'mcr.microsoft.com/dotnet/sdk:5.0-buster-slim' - } - } - - environment { - NUGET_API_KEY = credentials('myget-api-key') - HOME = '/tmp' // Doesn't require root user - DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1' - DOTNET_CLI_TELEMETRY_OPTOUT = '1' - } - - steps { - script { - if (env.BRANCH_NAME =~ /\d+\.\d+\.\d+(-[\w\d\-]+)?/) { - // Tagged release - version = env.BRANCH_NAME - pushTarget = 'main' - } else { - // Pull request, build alpha version number - version = "0.1.0-alpha-${env.BRANCH_NAME.toLowerCase()}-${env.BUILD_NUMBER}" - pushTarget = 'ci' - } - } - - sh "dotnet restore -s https://centeredge.myget.org/F/main/auth/${NUGET_API_KEY}/api/v3/index.json ./src/CenterEdge.Async.sln" - sh "dotnet build -c Release /p:VERSION=${version} ./src/CenterEdge.Async.sln" - sh "dotnet test --no-build -f net5.0 -c Release -l 'trx;LogFileName=results.trx' --collect:'XPlat Code Coverage' ./src/CenterEdge.Async.sln" - sh "dotnet pack --no-build -c Release /p:VERSION=${version} ./src/CenterEdge.Async.sln" - - stash name: 'packages', includes: "**/*.${version}.nupkg" - } - - post { - always { - mstest testResultsFile: '**/*.trx' - cobertura coberturaReportFile: '**/coverage.cobertura.xml' - } - } - } - - stage('Publish') { - agent { - docker { - image 'mcr.microsoft.com/dotnet/sdk:5.0-buster-slim' - } - } - - options { - skipDefaultCheckout() - } - - environment { - NUGET_API_KEY = credentials('myget-api-key') - HOME = '/tmp' // Doesn't require root user - DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1' - DOTNET_CLI_TELEMETRY_OPTOUT = '1' - } - - steps { - unstash 'packages' - - sh "dotnet nuget push **/*.${version}.nupkg -s https://centeredge.myget.org/F/${pushTarget}/api/v2/package -k ${env.NUGET_API_KEY}" - } - } - } -} diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000..abeb11c --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,6 @@ + + + + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + + \ No newline at end of file