From 5442b2bcb4ca1675c484b6f6389c56eabaa2ef43 Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Mon, 29 Jan 2024 11:57:32 +1100 Subject: [PATCH 1/6] Add GitHub CI workflow I'm experimenting with GitHub actions for various purposes such as CI builds and automated releases. This is a first attempt. --- .github/workflows/CI.yml | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/CI.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 000000000..d174dbefd --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,46 @@ +name: CI + +on: + + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + ununtu: + runs-on: ubuntu-latest + env: + DOTNET_NOLOGO: true + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.x + - name: Restore + run: dotnet restore MetadataExtractor.sln + - name: Build + run: dotnet build MetadataExtractor.sln --configuration Release + - name: Test net7.0 + run: dotnet test --verbosity normal --configuration Release --no-build -f net7.0 MetadataExtractor.Tests/MetadataExtractor.Tests.csproj + + windows: + runs-on: windows-latest + env: + DOTNET_NOLOGO: true + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.x + - name: Restore + run: dotnet restore MetadataExtractor.sln + - name: Build + run: dotnet build MetadataExtractor.sln --configuration Release + - name: Test net7.0 + run: dotnet test --verbosity normal --configuration Release --no-build -f net7.0 MetadataExtractor.Tests\MetadataExtractor.Tests.csproj + - name: Test net462 + run: dotnet test --verbosity normal --configuration Release --no-build -f net462 MetadataExtractor.Tests\MetadataExtractor.Tests.csproj From 6f264d2eb0f7ac017e8b3bc6852100274f84bb4f Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Mon, 29 Jan 2024 13:38:07 +1100 Subject: [PATCH 2/6] Use .NET 8 for builds and tests --- .github/workflows/CI.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d174dbefd..1588a5a61 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -18,13 +18,13 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Restore run: dotnet restore MetadataExtractor.sln - name: Build run: dotnet build MetadataExtractor.sln --configuration Release - - name: Test net7.0 - run: dotnet test --verbosity normal --configuration Release --no-build -f net7.0 MetadataExtractor.Tests/MetadataExtractor.Tests.csproj + - name: Test net8.0 + run: dotnet test --verbosity normal --configuration Release --no-build -f net8.0 MetadataExtractor.Tests/MetadataExtractor.Tests.csproj windows: runs-on: windows-latest @@ -35,12 +35,12 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Restore run: dotnet restore MetadataExtractor.sln - name: Build run: dotnet build MetadataExtractor.sln --configuration Release - - name: Test net7.0 - run: dotnet test --verbosity normal --configuration Release --no-build -f net7.0 MetadataExtractor.Tests\MetadataExtractor.Tests.csproj + - name: Test net8.0 + run: dotnet test --verbosity normal --configuration Release --no-build -f net8.0 MetadataExtractor.Tests\MetadataExtractor.Tests.csproj - name: Test net462 run: dotnet test --verbosity normal --configuration Release --no-build -f net462 MetadataExtractor.Tests\MetadataExtractor.Tests.csproj From 9a0d6e5d295a4426e8fc9b606a3605f6aa5981d4 Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Mon, 29 Jan 2024 13:44:35 +1100 Subject: [PATCH 3/6] Remove non-existant solution file --- MetadataExtractor.sln | 1 - 1 file changed, 1 deletion(-) diff --git a/MetadataExtractor.sln b/MetadataExtractor.sln index 3c3a29ebd..7b4fdb35c 100644 --- a/MetadataExtractor.sln +++ b/MetadataExtractor.sln @@ -9,7 +9,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .gitattributes = .gitattributes .gitignore = .gitignore .gitmodules = .gitmodules - appveyor.yml = appveyor.yml azure-pipelines.yml = azure-pipelines.yml Build.ps1 = Build.ps1 CONTRIBUTING.md = CONTRIBUTING.md From 9091a46b4627823d94395dbb1ca70ca17710bde1 Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Mon, 29 Jan 2024 13:44:52 +1100 Subject: [PATCH 4/6] Add CI workflow as solution item --- .github/workflows/prerelease.yml | 22 ++++++++++++++++++++++ .github/workflows/release.yml | 23 +++++++++++++++++++++++ MetadataExtractor.sln | 11 +++++++++++ 3 files changed, 56 insertions(+) create mode 100644 .github/workflows/prerelease.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml new file mode 100644 index 000000000..cff0b5372 --- /dev/null +++ b/.github/workflows/prerelease.yml @@ -0,0 +1,22 @@ +name: prerelease +on: + release: + types: [prereleased] + +jobs: + windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + shell: bash + - run: echo ${{ steps.get_version.outputs.VERSION }} + - run: dotnet pack MetadataExtractor/MetadataExtractor.csproj -o . -c Release /p:Version=${{ steps.get_version.outputs.VERSION }} /p:ContinuousIntegrationBuild=true + - run: dotnet nuget push *.nupkg -k $NUGET_API_KEY -s https://api.nuget.org/v3/index.json + env: + NUGET_API_KEY: ${{ secrets.NuGetAPIKey }} + shell: bash + + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..4fd30e1f0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,23 @@ +name: release +on: + release: + types: [published] + +jobs: + windows: + runs-on: windows-latest + if: "!github.event.release.prerelease" + steps: + - uses: actions/checkout@v3 + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + shell: bash + - run: echo ${{ steps.get_version.outputs.VERSION }} + - run: dotnet pack MetadataExtractor/MetadataExtractor.csproj -o . -c Release /p:Version=${{ steps.get_version.outputs.VERSION }} /p:ContinuousIntegrationBuild=true + - run: dotnet nuget push *.nupkg -k $NUGET_API_KEY -s https://api.nuget.org/v3/index.json + env: + NUGET_API_KEY: ${{ secrets.NuGetAPIKey }} + shell: bash + + diff --git a/MetadataExtractor.sln b/MetadataExtractor.sln index 7b4fdb35c..f3af1e06f 100644 --- a/MetadataExtractor.sln +++ b/MetadataExtractor.sln @@ -100,6 +100,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Wiki (Images)", "Wiki (Imag EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MetadataExtractor.Samples", "MetadataExtractor.Samples\MetadataExtractor.Samples.csproj", "{F8B15C79-7D2A-44F2-9E8A-1D5127FE6D91}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{2980D6CD-F063-461C-A8F6-AB90D505FA8C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{D75F7643-9F42-4A6B-A3FF-92443537CE9D}" + ProjectSection(SolutionItems) = preProject + .github\workflows\CI.yml = .github\workflows\CI.yml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -168,6 +175,10 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {2980D6CD-F063-461C-A8F6-AB90D505FA8C} = {8CF154EA-6A2C-4BF4-B263-78758F834192} + {D75F7643-9F42-4A6B-A3FF-92443537CE9D} = {2980D6CD-F063-461C-A8F6-AB90D505FA8C} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {15F8CDD5-5EFF-4277-8559-5AA83D1353C8} EndGlobalSection From 969a651fb195a4eebe71b8b695ffac7216523cb1 Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Mon, 29 Jan 2024 13:45:42 +1100 Subject: [PATCH 5/6] Remove Azure Pipelines config --- MetadataExtractor.sln | 1 - azure-pipelines.yml | 45 ------------------------------------------- 2 files changed, 46 deletions(-) delete mode 100644 azure-pipelines.yml diff --git a/MetadataExtractor.sln b/MetadataExtractor.sln index f3af1e06f..89e2544d1 100644 --- a/MetadataExtractor.sln +++ b/MetadataExtractor.sln @@ -9,7 +9,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .gitattributes = .gitattributes .gitignore = .gitignore .gitmodules = .gitmodules - azure-pipelines.yml = azure-pipelines.yml Build.ps1 = Build.ps1 CONTRIBUTING.md = CONTRIBUTING.md Directory.Build.props = Directory.Build.props diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 3bdedb82c..000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,45 +0,0 @@ -# .NET Desktop -# Build and run tests for .NET Desktop or Windows classic desktop solutions. -# Add steps that publish symbols, save build artifacts, and more: -# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net - -trigger: -- master - -pool: - vmImage: 'windows-latest' - -strategy: - maxParallel: 2 - matrix: - Debug: - buildConfiguration: Debug - Release: - buildConfiguration: Release - -variables: - solution: '**/*.sln' - buildPlatform: 'Any CPU' - -steps: -- task: NuGetToolInstaller@1 - -- task: NuGetCommand@2 - inputs: - restoreSolution: '$(solution)' - -- task: VSBuild@1 - inputs: - solution: '$(solution)' - platform: '$(buildPlatform)' - configuration: '$(buildConfiguration)' - -- task: VSTest@2 - inputs: - testSelector: 'testAssemblies' - testAssemblyVer2: | - **\MetadataExtractor.Tests.dll - !**\obj\** - platform: '$(buildPlatform)' - configuration: '$(buildConfiguration)' - runInParallel: true From a998e7361033f50b4a0d5a48236bd9b549461fc7 Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Mon, 29 Jan 2024 13:48:45 +1100 Subject: [PATCH 6/6] Build and test both Debug/Release on Ubuntu The Windows job does more work (testing .NET Framework too) so use the Ubuntu job to test both Debug/Release configurations. --- .github/workflows/CI.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1588a5a61..b03ad04a4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -21,10 +21,14 @@ jobs: dotnet-version: 8.0.x - name: Restore run: dotnet restore MetadataExtractor.sln - - name: Build + - name: Build (Release) run: dotnet build MetadataExtractor.sln --configuration Release - - name: Test net8.0 + - name: Build (Debug) + run: dotnet build MetadataExtractor.sln --configuration Debug + - name: Test net8.0 (Release) run: dotnet test --verbosity normal --configuration Release --no-build -f net8.0 MetadataExtractor.Tests/MetadataExtractor.Tests.csproj + - name: Test net8.0 (Debug) + run: dotnet test --verbosity normal --configuration Debug --no-build -f net8.0 MetadataExtractor.Tests/MetadataExtractor.Tests.csproj windows: runs-on: windows-latest @@ -38,7 +42,7 @@ jobs: dotnet-version: 8.0.x - name: Restore run: dotnet restore MetadataExtractor.sln - - name: Build + - name: Build run: dotnet build MetadataExtractor.sln --configuration Release - name: Test net8.0 run: dotnet test --verbosity normal --configuration Release --no-build -f net8.0 MetadataExtractor.Tests\MetadataExtractor.Tests.csproj