| name: Build |
| |
| on: |
| push: |
| branches: [ master ] |
| pull_request: |
| branches: [ master ] |
| |
| env: |
| SHA: ${{ GITHUB.SHA }} |
| REF: ${{ GITHUB.REF }} |
| RUN_ID: ${{ GITHUB.RUN_ID }} |
| RUN_NUMBER: ${{ GITHUB.RUN_NUMBER }} |
| BUILD_RUN_NUMBER: build.${{ GITHUB.RUN_NUMBER }} |
| GITHUB_TOKEN: ${{ SECRETS.GITHUB_TOKEN }} |
| MYGET_API_TOKEN: ${{ SECRETS.MYGET_API_TOKEN }} |
| COVERALLS_REPO_TOKEN: ${{ SECRETS.COVERALLS_REPO_TOKEN }} |
| |
| jobs: |
| |
| build: |
| runs-on: windows-latest |
| |
| steps: |
| - name: Checkout |
| uses: actions/checkout@v2 |
| with: |
| fetch-depth: 0 |
| |
| - name: Git fetch tags |
| run: git fetch --tags |
| |
| - name: Check tags |
| run: git tag -l -n |
| |
| - name: Setup dotnet 3.1.x sdk |
| uses: actions/setup-dotnet@v1 |
| with: |
| dotnet-version: 3.1.x |
| |
| - name: Setup .NET 5.0.x SDK |
| uses: actions/setup-dotnet@v1 |
| with: |
| dotnet-version: 5.0.x |
| |
| - name: Check .NET info |
| run: dotnet --info |
| |
| - name: Install dependencies |
| run: nuget restore |
| |
| - name: Build solution |
| run: dotnet build -c Release --no-restore |
| |
| - name: Test solution |
| run: dotnet test -c Release --no-build --no-restore --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=../ |
| |
| - name: Upload coverage |
| if: github.repository_owner == 'casbin-net' && github.ref == 'refs/heads/master' |
| run: | |
| dotnet tool install coveralls.net --version 2.0.0-beta0002 --tool-path "./tools"; |
| |
| $CommitAuthor = git show -s --pretty=format:"%cn"; |
| echo "Coomit author is: $CommitAuthor"; |
| |
| $CommitAuthorEmail = git show -s --pretty=format:"%ce"; |
| echo "Coomit author email is: $CommitAuthorEmail"; |
| |
| $CommitMessage = git show -s --pretty=format:"%s"; |
| echo "Coomit message is: $CommitMessage"; |
| |
| ./tools/csmacnz.Coveralls --opencover -i coverage.net452.opencover.xml --repoToken $env:COVERALLS_REPO_TOKEN ` |
| --commitId $env:SHA --commitBranch $env:REF --commitAuthor "$CommitAuthor" ` |
| --commitEmail "$CommitAuthorEmail" --commitMessage "$CommitMessage" ` |
| --jobId $env:RUN_NUMBER --serviceName github-actions --useRelativePaths; |
| |
| ./tools/csmacnz.Coveralls --opencover -i coverage.net461.opencover.xml --repoToken $env:COVERALLS_REPO_TOKEN ` |
| --commitId $env:SHA --commitBranch $env:REF --commitAuthor "$CommitAuthor" ` |
| --commitEmail "$CommitAuthorEmail" --commitMessage "$CommitMessage" ` |
| --jobId $env:RUN_NUMBER --serviceName github-actions --useRelativePaths; |
| |
| ./tools/csmacnz.Coveralls --opencover -i coverage.netcoreapp3.1.opencover.xml --repoToken $env:COVERALLS_REPO_TOKEN ` |
| --commitId $env:SHA --commitBranch $env:REF --commitAuthor "$CommitAuthor" ` |
| --commitEmail "$CommitAuthorEmail" --commitMessage "$CommitMessage" ` |
| --jobId $env:RUN_NUMBER --serviceName github-actions --useRelativePaths; |
| |
| if($LastExitCode -ne 0) |
| { |
| Write-Warning -Message "Can not upload coverage, laat exit code is ${LastExitCode}." |
| $LastExitCode = 0; |
| } |
| |
| - name: Pack packages |
| run: | |
| $LastTag = git describe --tags (git rev-list --tags --max-count=1); |
| echo "Last tag is: $LastTag"; |
| |
| $Version = ($LastTag).TrimStart('v').TrimEnd("beta").TrimEnd("preview"); |
| echo "Publishing version: $Version"; |
| |
| $NowBranchName = git rev-parse --abbrev-ref HEAD; |
| echo "Now branch name: $NowBranchName"; |
| |
| $PackageVersion = ($LastTag).TrimStart('v') + "-" + $env:BUILD_RUN_NUMBER + "." + $NowBranchName + "." + $env:SHA.SubString(0, 7); |
| echo "Publishing package version: ${PackageVersion}"; |
| |
| dotnet pack -c Release -o packages /p:PackageVersion=$PackageVersion /p:Version=$Version --no-build; |
| |
| - name: Publish artefacts |
| uses: actions/upload-artifact@v1.0.0 |
| with: |
| name: "drop-ci-packages" |
| path: './packages' |
| |
| release-build-version: |
| runs-on: windows-latest |
| needs: build |
| if: github.repository_owner == 'casbin-net' && github.ref == 'refs/heads/master' |
| steps: |
| - name: Download Artefact |
| uses: actions/download-artifact@v1 |
| with: |
| name: 'drop-ci-packages' |
| |
| - name: Add myget nuget source |
| run: dotnet nuget add source https://www.myget.org/F/casbin-net/api/v2/package --name myget.org |
| |
| - name: Push myget package |
| run: dotnet nuget push .\drop-ci-packages\*.nupkg -s myget.org -k $env:MYGET_API_TOKEN --skip-duplicate |