From 40fa00598c6666deef8b975c5c5827ca305b0d75 Mon Sep 17 00:00:00 2001 From: Austin Drenski Date: Thu, 11 Jan 2024 16:01:15 -0500 Subject: [PATCH] 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: #54 Signed-off-by: Austin Drenski --- .github/workflows/ci.yml | 44 ++++++++++++++++++++++++++++++++++++++-- build/Common.prod.props | 3 +++ build/Common.props | 4 ++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df23b66b..09139182 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,11 +5,15 @@ on: branches: [ main ] paths-ignore: - '**.md' - pull_request: + pull_request_target: branches: [ main ] paths-ignore: - '**.md' +permissions: + contents: read + packages: write + jobs: unit-tests-linux: runs-on: ubuntu-latest @@ -27,7 +31,7 @@ jobs: - name: Run Tests run: dotnet test test/OpenFeature.Tests/ --configuration Release --logger GitHubActions - + unit-tests-windows: runs-on: windows-latest steps: @@ -44,3 +48,39 @@ jobs: - name: Run Tests run: dotnet test test\OpenFeature.Tests\ --configuration Release --logger GitHubActions + + 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 "${{ secrets.GITHUB_TOKEN }}" --source https://nuget.pkg.github.com/open-feature/index.json diff --git a/build/Common.prod.props b/build/Common.prod.props index 49e454c5..8fbce04c 100644 --- a/build/Common.prod.props +++ b/build/Common.prod.props @@ -2,7 +2,10 @@ + true + true true + true diff --git a/build/Common.props b/build/Common.props index 42a91d64..d7bcd946 100644 --- a/build/Common.props +++ b/build/Common.props @@ -27,4 +27,8 @@ + + + +