Skip to content

Commit

Permalink
chore: Add support for GitHub Packages
Browse files Browse the repository at this point in the history
| GITHUB_REF    | version format                                   |
|---------------|--------------------------------------------------|
| refs/heads/*  | #.#.#-ci.{%Y%m%d}T{%H%M%S}+sha.${GITHUB_SHA:0:9} |
| refs/pull/*   | #.#.#-pr.{%Y%m%d}T{%H%M%S}+sha.${GITHUB_SHA:0:9} |
| refs/tags/v*  | #.#.#                                            |

See: open-feature/dotnet-sdk#54, open-feature/dotnet-sdk#173

Signed-off-by: Austin Drenski <[email protected]>
  • Loading branch information
austindrenski committed Jan 20, 2024
1 parent 20aeb3a commit 8abfe49
Show file tree
Hide file tree
Showing 15 changed files with 171 additions and 101 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
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
with:
dotnet-version: |
6.0.x
7.0.x
- 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
with:
dotnet-version: |
6.0.x
7.0.x
- 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/[email protected]
with:
name: nupkgs
path: src/**/*.nupkg
34 changes: 0 additions & 34 deletions .github/workflows/linux-ci.yml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/windows-ci.yml

This file was deleted.

39 changes: 36 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ Sample `.csproj` file:
<PropertyGroup>
<PackageId>OpenFeature.Contrib.MyComponent</PackageId>
<VersionNumber>0.0.1</VersionNumber> <!--x-release-please-version -->
<Version>$(VersionNumber)</Version>
<VersionPrefix>$(VersionNumber)</VersionPrefix>
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
<FileVersion>$(VersionNumber)</FileVersion>
<Description>A very valuable OpenFeature contribution!</Description>
<PackageProjectUrl>https://openfeature.dev</PackageProjectUrl>
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk-contrib</RepositoryUrl>
<Authors>Me!</Authors>
</PropertyGroup>

Expand All @@ -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 `<PrivateAssets>all</PrivateAssets>` 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.
```
13 changes: 4 additions & 9 deletions build/Common.prod.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
<Import Project=".\Common.props" />

<PropertyGroup>
<ContinuousIntegrationBuild Condition="'$(CI)' == 'true'">true</ContinuousIntegrationBuild>
<Deterministic Condition="'$(CI)' == 'true'">true</Deterministic>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackRelease>true</PackRelease>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net462;net5.0;net6.0;net7.0</TargetFrameworks>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk</RepositoryUrl>
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk-contrib</RepositoryUrl>
<Description>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.</Description>
<PackageTags>Feature;OpenFeature;Flags;</PackageTags>
<PackageIcon>openfeature-icon.png</PackageIcon>
Expand All @@ -28,12 +31,4 @@
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

<ItemGroup Condition="'$(Deterministic)'=='true'">
<SourceRoot Include="$(MSBuildThisFileDirectory)/" />
</ItemGroup>

<PropertyGroup Condition="'$(Deterministic)'=='true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
</Project>
6 changes: 5 additions & 1 deletion build/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@
<!-- 0.5+ -->
<OpenFeatureVer>[1.2,)</OpenFeatureVer>
</PropertyGroup>
</Project>

<ItemGroup Condition="'$(OS)' == 'Unix'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions build/Common.tests.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVer)" />
<PackageReference Include="GitHubActionsTestLogger" Version="$(GitHubActionsTestLoggerVer)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPkgVer)" />
<PackageReference Include="NSubstitute" Version="$(NSubstituteVer)" />
<PackageReference Include="xunit" Version="$(XUnitPkgVer)" />
Expand All @@ -45,6 +46,7 @@
<AutoFixtureVer>[4.17.0]</AutoFixtureVer>
<CoverletCollectorVer>[3.1.2]</CoverletCollectorVer>
<FluentAssertionsVer>[6.7.0]</FluentAssertionsVer>
<GitHubActionsTestLoggerVer>[2.3.3]</GitHubActionsTestLoggerVer>
<MicrosoftNETTestSdkPkgVer>[17.3.2]</MicrosoftNETTestSdkPkgVer>
<NSubstituteVer>[5.0.0]</NSubstituteVer>
<XUnitRunnerVisualStudioPkgVer>[2.4.3,3.0)</XUnitRunnerVisualStudioPkgVer>
Expand Down
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"rollForward": "latestFeature",
"version": "8.0.100"
}
}
22 changes: 22 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>

<configuration>

<packageSources>
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="github-open-feature" value="https://nuget.pkg.github.com/open-feature/index.json" />
</packageSources>

<packageSourceMapping>
<packageSource key="nuget">
<package pattern="OpenFeature" />
<package pattern="OpenFeature.*" />
<package pattern="*" />
</packageSource>
<packageSource key="github-open-feature">
<package pattern="OpenFeature" />
<package pattern="OpenFeature.*" />
</packageSource>
</packageSourceMapping>

</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
<PropertyGroup>
<PackageId>OpenFeature.Contrib.Hooks.Otel</PackageId>
<VersionNumber>0.1.3</VersionNumber> <!--x-release-please-version -->
<Version>$(VersionNumber)</Version>
<VersionPrefix>$(VersionNumber)</VersionPrefix>
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
<FileVersion>$(VersionNumber)</FileVersion>
<Description>Open Telemetry Hook for .NET</Description>
<PackageProjectUrl>https://openfeature.dev</PackageProjectUrl>
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk-contrib</RepositoryUrl>
<Authors>Florian Bacher</Authors>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
<PropertyGroup>
<PackageId>OpenFeature.Contrib.Providers.ConfigCat</PackageId>
<VersionNumber>0.0.1</VersionNumber> <!--x-release-please-version -->
<Version>$(VersionNumber)</Version>
<VersionPrefix>$(VersionNumber)</VersionPrefix>
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
<FileVersion>$(VersionNumber)</FileVersion>
<Description>ConfigCat provider for .NET</Description>
<PackageProjectUrl>https://openfeature.dev</PackageProjectUrl>
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk-contrib</RepositoryUrl>
<Authors>Luiz Bon</Authors>
</PropertyGroup>
<ItemGroup>
Expand All @@ -20,4 +18,4 @@
<ItemGroup>
<PackageReference Include="ConfigCat.Client" Version="[9,)"/>
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
<PropertyGroup>
<PackageId>OpenFeature.Contrib.Provider.FeatureManagement</PackageId>
<VersionNumber>0.0.1</VersionNumber>
<Version>$(VersionNumber)-preview</Version>
<VersionPrefix>$(VersionNumber)</VersionPrefix>
<VersionSuffix>preview</VersionSuffix>
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
<FileVersion>$(VersionNumber)</FileVersion>
<Description>An OpenFeature Provider built on top of the standard Microsoft FeatureManagement Library</Description>
<PackageProjectUrl>https://openfeature.dev</PackageProjectUrl>
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk-contrib</RepositoryUrl>
<Authors>Eric Pattison</Authors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.FeatureManagement" Version="4.0.0-preview" />
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
<PropertyGroup>
<PackageId>OpenFeature.Contrib.Providers.Flagd</PackageId>
<VersionNumber>0.1.7</VersionNumber> <!--x-release-please-version -->
<Version>$(VersionNumber)</Version>
<VersionPrefix>$(VersionNumber)</VersionPrefix>
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
<FileVersion>$(VersionNumber)</FileVersion>
<Description>flagd provider for .NET</Description>
<PackageProjectUrl>https://openfeature.dev</PackageProjectUrl>
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk-contrib</RepositoryUrl>
<Authors>Todd Baert</Authors>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
<TargetFrameworks>netstandard20</TargetFrameworks>
<PackageId>OpenFeature.Contrib.Providers.Flagsmith</PackageId>
<VersionNumber>0.1.5</VersionNumber> <!--x-release-please-version -->
<Version>$(VersionNumber)</Version>
<VersionPrefix>$(VersionNumber)</VersionPrefix>
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
<FileVersion>$(VersionNumber)</FileVersion>
<Description>Flagsmith provider for .NET</Description>
<PackageProjectUrl>https://openfeature.dev</PackageProjectUrl>
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk-contrib</RepositoryUrl>
<Authors>Vladimir Petrusevici</Authors>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
<PropertyGroup>
<PackageId>OpenFeature.Contrib.GOFeatureFlag</PackageId>
<VersionNumber>0.1.5</VersionNumber> <!--x-release-please-version -->
<Version>$(VersionNumber)</Version>
<VersionPrefix>$(VersionNumber)</VersionPrefix>
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
<FileVersion>$(VersionNumber)</FileVersion>
<Description>GO Feature Flag provider for .NET</Description>
<PackageProjectUrl>https://gofeatureflag.org</PackageProjectUrl>
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk-contrib</RepositoryUrl>
<Authors>Thomas Poignant</Authors>
</PropertyGroup>

Expand Down

0 comments on commit 8abfe49

Please sign in to comment.