From 0413cc1c6605648e7fad79cf9359c5fc356dc034 Mon Sep 17 00:00:00 2001 From: webwarrior-ws Date: Tue, 2 Apr 2024 20:03:08 +0200 Subject: [PATCH] Create Nethereum metapackage (#4) * GitHubCI: add metapackage push Following: https://danielwertheim.se/how-to-create-a-nuget-metapackage/ Co-authored-by: Mehrshad * GithubCI: use nugetPreRelease.fsx to get version * GithubCI: publish package on nuget * GithubCI: add conditions for "Push" step Check for presence of secrets.NUGET_API_KEY is made in script itself, because Github actions don't have access to secrets context in if statements (see [1]). [1] https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability --- .github/workflows/dotnet.yml | 54 ++++++++++++++++++++++++++++++++++++ nugetPreRelease.fsx | 6 ++++ 2 files changed, 60 insertions(+) create mode 100644 nugetPreRelease.fsx diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index bbfb70062..b803ca828 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -22,3 +22,57 @@ jobs: run: | cd src & ".\nugetDevBuild.bat" + + push: + needs: build + runs-on: ubuntu-22.04 + env: + BASE_VERSION: 4.20.0 + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.0.x + + - name: Add dependencies + run: | + dotnet new classlib --name Nethereum --framework netstandard2.0 + cd Nethereum + dotnet add package --version ${{env.BASE_VERSION}} Nethereum.ABI + dotnet add package --version ${{env.BASE_VERSION}} Nethereum.Accounts + dotnet add package --version ${{env.BASE_VERSION}} Nethereum.Contracts + dotnet add package --version ${{env.BASE_VERSION}} Nethereum.Hex + dotnet add package --version ${{env.BASE_VERSION}} Nethereum.KeyStore + dotnet add package --version ${{env.BASE_VERSION}} Nethereum.RLP + dotnet add package --version ${{env.BASE_VERSION}} Nethereum.RPC + dotnet add package --version ${{env.BASE_VERSION}} Nethereum.Signer + dotnet add package --version ${{env.BASE_VERSION}} Nethereum.StandardTokenEIP20 + dotnet add package --version ${{env.BASE_VERSION}} Nethereum.Util + dotnet add package --version ${{env.BASE_VERSION}} Nethereum.Web3 + rm Class1.cs + + - name: Pack + run: | + cd Nethereum + + VERSION="$(dotnet fsi ../nugetPreRelease.fsx $BASE_VERSION)" + + dotnet pack \ + --configuration Release \ + --output ../dist \ + --property:IncludeBuildOutput=false \ + --property:IncludeContentInPack=false \ + --property:TargetFrameworks=netstandard2.0 \ + --property:Version=$VERSION + + - name: Push + if: github.event_name == 'push' && github.ref == 'refs/heads/upstream' + run: | + cd dist + if [ -n "${{secrets.NUGET_API_KEY}}" ]; then + dotnet nuget push *.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json + fi diff --git a/nugetPreRelease.fsx b/nugetPreRelease.fsx new file mode 100644 index 000000000..71cadf764 --- /dev/null +++ b/nugetPreRelease.fsx @@ -0,0 +1,6 @@ +#r "nuget: Fsdk, Version=0.6.0--date20231213-0703.git-d7a5962" + +let args = fsi.CommandLineArgs + +Fsdk.Network.GetNugetPrereleaseVersionFromBaseVersion args.[1] +|> System.Console.WriteLine