Skip to content

Commit f47006a

Browse files
committed
chore: Add support for GitHub Packages
| 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]>
1 parent 23d657f commit f47006a

File tree

16 files changed

+189
-103
lines changed

16 files changed

+189
-103
lines changed

.github/workflows/ci.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths-ignore:
7+
- '**.md'
8+
pull_request:
9+
branches: [ main ]
10+
paths-ignore:
11+
- '**.md'
12+
13+
jobs:
14+
build:
15+
strategy:
16+
matrix:
17+
os: [ ubuntu-latest, windows-latest ]
18+
19+
runs-on: ${{ matrix.os }}
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
submodules: recursive
27+
28+
- name: Setup .NET SDK
29+
uses: actions/setup-dotnet@v4
30+
env:
31+
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
with:
33+
dotnet-version: |
34+
6.0.x
35+
7.0.x
36+
source-url: https://nuget.pkg.github.com/open-feature/index.json
37+
38+
- name: Restore
39+
run: dotnet restore
40+
41+
- name: Build
42+
run: dotnet build --no-restore
43+
44+
- name: Test
45+
run: dotnet test --no-build --logger GitHubActions
46+
47+
packaging:
48+
needs: build
49+
50+
permissions:
51+
contents: read
52+
packages: write
53+
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v4
59+
with:
60+
fetch-depth: 0
61+
submodules: recursive
62+
63+
- name: Setup .NET SDK
64+
uses: actions/setup-dotnet@v4
65+
env:
66+
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
with:
68+
dotnet-version: |
69+
6.0.x
70+
7.0.x
71+
source-url: https://nuget.pkg.github.com/open-feature/index.json
72+
73+
- name: Restore
74+
run: dotnet restore
75+
76+
- name: Pack NuGet packages (CI versions)
77+
if: startsWith(github.ref, 'refs/heads/')
78+
run: dotnet pack --no-restore --version-suffix "ci.$(date -u +%Y%m%dT%H%M%S)+sha.${GITHUB_SHA:0:9}"
79+
80+
- name: Pack NuGet packages (PR versions)
81+
if: startsWith(github.ref, 'refs/pull/')
82+
run: dotnet pack --no-restore --version-suffix "pr.$(date -u +%Y%m%dT%H%M%S)+sha.${GITHUB_SHA:0:9}"
83+
84+
- name: Publish NuGet packages (base)
85+
if: github.event.pull_request.head.repo.fork == false
86+
run: dotnet nuget push "src/**/*.nupkg" --api-key "${{ secrets.GITHUB_TOKEN }}" --source https://nuget.pkg.github.com/open-feature/index.json
87+
88+
- name: Publish NuGet packages (fork)
89+
if: github.event.pull_request.head.repo.fork == true
90+
uses: actions/[email protected]
91+
with:
92+
name: nupkgs
93+
path: src/**/*.nupkg

.github/workflows/linux-ci.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ jobs:
2323
fetch-depth: 0
2424
submodules: recursive
2525

26+
- name: Setup .NET SDK
27+
uses: actions/setup-dotnet@v4
28+
env:
29+
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
with:
31+
dotnet-version: |
32+
6.0.x
33+
7.0.x
34+
source-url: https://nuget.pkg.github.com/open-feature/index.json
35+
2636
- name: Install dependencies
2737
if: ${{ steps.release.outputs.releases_created }}
2838
run: dotnet restore

.github/workflows/windows-ci.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@ Sample `.csproj` file:
2828
<PropertyGroup>
2929
<PackageId>OpenFeature.Contrib.MyComponent</PackageId>
3030
<VersionNumber>0.0.1</VersionNumber> <!--x-release-please-version -->
31-
<Version>$(VersionNumber)</Version>
31+
<VersionPrefix>$(VersionNumber)</VersionPrefix>
3232
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
3333
<FileVersion>$(VersionNumber)</FileVersion>
3434
<Description>A very valuable OpenFeature contribution!</Description>
35-
<PackageProjectUrl>https://openfeature.dev</PackageProjectUrl>
36-
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk-contrib</RepositoryUrl>
3735
<Authors>Me!</Authors>
3836
</PropertyGroup>
3937

@@ -60,3 +58,38 @@ This repo uses _Release Please_ to release packages. Release Please sets up a ru
6058

6159
Keep dependencies to a minimum.
6260
Dependencies used only for building and testing should have a `<PrivateAssets>all</PrivateAssets>` element to prevent them from being exposed to consumers.
61+
62+
## Consuming pre-release packages
63+
64+
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:
65+
```console
66+
$ gh auth login --scopes read:packages
67+
68+
? What account do you want to log into? GitHub.com
69+
? What is your preferred protocol for Git operations? HTTPS
70+
? How would you like to authenticate GitHub CLI? Login with a web browser
71+
72+
! First copy your one-time code: ****-****
73+
Press Enter to open github.com in your browser...
74+
75+
✓ Authentication complete.
76+
- gh config set -h github.com git_protocol https
77+
✓ Configured git protocol
78+
✓ Logged in as ********
79+
```
80+
81+
```console
82+
$ gh auth status
83+
84+
github.com
85+
✓ Logged in to github.com as ******** (~/.config/gh/hosts.yml)
86+
✓ Git operations for github.com configured to use https protocol.
87+
✓ Token: gho_************************************
88+
✓ Token scopes: gist, read:org, read:packages, repo, workflow
89+
```
90+
2. Run the following command to configure your local environment to consume packages from GitHub Packages:
91+
```console
92+
$ dotnet nuget update source github-open-feature --username $(gh api user --jq .email) --password $(gh auth token) --store-password-in-clear-text
93+
94+
Package source "github-open-feature" was successfully updated.
95+
```

build/Common.prod.props

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
<Import Project=".\Common.props" />
33

44
<PropertyGroup>
5+
<ContinuousIntegrationBuild Condition="'$(CI)' == 'true'">true</ContinuousIntegrationBuild>
6+
<Deterministic Condition="'$(CI)' == 'true'">true</Deterministic>
57
<GenerateDocumentationFile>true</GenerateDocumentationFile>
8+
<PackRelease>true</PackRelease>
69
</PropertyGroup>
710

811
<PropertyGroup>
912
<TargetFrameworks>netstandard2.0;net462;net5.0;net6.0;net7.0</TargetFrameworks>
1013
<RepositoryType>git</RepositoryType>
11-
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk</RepositoryUrl>
12-
<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>
14+
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk-contrib</RepositoryUrl>
15+
<Description>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.</Description>
1316
<PackageTags>Feature;OpenFeature;Flags;</PackageTags>
1417
<PackageIcon>openfeature-icon.png</PackageIcon>
1518
<PackageProjectUrl>https://openfeature.dev</PackageProjectUrl>
@@ -28,12 +31,4 @@
2831
<IncludeSymbols>true</IncludeSymbols>
2932
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
3033
</PropertyGroup>
31-
32-
<ItemGroup Condition="'$(Deterministic)'=='true'">
33-
<SourceRoot Include="$(MSBuildThisFileDirectory)/" />
34-
</ItemGroup>
35-
36-
<PropertyGroup Condition="'$(Deterministic)'=='true'">
37-
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
38-
</PropertyGroup>
3934
</Project>

build/Common.props

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@
2727
<!-- 0.5+ -->
2828
<OpenFeatureVer>[1.2,)</OpenFeatureVer>
2929
</PropertyGroup>
30-
</Project>
30+
31+
<ItemGroup Condition="'$(OS)' == 'Unix'">
32+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
33+
</ItemGroup>
34+
</Project>

build/Common.tests.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2929
</PackageReference>
3030
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVer)" />
31+
<PackageReference Include="GitHubActionsTestLogger" Version="$(GitHubActionsTestLoggerVer)" />
3132
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPkgVer)" />
3233
<PackageReference Include="NSubstitute" Version="$(NSubstituteVer)" />
3334
<PackageReference Include="xunit" Version="$(XUnitPkgVer)" />
@@ -45,6 +46,7 @@
4546
<AutoFixtureVer>[4.17.0]</AutoFixtureVer>
4647
<CoverletCollectorVer>[3.1.2]</CoverletCollectorVer>
4748
<FluentAssertionsVer>[6.7.0]</FluentAssertionsVer>
49+
<GitHubActionsTestLoggerVer>[2.3.3]</GitHubActionsTestLoggerVer>
4850
<MicrosoftNETTestSdkPkgVer>[17.3.2]</MicrosoftNETTestSdkPkgVer>
4951
<NSubstituteVer>[5.0.0]</NSubstituteVer>
5052
<XUnitRunnerVisualStudioPkgVer>[2.4.3,3.0)</XUnitRunnerVisualStudioPkgVer>

global.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"rollForward": "latestFeature",
4+
"version": "8.0.100"
5+
}
6+
}

nuget.config

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<configuration>
4+
5+
<packageSources>
6+
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
7+
<add key="github-open-feature" value="https://nuget.pkg.github.com/open-feature/index.json" />
8+
</packageSources>
9+
10+
<packageSourceMapping>
11+
<packageSource key="nuget">
12+
<package pattern="OpenFeature" />
13+
<package pattern="OpenFeature.*" />
14+
<package pattern="*" />
15+
</packageSource>
16+
<packageSource key="github-open-feature">
17+
<package pattern="OpenFeature" />
18+
<package pattern="OpenFeature.*" />
19+
</packageSource>
20+
</packageSourceMapping>
21+
22+
</configuration>

src/OpenFeature.Contrib.Hooks.Otel/OpenFeature.Contrib.Hooks.Otel.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
<PropertyGroup>
44
<PackageId>OpenFeature.Contrib.Hooks.Otel</PackageId>
55
<VersionNumber>0.1.3</VersionNumber> <!--x-release-please-version -->
6-
<Version>$(VersionNumber)</Version>
6+
<VersionPrefix>$(VersionNumber)</VersionPrefix>
77
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
88
<FileVersion>$(VersionNumber)</FileVersion>
99
<Description>Open Telemetry Hook for .NET</Description>
10-
<PackageProjectUrl>https://openfeature.dev</PackageProjectUrl>
11-
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk-contrib</RepositoryUrl>
1210
<Authors>Florian Bacher</Authors>
1311
</PropertyGroup>
1412

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<PackageId>OpenFeature.Contrib.Providers.ConfigCat</PackageId>
55
<VersionNumber>0.0.2</VersionNumber> <!--x-release-please-version -->
6-
<Version>$(VersionNumber)</Version>
6+
<VersionPrefix>$(VersionNumber)</VersionPrefix>
77
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
88
<FileVersion>$(VersionNumber)</FileVersion>
99
<Description>ConfigCat provider for .NET</Description>
10-
<PackageProjectUrl>https://openfeature.dev</PackageProjectUrl>
11-
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk-contrib</RepositoryUrl>
1210
<Authors>Luiz Bon</Authors>
1311
</PropertyGroup>
1412
<ItemGroup>
@@ -20,4 +18,4 @@
2018
<ItemGroup>
2119
<PackageReference Include="ConfigCat.Client" Version="[9,)"/>
2220
</ItemGroup>
23-
</Project>
21+
</Project>

src/OpenFeature.Contrib.Providers.FeatureManagement/OpenFeature.Contrib.Providers.FeatureManagement.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
<PropertyGroup>
44
<PackageId>OpenFeature.Contrib.Provider.FeatureManagement</PackageId>
55
<VersionNumber>0.0.1</VersionNumber>
6-
<Version>$(VersionNumber)-preview</Version>
6+
<VersionPrefix>$(VersionNumber)</VersionPrefix>
7+
<VersionSuffix>preview</VersionSuffix>
78
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
89
<FileVersion>$(VersionNumber)</FileVersion>
910
<Description>An OpenFeature Provider built on top of the standard Microsoft FeatureManagement Library</Description>
10-
<PackageProjectUrl>https://openfeature.dev</PackageProjectUrl>
11-
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk-contrib</RepositoryUrl>
1211
<Authors>Eric Pattison</Authors>
1312
</PropertyGroup>
1413

1514
<ItemGroup>
1615
<PackageReference Include="Microsoft.FeatureManagement" Version="4.0.0-preview" />
1716
</ItemGroup>
1817

19-
</Project>
18+
</Project>

src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
<PropertyGroup>
44
<PackageId>OpenFeature.Contrib.Providers.Flagd</PackageId>
55
<VersionNumber>0.1.7</VersionNumber> <!--x-release-please-version -->
6-
<Version>$(VersionNumber)</Version>
6+
<VersionPrefix>$(VersionNumber)</VersionPrefix>
77
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
88
<FileVersion>$(VersionNumber)</FileVersion>
99
<Description>flagd provider for .NET</Description>
10-
<PackageProjectUrl>https://openfeature.dev</PackageProjectUrl>
11-
<RepositoryUrl>https://github.com/open-feature/dotnet-sdk-contrib</RepositoryUrl>
1210
<Authors>Todd Baert</Authors>
1311
</PropertyGroup>
1412

0 commit comments

Comments
 (0)