Skip to content

Commit

Permalink
Add GitHub Action
Browse files Browse the repository at this point in the history
  • Loading branch information
ermshiperete committed Aug 4, 2022
1 parent 4beed2c commit d5ec615
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/CI-CD.yml
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions .github/workflows/test-results.yml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit d5ec615

Please sign in to comment.