Skip to content

Commit

Permalink
workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
na1307 committed Jan 1, 2025
1 parent fbc35de commit b9f9de7
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 24 deletions.
30 changes: 9 additions & 21 deletions .github/workflows/SonarCloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Cache NuGet
Expand All @@ -34,19 +29,12 @@ jobs:
restore-keys: ${{ runner.os }}-sonar-nuget-
- name: Install Tools
run: dotnet tool restore
- name: SonarScanner Begin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: dotnet sonarscanner begin /k:"na1307_Bluehill.Analyzers" /o:"na1307" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.scanner.skipJreProvisioning=true
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --no-incremental
- name: Test
run: dotnet coverage collect 'dotnet test --no-build --verbosity normal' -f xml -o 'coverage.xml'
- name: SonarScanner End
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
- name: SonarScanner for .NET
uses: na1307/dotnet-sonarscanner-cloud@v1
with:
sonar-token: ${{ secrets.SONAR_TOKEN }}
additional-properties: -d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
build-commands: |
dotnet restore
dotnet build --no-restore --no-incremental
dotnet coverage collect 'dotnet test --no-build --verbosity normal' -f xml -o 'coverage.xml'
50 changes: 48 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ jobs:
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
OUTPUT_PATH: output
NUGETPROJ: Directory.Build.props
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Cache NuGet
Expand All @@ -31,6 +34,26 @@ jobs:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('Directory.Packages.props') }} #hash of project files
restore-keys: ${{ runner.os }}-nuget-
- name: Bump revision
id: bump
if: github.event_name == 'push'
uses: vers-one/[email protected]
with:
file: ${{ env.NUGETPROJ }}
version: bump-revision
tags: props.Version, props.FileVersion
- name: Describe
id: describe
if: github.event_name == 'push'
shell: pwsh
run: echo "InfoVersion=$($(git describe --tags --long) -replace $(git describe --tags --abbrev=0),'${{ steps.bump.outputs.newVersion }}')" >> $env:GITHUB_OUTPUT
- name: Set Version
if: github.event_name == 'push'
uses: vers-one/[email protected]
with:
file: ${{ env.NUGETPROJ }}
version: ${{ steps.describe.outputs.InfoVersion }}
tags: props.Version
- name: Restore dependencies
run: dotnet restore
- name: Build (Debug)
Expand All @@ -47,9 +70,32 @@ jobs:
name: ${{ github.event.repository.name }}.nupkg
path: ${{ env.OUTPUT_PATH }}/*.*nupkg

publish:
publish-gpr:
name: Publish to GitHub Packages Registry
if: github.event_name == 'push'
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
source-url: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download Package artifact
uses: actions/download-artifact@v4
with:
name: ${{ github.event.repository.name }}.nupkg
- name: Publish to GitHub Package Registry
run: 'dotnet nuget push "*.nupkg" --skip-duplicate'

publish-nuget:
name: Publish to NuGet
if: ${{ github.event_name == 'release' }}
if: github.event_name == 'release'
needs: build
runs-on: ubuntu-latest
steps:
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ name: Deploy GitHub Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
branches:
- main
paths:
- '.github/workflows/**'
- 'Bluehill.Analyzers.Pages/**'
- 'Directory.Build.props'
- 'Directory.Packages.props'
- 'global.json'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down

0 comments on commit b9f9de7

Please sign in to comment.