diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 5a70cd2..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,102 +0,0 @@ -version: 2.1 - -orbs: - win: circleci/windows@1.0.0 - -workflows: - version: 2 - test: - jobs: - - build_all - - test_linux: - name: .NET Core 3.1 - docker-image: mcr.microsoft.com/dotnet/core/sdk:3.1-focal - test-target-framework: netcoreapp3.1 - requires: - - build_all - - test_linux: - name: .NET Core 3.1 library running in .NET 6.0 - docker-image: mcr.microsoft.com/dotnet/sdk:6.0-focal - test-target-framework: net6.0 - requires: - - build_all - - test_windows - -jobs: - build_all: - docker: - - image: mcr.microsoft.com/dotnet/core/sdk:3.1-focal - environment: - ASPNETCORE_SUPPRESSSTATUSMESSAGES: true - steps: - - checkout - - run: - name: restore dependencies - command: dotnet restore src/LaunchDarkly.Logging - - run: - name: build .NET Standard 2.0 - command: dotnet build src/LaunchDarkly.Logging -f netstandard2.0 - - run: - name: build .NET Core 3.1 - command: dotnet build src/LaunchDarkly.Logging -f netcoreapp3.1 - - persist_to_workspace: - root: src/LaunchDarkly.Logging - paths: - - bin - - obj - - test_linux: - parameters: - docker-image: - type: string - test-target-framework: - type: string - docker: - - image: <> - environment: - ASPNETCORE_SUPPRESSSTATUSMESSAGES: true - TESTFRAMEWORK: <> - steps: - - checkout - - attach_workspace: - at: src/LaunchDarkly.Logging - - run: - name: run tests - command: | - dotnet test \ - -l "junit;LogFilePath=/tmp/circle-reports/unit-tests-commonsdk.xml" \ - -f <> \ - test/LaunchDarkly.Logging.Tests/LaunchDarkly.Logging.Tests.csproj - - store_test_results: - path: /tmp/circle-reports - - test_windows: - executor: - name: win/vs2019 - shell: powershell.exe - environment: - BUILDFRAMEWORKS: net462 - TESTFRAMEWORK: net462 - steps: - - checkout - - restore_cache: - keys: - - net462-deps-{{ checksum "src/LaunchDarkly.Logging/LaunchDarkly.Logging.csproj" }}-{{ checksum "test/LaunchDarkly.Logging.Tests/LaunchDarkly.Logging.Tests.csproj" }} - - run: - name: install project dependencies - command: dotnet restore - - save_cache: - key: net462-deps-{{ checksum "src/LaunchDarkly.Logging/LaunchDarkly.Logging.csproj" }}-{{ checksum "test/LaunchDarkly.Logging.Tests/LaunchDarkly.Logging.Tests.csproj" }} - paths: - - C:\Users\circleci\.nuget\packages - - run: - name: build - command: dotnet build src/LaunchDarkly.Logging -f net462 - - run: - name: run tests - command: | - dotnet test \ - -l "junit;LogFilePath=/tmp/circle-reports/unit-tests-commonsdk.xml" \ - test/LaunchDarkly.Logging.Tests/LaunchDarkly.Logging.Tests.csproj - - store_test_results: - path: /tmp/circle-reports diff --git a/.github/actions/build-docs/action.yml b/.github/actions/build-docs/action.yml new file mode 100644 index 0000000..f94fd61 --- /dev/null +++ b/.github/actions/build-docs/action.yml @@ -0,0 +1,21 @@ +name: Build Documentation +description: 'Build Documentation.' + +runs: + using: composite + steps: + - name: Setup dotnet build tools + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0 + - name: Install docfx + shell: bash + run: dotnet tool update -g docfx + + # Note: in the docfx.json file, the 'Configuration' property is set to Debug so that we don't require + # signing to happen just to build docs. + - name: Build docs + shell: bash + run: | + docfx metadata + docfx build diff --git a/.github/actions/ci/action.yml b/.github/actions/ci/action.yml new file mode 100644 index 0000000..76ea381 --- /dev/null +++ b/.github/actions/ci/action.yml @@ -0,0 +1,20 @@ +name: CI +description: Build and Test +inputs: + sdk: + description: 'The dotnet SDK to use.' + required: false + default: '9' + +runs: + using: composite + steps: + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ inputs.sdk }} + - run: dotnet restore src/LaunchDarkly.Logging + shell: bash + - run: dotnet build src/LaunchDarkly.Logging + shell: bash + - run: dotnet test test/LaunchDarkly.Logging.Tests + shell: bash diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml new file mode 100644 index 0000000..17a6a40 --- /dev/null +++ b/.github/actions/publish-docs/action.yml @@ -0,0 +1,24 @@ +name: Publish Documentation +description: 'Publish the documentation to Github pages' +inputs: + dry_run: + description: 'Is this a dry run. If so no package will be published.' + required: true + token: + description: 'Token to use for publishing.' + required: true + +runs: + using: composite + steps: + - uses: launchdarkly/gh-actions/actions/publish-pages@publish-pages-v1.0.2 + if: ${{ inputs.dry_run == 'false' }} + name: 'Publish to Github pages' + with: + docs_path: docs + github_token: ${{ inputs.token }} + - name: Dry Run Publish + if: ${{ inputs.dry_run == 'true' }} + shell: bash + run: | + echo "This is a dry run and docs are not being published." diff --git a/.github/actions/publish/action.yml b/.github/actions/publish/action.yml new file mode 100644 index 0000000..0780cf2 --- /dev/null +++ b/.github/actions/publish/action.yml @@ -0,0 +1,50 @@ +name: Publish Package +description: 'Packs DLLs into unsigned Nuget package and publishes to Nuget.' +inputs: + dry_run: + description: 'Is this a dry run. If so no package will be published.' + required: true +outputs: + hashes: + description: sha256sum hashes of built artifacts + value: ${{ steps.hash.outputs.hashes }} + +runs: + using: composite + steps: + - name: Setup dotnet build tools + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0 + + - name: Create Nuget Package + shell: bash + run: | + dotnet restore ./src/LaunchDarkly.Logging/LaunchDarkly.Logging.csproj + dotnet pack --no-build --output nupkgs --configuration Release ./src/LaunchDarkly.Logging/LaunchDarkly.Logging.csproj + + - name: Publish Package + if: ${{ inputs.dry_run == 'false' }} + shell: bash + run: | + for pkg in $(find ./nupkgs -name '*.nupkg' -o -name '*.snupkg'); do + echo "publishing ${pkg}" + dotnet nuget push "${pkg}" --api-key ${{ env.NUGET_API_KEY }} --source https://www.nuget.org + echo "published ${pkg}" + done + + - name: Hash nuget packages + id: hash + if: ${{ inputs.dry_run == 'false' }} + shell: bash + run: | + echo "hashes=$(sha256sum ./nupkgs/*.nupkg ./nupkgs/*.snupkg | base64 -w0)" >> "$GITHUB_OUTPUT" + + - name: Dry Run Publish + if: ${{ inputs.dry_run == 'true' }} + shell: bash + run: | + echo "This is a dry run and packages are not being published." + for pkg in $(find ./nupkgs -name '*.nupkg' -o -name '*.snupkg'); do + echo "detected package ${pkg}" + done diff --git a/.github/actions/release-build/action.yml b/.github/actions/release-build/action.yml new file mode 100644 index 0000000..2527d9d --- /dev/null +++ b/.github/actions/release-build/action.yml @@ -0,0 +1,18 @@ +name: Release Build +description: 'Build in Release Configuration' + +runs: + using: composite + steps: + - name: Setup dotnet build tools + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0 + + - name: Restore Packages + shell: bash + run: dotnet restore + + - name: Build + shell: bash + run: dotnet build /p:Configuration=Release ./src/LaunchDarkly.Logging/LaunchDarkly.Logging.csproj diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f26582a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: Build and Test + +on: + push: + branches: [main, 'feat/**'] + paths-ignore: + - '**.md' #Do not need to run CI for markdown changes. + pull_request: + branches: [main, 'feat/**'] + paths-ignore: + - '**.md' + workflow_call: + +jobs: + build-test-linux: + strategy: + matrix: + os: ['ubuntu-latest', 'windows-latest'] + dotnet: [{sdk: '8.x'}, {sdk: '9.x'}] + runs-on: ${{ matrix.os }} + name: Build ${{ matrix.os }} - ${{ matrix.dotnet.sdk }} + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/ci + with: + sdk: ${{ matrix.dotnet.sdk }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..9b164d9 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,86 @@ +name: Publish Package + +on: + workflow_dispatch: + inputs: + dry_run: + description: 'Is this a dry run. If so no package will be published.' + type: boolean + required: true + tag: + description: 'Tag for provenance. For a dry run the value does not matter.' + type: string + required: true + + workflow_call: + inputs: + dry_run: + description: 'Is this a dry run. If so no package will be published.' + type: boolean + required: true + tag: + description: 'Tag for provenance' + type: string + required: true + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + id-token: write # Needed if using OIDC to get release secrets. + contents: write # Contents and pull-requests are for release-please to make releases. + pull-requests: write + + steps: + - uses: actions/checkout@v4 + + - uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.2.0 + name: Get secrets + with: + aws_assume_role: ${{ vars.AWS_ROLE_ARN }} + ssm_parameter_pairs: '/production/common/releasing/digicert/host = DIGICERT_HOST, + /production/common/releasing/digicert/api_key = DIGICERT_API_KEY, + /production/common/releasing/digicert/client_cert_file_b64 = DIGICERT_CLIENT_CERT_FILE_B64, + /production/common/releasing/digicert/client_cert_password = DIGICERT_CLIENT_CERT_PASSWORD, + /production/common/releasing/digicert/code_signing_cert_sha1_hash = DIGICERT_CODE_SIGNING_CERT_SHA1_HASH, + /production/common/releasing/nuget/api_key = NUGET_API_KEY' + s3_path_pairs: 'launchdarkly-releaser/dotnet/LaunchDarkly.Logging.snk = LaunchDarkly.Logging.snk' + + + - name: Build Release + uses: ./.github/actions/release-build + + - name: Build Documentation + uses: ./.github/actions/build-docs + + - name: Sign DLLs + uses: launchdarkly/gh-actions/actions/sign-dlls@sign-dlls-v1.0.0 + with: + build_configuration_path: ./src/LaunchDarkly.Logging/bin/Release + dll_name: LaunchDarkly.Logging.dll + + - name: Publish Nupkg + id: publish + uses: ./.github/actions/publish + with: + dry_run: ${{ inputs.dry_run }} + + - name: Publish Documentation + uses: ./.github/actions/publish-docs + with: + token: ${{ secrets.GITHUB_TOKEN }} + dry_run: ${{ inputs.dry_run }} + + provenance: + permissions: + actions: read + id-token: write + contents: write + if: ${{ inputs.dry_run == 'false' }} + needs: ['publish'] + uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.10.0 + with: + base64-subjects: "${{ needs.publish.outputs.hashes }}" + upload-assets: true + upload-tag-name: ${{ inputs.tag }} + provenance-name: ${{ format('LaunchDarkly.Logging-{0}_provenance.intoto.jsonl', inputs.tag) }} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..522eb94 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,36 @@ +name: Release Please + +on: + push: + branches: + - main + +jobs: + release-please: + outputs: + releases_created: ${{ steps.release.outputs.releases_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + runs-on: ubuntu-latest + permissions: + id-token: write # Needed if using OIDC to get release secrets. + contents: write # Contents and pull-requests are for release-please to make releases. + pull-requests: write + + steps: + - uses: googleapis/release-please-action@v4 + id: release + with: + token: ${{secrets.GITHUB_TOKEN}} + default-branch: main + + ci: + needs: ['release-please'] + if: ${{ needs.release-please.outputs.releases_created == 'true' }} + uses: ./.github/workflows/ci.yml + publish: + needs: ['release-please', 'ci'] + if: ${{ needs.release-please.outputs.releases_created == 'true' }} + uses: ./.github/workflows/publish.yml + with: + dry_run: false + tag: ${{ needs.release-please.outputs.tag_name }} diff --git a/.gitignore b/.gitignore index d631b75..57d1314 100644 --- a/.gitignore +++ b/.gitignore @@ -54,9 +54,6 @@ DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html -# Click-Once directory -publish - # Others [Bb]in [Oo]bj @@ -80,3 +77,5 @@ project.lock.json *.snk *.p12 +api/ +docs/ diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..895bf0e --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "2.0.0" +} diff --git a/docfx.json b/docfx.json new file mode 100644 index 0000000..eb86e59 --- /dev/null +++ b/docfx.json @@ -0,0 +1,48 @@ +{ + "metadata": [ + { + "src": [ + { + "src": "./src", + "files": [ + "**/*.csproj", + "**/bin/**/**LaunchDarkly**.dll" + ] + } + ], + "dest": "./api", + "properties" : { + "Configuration": "Debug" + } + } + ], + "build": { + "content": [ + { + "files": [ + "**/*.{md,yml}" + ], + "exclude": [ + "docs/**" + ] + } + ], + "resource": [ + { + "files": [ + "images/**" + ] + } + ], + "output": "docs", + "template": [ + "default" + ], + "globalMetadata": { + "_appName": "LaunchDarkly Logging API for .NET", + "_appTitle": "LaunchDarkly Logging API for .NET", + "_enableSearch": true, + "pdf": false + } + } +} diff --git a/docs-src/index.md b/index.md similarity index 100% rename from docs-src/index.md rename to index.md diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..e89297f --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,10 @@ +{ + "packages": { + ".": { + "release-type": "simple", + "bootstrap-sha": "b4600d1c993afecd737dad1c85da34908c7d7e50", + "include-v-in-tag": false, + "include-component-in-tag": false + } + } +} diff --git a/test/LaunchDarkly.Logging.Tests/LaunchDarkly.Logging.Tests.csproj b/test/LaunchDarkly.Logging.Tests/LaunchDarkly.Logging.Tests.csproj index 5680c76..0c69cf2 100644 --- a/test/LaunchDarkly.Logging.Tests/LaunchDarkly.Logging.Tests.csproj +++ b/test/LaunchDarkly.Logging.Tests/LaunchDarkly.Logging.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1;net6.0 - $(TESTFRAMEWORK) + net8.0 + $(TargetFrameworks);net462 LaunchDarkly.Logging.Tests @@ -11,10 +11,6 @@ - - -