-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
name: GitHubAction | ||
|
||
on: | ||
push: | ||
branches: | ||
- releases/* | ||
workflow_call: | ||
secrets: | ||
SONAR_TOKEN: | ||
required: true | ||
|
||
env: | ||
BuildConfiguration: ${{ startsWith(github.ref, 'refs/heads/releases') && 'Release' || 'Debug' }} | ||
|
||
jobs: | ||
CI: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
release_version: ${{ steps.PassOutputReleaseVersion.releaseVersion }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Using .NET from 'global.json' | ||
uses: actions/setup-dotnet@v1 | ||
|
||
- name: Restore Nuget Packages | ||
run: | | ||
config=$(find . -name 'NuGet.config') | ||
for csproj in $(find . -name '*.csproj'); do | ||
dotnet restore $csproj --configfile $config --verbosity minimal | ||
done | ||
shell: bash | ||
|
||
- name: Build | ||
run: dotnet build --nologo --no-restore --configuration ${{env.BuildConfiguration}} | ||
|
||
- name: Test | ||
run: dotnet test --nologo --no-restore --configuration ${{env.BuildConfiguration}} | ||
|
||
- name: Pack | ||
run: dotnet pack --no-build --configuration ${{env.BuildConfiguration}} --output nupkg | ||
|
||
- name: Generate Coverage Report | ||
run: | | ||
./tools/reportgenerator -reports:coverage/*/coverage.cobertura.xml -targetdir:CodeCoverage -reporttypes:MarkdownSummaryGithub | ||
./tools/reportgenerator -reports:coverage/*/coverage.cobertura.xml -targetdir:CodeCoverage -reporttypes:Cobertura | ||
continue-on-error: true | ||
|
||
- name: Publish Coverage Report | ||
uses: actions/upload-artifact@v2 | ||
continue-on-error: true | ||
with: | ||
name: code-coverage-report | ||
path: ${{ github.workspace }}/CodeCoverage/SummaryGithub.md | ||
#- name: SonarCloud Scan | ||
# uses: sonarsource/sonarcloud-github-action@master | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
# with: | ||
# projectBaseDir: ${{ github.workspace }} | ||
# args: > | ||
# -Dsonar.organization=encamina | ||
# -Dsonar.projectKey=${{secrets.SONAR_TOKEN}} | ||
# -Dsonar.python.coverage.reportPaths=CodeCoverage/Cobertura.xml | ||
# -Dsonar.tests=tst/ | ||
# -Dsonar.verbose=true | ||
|
||
# The folder on which nugets are located is zipped, then it is moved to the workspace. | ||
- name: Zip Artifact for deployment | ||
run: | | ||
cd ${{ github.workspace }}/nupkg | ||
zip -r nupkg.zip * | ||
mv ./nupkg.zip ${{ github.workspace }} | ||
- name: Upload Artifact for Continuous Deployment | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: enmarcha-libraries-${{ github.run_number }} | ||
path: nupkg.zip | ||
|
||
CD: | ||
runs-on: ubuntu-latest | ||
needs: CI | ||
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/releases') | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Read and Store Version | ||
id: PassOutputReleaseVersion | ||
shell: pwsh | ||
run: | | ||
$xml = [Xml] (Get-Content "${{ github.workspace }}/Directory.Build.props") | ||
$prefix = [System.Linq.Enumerable]::FirstOrDefault($xml.Project.PropertyGroup.VersionPrefix, [Func[object,bool]]{ param($x) $x -ne $null }) | ||
$suffix = [System.Linq.Enumerable]::FirstOrDefault($xml.Project.PropertyGroup.VersionSuffix, [Func[object,bool]]{ param($x) $x -ne $null }) | ||
$release_version = ($prefix, $suffix) | ? { $_ } | Join-String -Separator "-" | ||
echo "RELEASE_VERSION=$release_version" >> $env:GITHUB_OUTPUT | ||
- name: Create Tag | ||
run: | | ||
git config --global user.name "${{ github.actor }}" | ||
git config --global user.email "${{ github.actor }}@users.noreply.github.com" | ||
git tag -a "Release-${{ steps.PassOutputReleaseVersion.outputs.RELEASE_VERSION }}" -m "Version from build ${{ github.run_number }}" | ||
- name: Download Libraries for Continuous Deployment | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: enmarcha-libraries-${{ github.run_number }} | ||
path: ./ | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: "v${{ steps.PassOutputReleaseVersion.outputs.RELEASE_VERSION }}" | ||
release_name: "Release ${{ steps.PassOutputReleaseVersion.outputs.RELEASE_VERSION }}" | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload Release Assets | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./nupkg.zip | ||
asset_name: enmarcha-libraries-${{ github.run_number }}.zip | ||
asset_content_type: application/zip |