From d5ec61595f1596a5ac1e6ba2691d65d02ae2dbbd Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Wed, 3 Aug 2022 18:51:35 +0200 Subject: [PATCH] Add GitHub Action --- .github/workflows/CI-CD.yml | 74 ++++++++++++++++++++++++++++++ .github/workflows/test-results.yml | 43 +++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 .github/workflows/CI-CD.yml create mode 100644 .github/workflows/test-results.yml diff --git a/.github/workflows/CI-CD.yml b/.github/workflows/CI-CD.yml new file mode 100644 index 00000000..480fe87c --- /dev/null +++ b/.github/workflows/CI-CD.yml @@ -0,0 +1,74 @@ +name: "Build, Test and Pack" + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] +jobs: + event_file: + name: "Event File" + runs-on: ubuntu-latest + steps: + - name: Upload + uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 + with: + name: Event File + path: ${{ github.event_path }} + + build-and-test: + name: "Build and Test" + strategy: + matrix: + os: [windows-latest, ubuntu-latest] + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 + with: + fetch-depth: '0' + + - name: Install .NET Core + uses: actions/setup-dotnet@c0d4ad69d8bd405d234f1c9166d383b7a4f69ed8 # v2.1.0 + with: + dotnet-version: 6.0.x + + - name: Build + run: dotnet build --configuration Release source/icu.net.sln + + - name: Test + run: dotnet test --configuration Release --no-build source/icu.net.sln -- NUnit.TestOutputXml=TestResults + + - name: Upload Test Results + if: always() + uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 + with: + name: Test Results (${{matrix.os}}) + path: "**/TestResults/*.xml" + + - name: Pack + run: dotnet pack --configuration Release --no-build --include-symbols source/icu.net.sln + + - name: Upload Artifacts + uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 + with: + name: icu-dotnet-nugetpackage + path: | + output/*.nupkg + output/*.snupkg + if: matrix.os == 'ubuntu-latest' + + publish-nuget: + name: "Publish NuGet package" + runs-on: ubuntu-latest + needs: build-and-test + if: github.event_name == 'push' + steps: + - name: Download Artifacts + uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v3.0.0 + with: + path: artifacts + + - name: Publish to Nuget + run: dotnet nuget push artifacts/*.*nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.SILLSDEV_PUBLISH_NUGET_ORG}} --skip-duplicate diff --git a/.github/workflows/test-results.yml b/.github/workflows/test-results.yml new file mode 100644 index 00000000..574e059d --- /dev/null +++ b/.github/workflows/test-results.yml @@ -0,0 +1,43 @@ +# see https://github.com/marketplace/actions/publish-test-results#support-fork-repositories-and-dependabot-branches +# why this file exists +name: Test Results + +on: + workflow_run: + workflows: ["Build, Test and Pack"] + types: + - completed + +jobs: + test-results: + name: Test Results + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion != 'skipped' + + permissions: + checks: write + pull-requests: write + + steps: + - name: Download and Extract Artifacts + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + run: | + mkdir -p artifacts && cd artifacts + + artifacts_url=${{ github.event.workflow_run.artifacts_url }} + + gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact + do + IFS=$'\t' read name url <<< "$artifact" + gh api $url > "$name.zip" + unzip -d "$name" "$name.zip" + done + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@2a60c5d47eb29cd5cc922f51bbea18e148f56203 # v2.0.0 + with: + commit: ${{ github.event.workflow_run.head_sha }} + event_file: artifacts/Event File/event.json + event_name: ${{ github.event.workflow_run.event }} + nunit_files: "artifacts/**/*.xml"