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 <austin@austindrenski.io>
  • Loading branch information
austindrenski committed Jan 19, 2024
1 parent 20aeb3a commit 0d3c60e
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 69 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
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: 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 "${{ secrets.GITHUB_TOKEN }}" --source https://nuget.pkg.github.com/open-feature/index.json
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.

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

0 comments on commit 0d3c60e

Please sign in to comment.