From 0def0da173e2f327b7381eba043b6e99ae8f26fe Mon Sep 17 00:00:00 2001 From: Austin Drenski Date: Mon, 22 Jan 2024 10:58:35 -0500 Subject: [PATCH] chore: Add support for GitHub Packages (#134) Signed-off-by: Austin Drenski --- .github/workflows/ci.yml | 93 +++++++++++++++++++ .github/workflows/linux-ci.yml | 34 ------- .github/workflows/release.yml | 10 ++ .github/workflows/windows-ci.yml | 34 ------- CONTRIBUTING.md | 39 +++++++- build/Common.prod.props | 15 +-- build/Common.props | 6 +- build/Common.tests.props | 2 + global.json | 6 ++ nuget.config | 22 +++++ .../OpenFeature.Contrib.Hooks.Otel.csproj | 4 +- ...Feature.Contrib.Providers.ConfigCat.csproj | 8 +- ...Contrib.Providers.FeatureManagement.csproj | 7 +- ...OpenFeature.Contrib.Providers.Flagd.csproj | 4 +- ...Feature.Contrib.Providers.Flagsmith.csproj | 4 +- ...ure.Contrib.Providers.GOFeatureFlag.csproj | 4 +- 16 files changed, 189 insertions(+), 103 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/linux-ci.yml delete mode 100644 .github/workflows/windows-ci.yml create mode 100644 global.json create mode 100644 nuget.config diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..1d2fd897 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,93 @@ +name: CI + +on: + push: + branches: [ main ] + paths-ignore: + - '**.md' + pull_request: + branches: [ main ] + paths-ignore: + - '**.md' + +jobs: + build: + strategy: + matrix: + os: [ ubuntu-latest, windows-latest ] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + + - name: Setup .NET SDK + uses: actions/setup-dotnet@v4 + env: + NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + dotnet-version: | + 6.0.x + 7.0.x + source-url: https://nuget.pkg.github.com/open-feature/index.json + + - name: Restore + run: dotnet restore + + - name: Build + run: dotnet build --no-restore + + - name: Test + run: dotnet test --no-build --logger GitHubActions + + packaging: + needs: build + + permissions: + contents: read + packages: write + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + + - name: Setup .NET SDK + uses: actions/setup-dotnet@v4 + env: + NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + dotnet-version: | + 6.0.x + 7.0.x + source-url: https://nuget.pkg.github.com/open-feature/index.json + + - name: Restore + run: dotnet restore + + - name: Pack NuGet packages (CI versions) + if: startsWith(github.ref, 'refs/heads/') + run: dotnet pack --no-restore --version-suffix "ci.$(date -u +%Y%m%dT%H%M%S)+sha.${GITHUB_SHA:0:9}" + + - name: Pack NuGet packages (PR versions) + if: startsWith(github.ref, 'refs/pull/') + run: dotnet pack --no-restore --version-suffix "pr.$(date -u +%Y%m%dT%H%M%S)+sha.${GITHUB_SHA:0:9}" + + - name: Publish NuGet packages (base) + if: github.event.pull_request.head.repo.fork == false + run: dotnet nuget push "src/**/*.nupkg" --api-key "${{ secrets.GITHUB_TOKEN }}" --source https://nuget.pkg.github.com/open-feature/index.json + + - name: Publish NuGet packages (fork) + if: github.event.pull_request.head.repo.fork == true + uses: actions/upload-artifact@v4.2.0 + with: + name: nupkgs + path: src/**/*.nupkg diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml deleted file mode 100644 index 7313bea5..00000000 --- a/.github/workflows/linux-ci.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Linux - -on: - push: - branches: [ main ] - paths-ignore: - - '**.md' - pull_request: - branches: [ main ] - paths-ignore: - - '**.md' - -jobs: - build-test: - runs-on: ubuntu-latest - - strategy: - matrix: - version: [net6.0,net7.0] - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - submodules: recursive - - - name: Install dependencies - run: dotnet restore - - - name: Build - run: dotnet build --configuration Release --no-restore - - - name: Test ${{ matrix.version }} - run: dotnet test --configuration Release --no-build --logger:"console;verbosity=detailed" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3c579fcb..74505035 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,6 +23,16 @@ jobs: fetch-depth: 0 submodules: recursive + - name: Setup .NET SDK + uses: actions/setup-dotnet@v4 + env: + NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + dotnet-version: | + 6.0.x + 7.0.x + source-url: https://nuget.pkg.github.com/open-feature/index.json + - name: Install dependencies if: ${{ steps.release.outputs.releases_created }} run: dotnet restore diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml deleted file mode 100644 index 3e29f545..00000000 --- a/.github/workflows/windows-ci.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Windows - -on: - push: - branches: [ main ] - paths-ignore: - - '**.md' - pull_request: - branches: [ main ] - paths-ignore: - - '**.md' - -jobs: - build-test: - runs-on: windows-latest - - strategy: - matrix: - version: [net462,net6.0,net7.0] - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - submodules: recursive - - - name: Install dependencies - run: dotnet restore - - - name: Build - run: dotnet build --configuration Release --no-restore - - - name: Test ${{ matrix.version }} - run: dotnet test --configuration Release --no-build --logger:"console;verbosity=detailed" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index abeb7e0b..02639db8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,12 +28,10 @@ Sample `.csproj` file: OpenFeature.Contrib.MyComponent 0.0.1 - $(VersionNumber) + $(VersionNumber) $(VersionNumber) $(VersionNumber) A very valuable OpenFeature contribution! - https://openfeature.dev - https://github.com/open-feature/dotnet-sdk-contrib Me! @@ -60,3 +58,38 @@ This repo uses _Release Please_ to release packages. Release Please sets up a ru Keep dependencies to a minimum. Dependencies used only for building and testing should have a `all` element to prevent them from being exposed to consumers. + +## Consuming pre-release packages + +1. Acquire a [GitHub personal access token (PAT)](https://docs.github.com/github/authenticating-to-github/creating-a-personal-access-token) scoped for `read:packages` and verify the permissions: + ```console + $ gh auth login --scopes read:packages + + ? What account do you want to log into? GitHub.com + ? What is your preferred protocol for Git operations? HTTPS + ? How would you like to authenticate GitHub CLI? Login with a web browser + + ! First copy your one-time code: ****-**** + Press Enter to open github.com in your browser... + + ✓ Authentication complete. + - gh config set -h github.com git_protocol https + ✓ Configured git protocol + ✓ Logged in as ******** + ``` + + ```console + $ gh auth status + + github.com + ✓ Logged in to github.com as ******** (~/.config/gh/hosts.yml) + ✓ Git operations for github.com configured to use https protocol. + ✓ Token: gho_************************************ + ✓ Token scopes: gist, read:org, read:packages, repo, workflow + ``` +2. Run the following command to configure your local environment to consume packages from GitHub Packages: + ```console + $ dotnet nuget update source github-open-feature --username $(gh api user --jq .email) --password $(gh auth token) --store-password-in-clear-text + + Package source "github-open-feature" was successfully updated. + ``` diff --git a/build/Common.prod.props b/build/Common.prod.props index 7badf346..abaa4ab8 100644 --- a/build/Common.prod.props +++ b/build/Common.prod.props @@ -2,14 +2,17 @@ + true + true true + true netstandard2.0;net462;net5.0;net6.0;net7.0 git - https://github.com/open-feature/dotnet-sdk - OpenFeature is an open standard for feature flag management, created to support a robust feature flag ecosystem using cloud native technologies. OpenFeature will provide a unified API and SDK, and a developer-first, cloud-native implementation, with extensibility for open source and commercial offerings. + https://github.com/open-feature/dotnet-sdk-contrib + OpenFeature is an open specification that provides a vendor-agnostic, community-driven API for feature flagging that works with your favorite feature flag management tool or in-house solution. Feature;OpenFeature;Flags; openfeature-icon.png https://openfeature.dev @@ -28,12 +31,4 @@ true snupkg - - - - - - - true - diff --git a/build/Common.props b/build/Common.props index fc34c474..928e20d7 100644 --- a/build/Common.props +++ b/build/Common.props @@ -27,4 +27,8 @@ [1.2,) - \ No newline at end of file + + + + + diff --git a/build/Common.tests.props b/build/Common.tests.props index 8a533a23..9f94a8e4 100644 --- a/build/Common.tests.props +++ b/build/Common.tests.props @@ -28,6 +28,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + @@ -45,6 +46,7 @@ [4.17.0] [3.1.2] [6.7.0] + [2.3.3] [17.3.2] [5.0.0] [2.4.3,3.0) diff --git a/global.json b/global.json new file mode 100644 index 00000000..0aca8b12 --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "rollForward": "latestFeature", + "version": "8.0.100" + } +} diff --git a/nuget.config b/nuget.config new file mode 100644 index 00000000..5a0edf43 --- /dev/null +++ b/nuget.config @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/OpenFeature.Contrib.Hooks.Otel/OpenFeature.Contrib.Hooks.Otel.csproj b/src/OpenFeature.Contrib.Hooks.Otel/OpenFeature.Contrib.Hooks.Otel.csproj index f413d1f7..cce45511 100644 --- a/src/OpenFeature.Contrib.Hooks.Otel/OpenFeature.Contrib.Hooks.Otel.csproj +++ b/src/OpenFeature.Contrib.Hooks.Otel/OpenFeature.Contrib.Hooks.Otel.csproj @@ -3,12 +3,10 @@ OpenFeature.Contrib.Hooks.Otel 0.1.3 - $(VersionNumber) + $(VersionNumber) $(VersionNumber) $(VersionNumber) Open Telemetry Hook for .NET - https://openfeature.dev - https://github.com/open-feature/dotnet-sdk-contrib Florian Bacher diff --git a/src/OpenFeature.Contrib.Providers.ConfigCat/OpenFeature.Contrib.Providers.ConfigCat.csproj b/src/OpenFeature.Contrib.Providers.ConfigCat/OpenFeature.Contrib.Providers.ConfigCat.csproj index 12171ff0..4ff809fc 100644 --- a/src/OpenFeature.Contrib.Providers.ConfigCat/OpenFeature.Contrib.Providers.ConfigCat.csproj +++ b/src/OpenFeature.Contrib.Providers.ConfigCat/OpenFeature.Contrib.Providers.ConfigCat.csproj @@ -1,14 +1,12 @@ - + OpenFeature.Contrib.Providers.ConfigCat 0.0.2 - $(VersionNumber) + $(VersionNumber) $(VersionNumber) $(VersionNumber) ConfigCat provider for .NET - https://openfeature.dev - https://github.com/open-feature/dotnet-sdk-contrib Luiz Bon @@ -20,4 +18,4 @@ - \ No newline at end of file + diff --git a/src/OpenFeature.Contrib.Providers.FeatureManagement/OpenFeature.Contrib.Providers.FeatureManagement.csproj b/src/OpenFeature.Contrib.Providers.FeatureManagement/OpenFeature.Contrib.Providers.FeatureManagement.csproj index 85ea512d..7cf292aa 100644 --- a/src/OpenFeature.Contrib.Providers.FeatureManagement/OpenFeature.Contrib.Providers.FeatureManagement.csproj +++ b/src/OpenFeature.Contrib.Providers.FeatureManagement/OpenFeature.Contrib.Providers.FeatureManagement.csproj @@ -3,12 +3,11 @@ OpenFeature.Contrib.Provider.FeatureManagement 0.0.1 - $(VersionNumber)-preview + $(VersionNumber) + preview $(VersionNumber) $(VersionNumber) An OpenFeature Provider built on top of the standard Microsoft FeatureManagement Library - https://openfeature.dev - https://github.com/open-feature/dotnet-sdk-contrib Eric Pattison @@ -16,4 +15,4 @@ - \ No newline at end of file + diff --git a/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj b/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj index f73392e1..cebe1bc8 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj +++ b/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj @@ -3,12 +3,10 @@ OpenFeature.Contrib.Providers.Flagd 0.1.7 - $(VersionNumber) + $(VersionNumber) $(VersionNumber) $(VersionNumber) flagd provider for .NET - https://openfeature.dev - https://github.com/open-feature/dotnet-sdk-contrib Todd Baert diff --git a/src/OpenFeature.Contrib.Providers.Flagsmith/OpenFeature.Contrib.Providers.Flagsmith.csproj b/src/OpenFeature.Contrib.Providers.Flagsmith/OpenFeature.Contrib.Providers.Flagsmith.csproj index 73aa89f6..7cb63914 100644 --- a/src/OpenFeature.Contrib.Providers.Flagsmith/OpenFeature.Contrib.Providers.Flagsmith.csproj +++ b/src/OpenFeature.Contrib.Providers.Flagsmith/OpenFeature.Contrib.Providers.Flagsmith.csproj @@ -4,12 +4,10 @@ netstandard20 OpenFeature.Contrib.Providers.Flagsmith 0.1.5 - $(VersionNumber) + $(VersionNumber) $(VersionNumber) $(VersionNumber) Flagsmith provider for .NET - https://openfeature.dev - https://github.com/open-feature/dotnet-sdk-contrib Vladimir Petrusevici diff --git a/src/OpenFeature.Contrib.Providers.GOFeatureFlag/OpenFeature.Contrib.Providers.GOFeatureFlag.csproj b/src/OpenFeature.Contrib.Providers.GOFeatureFlag/OpenFeature.Contrib.Providers.GOFeatureFlag.csproj index 14f89391..3af2cc01 100644 --- a/src/OpenFeature.Contrib.Providers.GOFeatureFlag/OpenFeature.Contrib.Providers.GOFeatureFlag.csproj +++ b/src/OpenFeature.Contrib.Providers.GOFeatureFlag/OpenFeature.Contrib.Providers.GOFeatureFlag.csproj @@ -3,12 +3,10 @@ OpenFeature.Contrib.GOFeatureFlag 0.1.5 - $(VersionNumber) + $(VersionNumber) $(VersionNumber) $(VersionNumber) GO Feature Flag provider for .NET - https://gofeatureflag.org - https://github.com/open-feature/dotnet-sdk-contrib Thomas Poignant