✨ Stylecop.json (#14) #10
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: Pipeline | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
Build: | |
name: Build | |
runs-on: ubuntu-latest | |
outputs: | |
GitVersion_SemVer: ${{ steps.GitVersion.outputs.GitVersion_SemVer }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Full depth (not shallow) for GitVersion and better relevancy of Sonar analysis | |
- name: Set up GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: 6.x | |
- name: Execute GitVersion | |
id: GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
useConfigFile: true | |
additionalArguments: /updateprojectfiles | |
- name: Use .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
global-json-file: global.json | |
# Begin ci-build.ps1 | |
- name: dotnet restore | |
run: dotnet restore | |
- name: dotnet build | |
run: dotnet build -c release --no-restore | |
- name: dotnet pack | |
run: dotnet pack -c release --no-build | |
# End ci-build.ps1 | |
- name: SonarCloud Scan | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
- uses: actions/upload-artifact@v4 | |
if: ${{ github.ref == 'refs/heads/main' }} | |
with: | |
name: nupkg | |
path: artifacts/package/release/${{ github.event.repository.name }}.${{ env.GitVersion_SemVer }}.nupkg | |
if-no-files-found: error | |
retention-days: 1 # Minimal retention b/c only needed for job passing; release manager uploads the same artifact | |
compression-level: 0 # NuGet pack already compresses so do not re-compress? (Not confirmed) | |
Publish: | |
if: ${{ github.ref == 'refs/heads/main' }} | |
name: Publish | |
needs: Build | |
runs-on: ubuntu-latest | |
env: | |
GitVersion_SemVer: ${{needs.Build.outputs.GitVersion_SemVer}} | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: nupkg | |
- name: Set nupkg path (GitVersion-ed) | |
run: | | |
echo 'NUPKG_PATH=${{ github.event.repository.name }}.${{ env.GitVersion_SemVer }}.nupkg' >> "$GITHUB_ENV" | |
- name: Publish to NuGet | |
run: >- | |
dotnet nuget push ${{ env.NUPKG_PATH }} | |
--api-key $NUGET_AUTH_TOKEN | |
--no-symbols | |
--skip-duplicate | |
--source https://api.nuget.org/v3/index.json | |
env: | |
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_AUTH_TOKEN }} | |
- name: git tag | |
run: | | |
git tag v${{ env.GitVersion_SemVer }} | |
git push origin tag v${{ env.GitVersion_SemVer }} |