Adding Azure DevOps nuget and docker run templates #2377
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: Build & Test | |
on: | |
push: | |
pull_request: | |
jobs: | |
build: | |
runs-on: windows-latest | |
defaults: | |
run: | |
working-directory: . | |
outputs: | |
semver: ${{ steps.gitversion.outputs.semver }} | |
LicenseClearingTool: ${{ steps.packageBuildResults.outputs.LicenseClearingTool }} | |
nupkg-LicenseClearingTool: ${{ steps.createNupkg.outputs.nupkg-LicenseClearingTool }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Version | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: '5.12.0' | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: TRUE | |
- name: Determine Version | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
useConfigFile: true | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: TRUE | |
- name: get SemVer | |
#if: ${{ false }} # disable for now | |
id: gitversion | |
run: | | |
echo "SemVer: v$($env:GitVersion_SemVer)" | |
Write-Host "::set-output name=semver::$($env:GitVersion_MajorMinorPatch)" | |
$fileName = "dummy-v$($env:GitVersion_SemVer)" | |
echo "SemVerMMP: v$($env:GitVersion_MajorMinorPatch)" | |
Write-Host "Filename: '$fileName'" | |
- name: Add msbuild to PATH | |
uses: microsoft/[email protected] | |
- name: update appsettingsUnitTest.json | |
run: ./Scripts/json_update_ut.ps1 -JsonFile 'src\UnitTestUtilities\appsettingsUnitTest.json' | |
env: | |
SW360HOST: ${{ secrets.SW360HOST }} | |
SW360APPPORT: ${{ secrets.SW360APPPORT }} | |
FOSSYHOST: ${{ secrets.FOSSYHOST }} | |
FOSSYAPPPORT: ${{ secrets.FOSSYAPPPORT }} | |
JFROGURL: ${{ secrets.JFROGURL }} | |
- name: Restore Packages | |
run: dotnet restore src\LicenseClearingTool.sln | |
- name: Build | |
run: | | |
dotnet build src\LicenseClearingTool.sln | |
Write-Host "Files in directory:" | |
dir $env:GITHUB_WORKSPACE\out\net8.0 | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: buildoutput | |
path: ${{ github.workspace }}/out/net8.0 | |
- name: Archive Build Log | |
uses: actions/upload-artifact@v4 | |
if: ${{ success() || failure() }} | |
with: | |
name: Compile_Solution_log | |
path: | | |
$env:GITHUB_WORKSPACE/src/*.binlog | |
$env:GITHUB_WORKSPACE/*.binlog | |
- name: Archive Build Output | |
uses: actions/upload-artifact@v4 | |
with: | |
name: continuous-clearing | |
path: | | |
out/continuous-clearing | |
- name: Create zip | |
id: packageBuildResults | |
run: | | |
$sourceFolder = Join-Path $env:GITHUB_WORKSPACE "out" | Join-Path -ChildPath "*" | |
$outFolder = Join-Path $env:GITHUB_WORKSPACE "out" | Join-Path -ChildPath "continuous-clearing" | |
New-Item -ItemType Directory -Force -Path $outFolder | |
$fileName = "continuous-clearing-v7.0.1.zip" | |
Write-Host "Filename: '$fileName'" | |
Write-Host "sourceFolder: '$sourceFolder'" | |
Write-Host "Outfolder: '$outFolder'" | |
Write-Host "::set-output name=LicenseClearingTool::$($fileName)" | |
$outPath = Join-Path $outFolder $fileName | |
Compress-Archive -DestinationPath $outPath -Path $sourceFolder -CompressionLevel Optimal | |
- name: Test | |
#if: ${{ false }} # disable for now | |
run: | | |
$TestProjects = Get-ChildItem -Path *test*.csproj -Recurse -exclude TestUtilities.csproj,UnitTestUtilities.csproj,SW360IntegrationTest.csproj | |
Write-Host "**************************The test projects considered for execution: $TestProjects ******************************" | |
Write-Host "********************************************************************************************************************" | |
foreach ($Project in $TestProjects) | |
{ | |
Write-Host $Project.DirectoryName | |
$TestProject = $Project.DirectoryName | |
Push-Location $Project.PSParentPath | |
dotnet test --no-build --configuration Release | |
} | |
- name: Archive Build Output | |
uses: actions/upload-artifact@v4 | |
with: | |
name: continuous-clearing | |
path: | | |
out/continuous-clearing | |
- name: Create Nuget Packages | |
id: createNupkg | |
run: | | |
nuget pack CA.nuspec -Version 7.0.1 | |
Write-Host "::set-output name=nupkg-LicenseClearingTool::continuous-clearing.7.0.1.nupkg" | |
- name: Archive NuGet Packages | |
uses: actions/upload-artifact@v4 | |
with: | |
name: nuget-continuous-clearing | |
path: | | |
*.nupkg | |
build-docker: | |
runs-on: ubuntu-latest | |
needs: build | |
outputs: | |
docker-LicenseClearingTool: ${{ steps.builddocker.outputs.docker-LicenseClearingTool }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Download Build Output | |
uses: actions/download-artifact@v4 | |
with: | |
name: buildoutput | |
path: ${{ github.workspace }}/out/net8.0 | |
- name: Build the Docker image | |
id: builddocker | |
#if: ${{ false }} # disable for now | |
run: | | |
echo "Files in directory:" | |
docker build . --file Dockerfile --tag ${{ github.repository }}:continuous-clearing-v7.0.1 | |
docker save ${{ github.repository }}:continuous-clearing-v7.0.1 -o continuous-clearing-v7.0.1.tar | |
echo "::set-output name=docker-LicenseClearingTool::continuous-clearing-v7.0.1.tar" | |
- name: Archive docker image | |
#if: ${{ false }} # disable for now | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docker-continuous-clearing | |
path: | | |
*.tar | |
release: | |
if: github.ref == 'refs/heads/main' | |
runs-on: windows-latest | |
needs: [build, build-docker] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Download Build Output | |
uses: actions/download-artifact@v4 | |
with: | |
name: continuous-clearing | |
- name: Download NuGet Package | |
uses: actions/download-artifact@v4 | |
with: | |
name: nuget-continuous-clearing | |
- name: Download Docker image | |
uses: actions/download-artifact@v4 | |
with: | |
name: docker-continuous-clearing | |
- name: Debug | |
run: | | |
tree | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v7.0.1 | |
release_name: Release v7.0.1 | |
body: | | |
${{ github.event.head_commit.message }} | |
draft: true | |
prerelease: false | |
- name: Upload Zip | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./${{ needs.build.outputs.LicenseClearingTool }} | |
asset_name: ${{ needs.build.outputs.LicenseClearingTool }} | |
asset_content_type: application/zip | |
- name: Upload Nupkg | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./${{ needs.build.outputs.nupkg-LicenseClearingTool }} | |
asset_name: ${{ needs.build.outputs.nupkg-LicenseClearingTool }} | |
asset_content_type: application/zip | |
- name: Upload Docker | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./${{ needs.build-docker.outputs.docker-LicenseClearingTool }} | |
asset_name: ${{ needs.build-docker.outputs.docker-LicenseClearingTool }} | |
asset_content_type: application/zip | |
- name: Upload ReadmeOSS_nupkg file | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ github.workspace }}\ReadmeOSS_continuous-clearing_nupkg.html | |
asset_name: ReadmeOSS_continuous-clearing_nupkg.html | |
asset_content_type: text/html | |
- name: Upload ReadmeOSS_Docker file | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ github.workspace }}\ReadmeOSS_continuous-clearing_DockerImage.html | |
asset_name: ReadmeOSS_continuous-clearing_DockerImage.html | |
asset_content_type: text/html |