|
| 1 | +name: csharpWorkflow |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: main |
| 6 | + paths: |
| 7 | + - 'csharp/**' |
| 8 | + - '.github/workflows/csharp.yml' |
| 9 | +env: |
| 10 | + NUGETTOKEN: ${{ secrets.NUGET_TOKEN }} |
| 11 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 12 | + SCRIPTS_BASE_URL: https://raw.githubusercontent.com/linksplatform/Scripts/main/MultiProjectRepository |
| 13 | + |
| 14 | +defaults: |
| 15 | + run: |
| 16 | + working-directory: csharp |
| 17 | + |
| 18 | +jobs: |
| 19 | + test: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v1 |
| 23 | + with: |
| 24 | + submodules: true |
| 25 | + - name: Test |
| 26 | + run: | |
| 27 | + dotnet test -c Release -f net6 |
| 28 | + pushNuGetPackageToGitHubPackageRegistry: |
| 29 | + needs: test |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v1 |
| 33 | + with: |
| 34 | + submodules: true |
| 35 | + - uses: nuget/setup-nuget@v1 |
| 36 | + - name: Publish NuGet package to GitHub Package Registry |
| 37 | + run: | |
| 38 | + dotnet build -c Release |
| 39 | + dotnet pack -c Release |
| 40 | + nuget source Add -Name "GitHub" -Source "https://nuget.pkg.github.com/linksplatform/index.json" -UserName linksplatform -Password ${{ secrets.GITHUB_TOKEN }} |
| 41 | + nuget push **/*.nupkg -Source "GitHub" -SkipDuplicate |
| 42 | + pusnToNuget: |
| 43 | + runs-on: ubuntu-latest |
| 44 | + needs: test |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v1 |
| 47 | + with: |
| 48 | + submodules: true |
| 49 | + - name: Read project information |
| 50 | + run: | |
| 51 | + export REPOSITORY_NAME=$(basename ${{ github.repository }}) |
| 52 | + wget "$SCRIPTS_BASE_URL/read_csharp_package_info.sh" |
| 53 | + bash ./read_csharp_package_info.sh |
| 54 | + - name: Publish NuGet package |
| 55 | + run: | |
| 56 | + export REPOSITORY_NAME=$(basename ${{ github.repository }}) |
| 57 | + wget "$SCRIPTS_BASE_URL/push-csharp-nuget.sh" |
| 58 | + bash ./push-csharp-nuget.sh |
| 59 | + publiseRelease: |
| 60 | + runs-on: ubuntu-latest |
| 61 | + needs: test |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v1 |
| 64 | + with: |
| 65 | + submodules: true |
| 66 | + - name: Read project information |
| 67 | + if: ${{ github.event_name == 'push' }} |
| 68 | + run: | |
| 69 | + export REPOSITORY_NAME=$(basename ${{ github.repository }}) |
| 70 | + wget "$SCRIPTS_BASE_URL/read_csharp_package_info.sh" |
| 71 | + bash ./read_csharp_package_info.sh |
| 72 | + - name: Publish release |
| 73 | + run: | |
| 74 | + export REPOSITORY_NAME=$(basename ${{ github.repository }}) |
| 75 | + wget "$SCRIPTS_BASE_URL/publish-release.sh" |
| 76 | + chmod +x ./publish-release.sh |
| 77 | + wget "$SCRIPTS_BASE_URL/publish-csharp-release.sh" |
| 78 | + bash ./publish-csharp-release.sh |
| 79 | + findChangedCsFiles: |
| 80 | + runs-on: ubuntu-latest |
| 81 | + needs: test |
| 82 | + outputs: |
| 83 | + isCsFilesChanged: ${{ steps.setIsCsFilesChangedOutput.outputs.isCsFilesChanged }} |
| 84 | + steps: |
| 85 | + - uses: actions/checkout@v3 |
| 86 | + with: |
| 87 | + fetch-depth: 0 |
| 88 | + - name: Get changed files using defaults |
| 89 | + id: changed-files |
| 90 | + uses: tj-actions/changed-files@v21 |
| 91 | + - name: Set output isCsFilesChanged |
| 92 | + id: setIsCsFilesChangedOutput |
| 93 | + run: | |
| 94 | + isCsFilesChanged='false' |
| 95 | + echo "Changed files: ${{ steps.changed-files.outputs.all_changed_files }}" |
| 96 | + for changedFile in ${{ steps.changed-files.outputs.all_changed_files }}; do |
| 97 | + if [[ $changedFile == *.cs ]] |
| 98 | + then |
| 99 | + echo "isCsFilesChanged='true'" |
| 100 | + isCsFilesChanged='true' |
| 101 | + fi |
| 102 | + done |
| 103 | + echo "::set-output name=isCsFilesChanged::${isCsFilesChanged}" |
| 104 | + echo "isCsFilesChanged: ${isCsFilesChanged}" |
| 105 | + generatePdfWithCode: |
| 106 | + runs-on: ubuntu-latest |
| 107 | + needs: [findChangedCsFiles] |
| 108 | + if: ${{ needs.findChangedCsFiles.outputs.isCsFilesChanged == 'true' }} |
| 109 | + steps: |
| 110 | + - uses: actions/checkout@v1 |
| 111 | + with: |
| 112 | + submodules: true |
| 113 | + - name: Generate PDF with code |
| 114 | + run: | |
| 115 | + export REPOSITORY_NAME=$(basename ${{ github.repository }}) |
| 116 | + wget "$SCRIPTS_BASE_URL/format-csharp-files.py" |
| 117 | + wget "$SCRIPTS_BASE_URL/format-csharp-document.sh" |
| 118 | + wget "$SCRIPTS_BASE_URL/generate-csharp-pdf.sh" |
| 119 | + bash ./generate-csharp-pdf.sh |
| 120 | + publishDocumentation: |
| 121 | + runs-on: ubuntu-latest |
| 122 | + needs: [findChangedCsFiles] |
| 123 | + if: ${{ needs.findChangedCsFiles.outputs.isCsFilesChanged == 'true' }} |
| 124 | + steps: |
| 125 | + - uses: actions/checkout@v1 |
| 126 | + with: |
| 127 | + submodules: true |
| 128 | + - name: Publish documentation to gh-pages branch |
| 129 | + run: | |
| 130 | + export REPOSITORY_NAME=$(basename ${{ github.repository }}) |
| 131 | + wget "$SCRIPTS_BASE_URL/docfx.json" |
| 132 | + wget "$SCRIPTS_BASE_URL/filter.yml" |
| 133 | + wget "$SCRIPTS_BASE_URL/toc.yml" |
| 134 | + wget "$SCRIPTS_BASE_URL/publish-csharp-docs.sh" |
| 135 | + bash ./publish-csharp-docs.sh |
0 commit comments