Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add support for GitHub Packages #173

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,46 @@ jobs:

- name: Run Tests
run: dotnet test test\OpenFeature.Tests\ --configuration Release --logger GitHubActions

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

permissions:
contents: read
packages: write

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/')
austindrenski marked this conversation as resolved.
Show resolved Hide resolved
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
12 changes: 4 additions & 8 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 All @@ -16,7 +19,7 @@
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<Authors>OpenFeature Authors</Authors>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Version>$(VersionNumber)</Version>
toddbaert marked this conversation as resolved.
Show resolved Hide resolved
<VersionPrefix>$(VersionNumber)</VersionPrefix>
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
<FileVersion>$(VersionNumber)</FileVersion>
</PropertyGroup>
Expand All @@ -32,11 +35,4 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

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

<PropertyGroup Condition="'$(Deterministic)'=='true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
toddbaert marked this conversation as resolved.
Show resolved Hide resolved
</Project>
4 changes: 4 additions & 0 deletions build/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@
<PackageReference Include="System.Collections.Immutable" Version="[1.7.1,)" />
<PackageReference Include="System.Threading.Channels" Version="[6.0.0,)" />
</ItemGroup>

<ItemGroup Condition="'$(OS)' == 'Unix'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
</ItemGroup>
Comment on lines +32 to +34
Copy link
Member

@toddbaert toddbaert Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this because we're not building on Windows in the job? Will this have any impact on the release build (it does run on windows)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this because we're not building on Windows in the job?

Yep! It gives dotnet build enough context to build the net462 TFM on Linux, so we can run package builds on ubuntu-latest which, among other reasons, runs circles around windows-latest for dotnet restore and anything else that uses compression:

  • windows-latest:
    Run dotnet test test\OpenFeature.Tests\ --configuration Release --logger GitHubActions
      Determining projects to restore...
      Restored D:\a\dotnet-sdk\dotnet-sdk\src\OpenFeature\OpenFeature.csproj (in 21.2 sec).
      Restored D:\a\dotnet-sdk\dotnet-sdk\test\OpenFeature.Tests\OpenFeature.Tests.csproj (in 1.69 min).
    
  • ubuntu-latest:
    Run dotnet test test/OpenFeature.Tests/ --configuration Release --logger GitHubActions
      Determining projects to restore...
      Restored /home/runner/work/dotnet-sdk/dotnet-sdk/src/OpenFeature/OpenFeature.csproj (in 5.33 sec).
      Restored /home/runner/work/dotnet-sdk/dotnet-sdk/test/OpenFeature.Tests/OpenFeature.Tests.csproj (in 5.5 sec).
    

Will this have any impact on the release build (it does run on windows)?

It should have no impact since it's conditioned on the OS var and the reference assemblies won't be included in the compilation, leaving dotnet to find the actual assemblies in the GAC (or on disk, can't remember which it actually checks, so don't quote me on this part).

But it does mean, that once everyone is comfortable with it (i.e. this workflow runs without issues a few times), we could then update release.yml to run on ubuntu-latest too.

That workflow obviously runs less frequently than ci.yml, so the dotnet restore perf won't be as big of a consideration in that case, but I personally feel better building my internal stable releases on the ubuntu-latest runners. Things just always seem to work better there lol (e.g. cli perf, line endings, etc).

edit: opened #195 for later

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I'm in favor of that change in the future. Thanks for the explanation 🙏

</Project>