upgrade net version for test projects #23
Workflow file for this run
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
name: package | |
on: | |
push: | |
tags: | |
- "*" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 01 Checkout Code | |
uses: actions/checkout@v2 | |
- name: 02 Setup .Net SDK | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: | | |
7.0.100 | |
- name: 03 Build with dotnet | |
run: dotnet build | |
code-check-format: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 01 Checkout Code | |
uses: actions/checkout@v2 | |
- name: 02 Setup .Net SDK | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: | | |
7.0.100 | |
- name: 03 Restore Dotnet Tool | |
run: dotnet tool restore | |
- name: 04 Check Code Format | |
run: dotnet format --verify-no-changes | |
code-scan-sonar: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 01 Checkout Code | |
uses: actions/checkout@v2 | |
- name: 02 Setup .Net SDK | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: | | |
7.0.100 | |
- name: 03 Setup JDK 11 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 1.11 | |
- name: 04 Install SonarScanner | |
run: dotnet tool restore | |
- name: 05 Set Sonar Environments | |
run: | | |
SONAR_OWNER=$(echo ${GITHUB_REPOSITORY_OWNER} | tr 'A-Z' 'a-z') | |
SONAR_PROJECT=$(echo ${GITHUB_REPOSITORY} | tr 'A-Z' 'a-z' | tr '/' '_') | |
echo SONAR_OWNER=${SONAR_OWNER} >> $GITHUB_ENV | |
echo SONAR_PROJECT=${SONAR_PROJECT} >> $GITHUB_ENV | |
- name: 06 Begin Scan With SonarCloud | |
run: dotnet sonarscanner begin /k:${SONAR_PROJECT} /o:${SONAR_OWNER} /d:sonar.login="${{secrets.SONAR_TOKEN}}" /d:sonar.host.url="https://sonarcloud.io" | |
- name: 07 Build with dotnet | |
run: dotnet build | |
- name: 08 End Scan With SonarCloud | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: dotnet sonarscanner end /d:sonar.login="${{secrets.SONAR_TOKEN}}" | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 01 Checkout Code | |
uses: actions/checkout@v1 | |
- name: 02 Setup .Net SDK | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: | | |
7.0.100 | |
- name: 03 Restore Dotnet Tool | |
run: dotnet tool restore | |
- name: 04 Run Unit test | |
run: dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Exclude="[*Test]*" | |
# - name: 05 Combin All Test Report | |
# run: dotnet reportgenerator -reports:test/**/coverage.cobertura.xml -reporttype:cobertura -targetdir:. | |
# - name: 06 Save Artifact | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: cobertura_report | |
# path: ./Cobertura.xml | |
# - name: 07 Upload coverage to Codecov | |
# uses: codecov/codecov-action@v2 | |
# with: | |
# token: ${{ secrets.CODECOV_TOKEN }} | |
# flags: unittests | |
# fail_ci_if_error: true | |
release: | |
needs: [build, test, code-check-format, code-scan-sonar] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 01 Checkout Code | |
uses: actions/checkout@v2 | |
- name: 02 Setup .Net SDK | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: | | |
7.0.100 | |
- name: 03 Set Git Tag Name | |
run: echo GIT_TAG=${GITHUB_REF:10} >> $GITHUB_ENV | |
- name: 04 Set Pack Version | |
run: echo PACK_VERSION=${GIT_TAG#v} >> $GITHUB_ENV | |
- name: 05 Create Package | |
run: dotnet pack -p:PackageVersion=${PACK_VERSION} -p:RepositoryUrl=${{github.event.repository.url}} -p:PackageProjectUrl=${{github.event.repository.url}} -o .publish --configuration Release | |
- name: 06 Push Package | |
run: bash ./.github/scripts/pushpack.sh .publish ${{secrets.NUGET_APIKEY}} | |
- name: 07 Set Image Tag | |
run: echo IMAGE_VERSION=${GIT_TAG#v} >> $GITHUB_ENV | |
- name: 08 Build and Push Image Tag | |
run: bash ./.github/scripts/pushdocker.sh ${{secrets.DOCKER_USERNAME}} ${{secrets.DOCKER_PASSWORD}} |