Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
211 changes: 108 additions & 103 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
on:
workflow_call:
inputs:
Expand All @@ -14,110 +15,114 @@ on:

jobs:
build:
permissions:
contents: read
pull-requests: write

runs-on: ${{ inputs.os }}

steps:

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup dotnet 6/8
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.x
8.x

- name: Restore Tools
run: >
dotnet tool restore
- name: Restore Dependencies
run: >
dotnet restore
- name: Start Sonar Scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
dotnet dotnet-sonarscanner
begin
/k:"demaconsulting_SpdxModel"
/o:"demaconsulting"
/d:sonar.token="${{ secrets.SONAR_TOKEN }}"
/d:sonar.host.url="https://sonarcloud.io"
/d:sonar.cs.opencover.reportsPaths=**/*.opencover.xml
/d:sonar.scanner.scanAll=false

- name: Build
run: >
dotnet build
--no-restore
--configuration Release
--property:Version=${{ inputs.version }}

- name: Test
run: >
dotnet test
--no-build
--configuration Release
--property:Version=${{ inputs.version }}
--collect "XPlat Code Coverage;Format=opencover"

- name: End Sonar Scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
dotnet dotnet-sonarscanner
end
/d:sonar.token="${{ secrets.SONAR_TOKEN }}"

- name: Generate SBOM
run: >
dotnet sbom-tool generate
-b src/DemaConsulting.SpdxModel/bin/Release
-bc src/DemaConsulting.SpdxModel
-pn DemaConsulting.SpdxModel
-pv ${{ inputs.version }}
-ps DemaConsulting
-nsb https://DemaConsulting.com/SpdxModel
-pm true
-li true

- name: Generate Tests SBOM
run: >
dotnet sbom-tool generate
-b test/DemaConsulting.SpdxModel.Tests/bin/Release
-bc test/DemaConsulting.SpdxModel.Tests
-cd "--DirectoryExclusionList **/Examples/**"
-pn DemaConsulting.SpdxModel.Tests
-pv ${{ inputs.version }}
-ps DemaConsulting
-nsb https://DemaConsulting.com/SpdxModel.Tests
-pm true
-li true

- name: Run SBOM Workflow
run: >
dotnet spdx-tool
run-workflow spdx-workflow.yaml

- name: Create Dotnet Tool
run: >
dotnet pack
--no-build
--no-restore
--property:PackageVersion=${{ inputs.version }}

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ inputs.os }}
path: |
**/*.nupkg
**/*.snupkg
**/manifest.spdx.json
**/manifest.spdx.json.sha256
*summary.md
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup dotnet 6/8
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.x
8.x

- name: Restore Tools
run: >
dotnet tool restore

- name: Restore Dependencies
run: >
dotnet restore

- name: Start Sonar Scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
dotnet dotnet-sonarscanner
begin
/k:"demaconsulting_SpdxModel"
/o:"demaconsulting"
/d:sonar.token="${{ secrets.SONAR_TOKEN }}"
/d:sonar.host.url="https://sonarcloud.io"
/d:sonar.cs.opencover.reportsPaths=**/*.opencover.xml
/d:sonar.scanner.scanAll=false

- name: Build
run: >
dotnet build
--no-restore
--configuration Release
--property:Version=${{ inputs.version }}

- name: Test
run: >
dotnet test
--no-build
--configuration Release
--property:Version=${{ inputs.version }}
--collect "XPlat Code Coverage;Format=opencover"

- name: End Sonar Scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
dotnet dotnet-sonarscanner
end
/d:sonar.token="${{ secrets.SONAR_TOKEN }}"

- name: Generate SBOM
run: >
dotnet sbom-tool generate
-b src/DemaConsulting.SpdxModel/bin/Release
-bc src/DemaConsulting.SpdxModel
-pn DemaConsulting.SpdxModel
-pv ${{ inputs.version }}
-ps DemaConsulting
-nsb https://DemaConsulting.com/SpdxModel
-pm true
-li true

- name: Generate Tests SBOM
run: >
dotnet sbom-tool generate
-b test/DemaConsulting.SpdxModel.Tests/bin/Release
-bc test/DemaConsulting.SpdxModel.Tests
-cd "--DirectoryExclusionList **/Examples/**"
-pn DemaConsulting.SpdxModel.Tests
-pv ${{ inputs.version }}
-ps DemaConsulting
-nsb https://DemaConsulting.com/SpdxModel.Tests
-pm true
-li true

- name: Run SBOM Workflow
run: >
dotnet spdx-tool
run-workflow spdx-workflow.yaml

- name: Create Dotnet Tool
run: >
dotnet pack
--no-build
--no-restore
--property:PackageVersion=${{ inputs.version }}

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ inputs.os }}
path: |
**/*.nupkg
**/*.snupkg
**/manifest.spdx.json
**/manifest.spdx.json.sha256
*summary.md
7 changes: 7 additions & 0 deletions .github/workflows/build_on_push.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
---
name: Build

on: [push, workflow_dispatch]

jobs:
build-windows:
name: Build Windows
permissions:
contents: read
pull-requests: write
uses: ./.github/workflows/build.yaml
with:
os: windows-latest
Expand All @@ -14,6 +18,9 @@ jobs:

build-linux:
name: Build Linux
permissions:
contents: read
pull-requests: write
uses: ./.github/workflows/build.yaml
with:
os: ubuntu-latest
Expand Down
74 changes: 39 additions & 35 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Release

on:
Expand All @@ -13,13 +14,16 @@ on:
default: 'publish'
type: choice
options:
- none
- release
- publish
- none
- release
- publish

jobs:
build:
name: Build Linux
permissions:
contents: read
pull-requests: write
uses: ./.github/workflows/build.yaml
with:
os: ubuntu-latest
Expand All @@ -33,41 +37,41 @@ jobs:
packages: write

runs-on: ubuntu-latest

needs: build

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Setup dotnet 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.x

- name: Setup dotnet 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.x
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: artifacts-ubuntu-latest
path: artifacts

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: artifacts-ubuntu-latest
path: artifacts
- name: Clean Artifacts
shell: bash
run: rm -rf artifacts/test

- name: Clean Artifacts
shell: bash
run: rm -rf artifacts/test

- name: Create release
if: ${{ inputs.publish == 'release' || inputs.publish == 'publish' }}
uses: ncipollo/release-action@v1
with:
artifacts: 'artifacts/**/*'
generateReleaseNotes: true
tag: ${{ inputs.version }}
- name: Create release
if: ${{ inputs.publish == 'release' || inputs.publish == 'publish' }}
uses: ncipollo/release-action@v1
with:
artifacts: 'artifacts/**/*'
generateReleaseNotes: true
tag: ${{ inputs.version }}

- name: Publish to Nuget
if: ${{ inputs.publish == 'publish' }}
run: >
dotnet
nuget push
artifacts/src/DemaConsulting.SpdxModel/bin/Release/*.nupkg
--source "https://api.nuget.org/v3/index.json"
--api-key "${{ secrets.DEMACONSULTINGNUGETKEY }}"
- name: Publish to Nuget
if: ${{ inputs.publish == 'publish' }}
run: >
dotnet
nuget push
artifacts/src/DemaConsulting.SpdxModel/bin/Release/*.nupkg
--source "https://api.nuget.org/v3/index.json"
--api-key "${{ secrets.DEMACONSULTINGNUGETKEY }}"
4 changes: 2 additions & 2 deletions src/DemaConsulting.SpdxModel/SpdxChecksumAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public static SpdxChecksumAlgorithm FromText(string checksumAlgorithm)
"BLAKE2b-512" => SpdxChecksumAlgorithm.Blake2B512,
"BLAKE3" => SpdxChecksumAlgorithm.Blake3,
"ADLER32" => SpdxChecksumAlgorithm.Adler32,
_ => throw new InvalidOperationException($"Unsupported SPDX Checksum Algorithm {checksumAlgorithm}")
_ => throw new InvalidOperationException($"Unsupported SPDX Checksum Algorithm '{checksumAlgorithm}'")
};
}

Expand Down Expand Up @@ -182,7 +182,7 @@ public static string ToText(this SpdxChecksumAlgorithm checksumAlgorithm)
SpdxChecksumAlgorithm.Blake2B512 => "BLAKE2b-512",
SpdxChecksumAlgorithm.Blake3 => "BLAKE3",
SpdxChecksumAlgorithm.Adler32 => "ADLER32",
_ => throw new InvalidOperationException($"Unsupported SPDX Checksum Algorithm {checksumAlgorithm}")
_ => throw new InvalidOperationException($"Unsupported SPDX Checksum Algorithm '{checksumAlgorithm}'")
};
}
}
4 changes: 2 additions & 2 deletions src/DemaConsulting.SpdxModel/SpdxFileType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static SpdxFileType FromText(string fileType)
"DOCUMENTATION" => SpdxFileType.Documentation,
"SPDX" => SpdxFileType.Spdx,
"OTHER" => SpdxFileType.Other,
_ => throw new InvalidOperationException($"Unsupported SPDX File Type {fileType}")
_ => throw new InvalidOperationException($"Unsupported SPDX File Type '{fileType}'")
};
}

Expand All @@ -132,7 +132,7 @@ public static string ToText(this SpdxFileType fileType)
SpdxFileType.Documentation => "DOCUMENTATION",
SpdxFileType.Spdx => "SPDX",
SpdxFileType.Other => "OTHER",
_ => throw new InvalidOperationException($"Unsupported SPDX File Type {fileType}")
_ => throw new InvalidOperationException($"Unsupported SPDX File Type '{fileType}'")
};
}
}
Loading
Loading