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#54

Signed-off-by: Austin Drenski <austin@austindrenski.io>
  • Loading branch information
austindrenski committed Jan 11, 2024
1 parent d0c25af commit 216f735
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
38 changes: 37 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Run Tests
run: dotnet test test/OpenFeature.Tests/ --configuration Release --logger:"console;verbosity=detailed"

unit-tests-windows:
runs-on: windows-latest
steps:
Expand All @@ -44,3 +44,39 @@ jobs:
- name: Run Tests
run: dotnet test test\OpenFeature.Tests\ --configuration Release --logger:"console;verbosity=detailed"

packaging:
needs:
- unit-tests-linux
- unit-tests-windows

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- 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: Pack NuGet packages (Release versions)
if: startsWith(github.ref, 'refs/tags/v')
run: dotnet pack --no-restore

- name: Publish NuGet packages
if: startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/pull/') || startsWith(github.ref, 'refs/tags/v')
run: dotnet nuget push "src/**/*.nupkg" --api-key "${GITHUB_TOKEN}" --source https://nuget.pkg.github.com/open-feature/index.json
3 changes: 3 additions & 0 deletions build/Common.prod.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
<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>
Expand Down
4 changes: 4 additions & 0 deletions build/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@
<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="[1.7.1, 8.0.0)" />
</ItemGroup>

<ItemGroup Condition="'$(OS)' == 'Unix'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
</ItemGroup>
</Project>
20 changes: 20 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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="*" />
</packageSource>
<packageSource key="github-open-feature">
<package pattern="OpenFeature" />
<package pattern="OpenFeature.*" />
</packageSource>
</packageSourceMapping>

</configuration>

0 comments on commit 216f735

Please sign in to comment.