From a418c2ec1458072bf01ec5260995ccf926e93313 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 29 Mar 2024 13:22:51 +0100 Subject: [PATCH 1/4] GitHubCI: add metapackage push Following: https://danielwertheim.se/how-to-create-a-nuget-metapackage/ Co-authored-by: Mehrshad --- .github/workflows/dotnet.yml | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index bbfb70062..551753bec 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -22,3 +22,56 @@ 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 + + # TODO: use Fsdk like FSharpLint does: https://github.com/fsprojects/FSharpLint/blob/master/nugetPreRelease.fsx + VERSION="${{env.BASE_VERSION}}" + + dotnet pack \ + --configuration Release \ + --output ../dist \ + --property:IncludeBuildOutput=false \ + --property:IncludeContentInPack=false \ + --property:TargetFrameworks=netstandard2.0 \ + --property:Version=$VERSION + +# disabled for now, comes from https://github.com/Mersho/Nethereum/commits/NethMetapackage +# - name: Push +# run: | +# cd dist +# dotnet nuget push *.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json From d7e00f524a7376316db76b08f2ca47790cc2e256 Mon Sep 17 00:00:00 2001 From: webwarrior Date: Mon, 1 Apr 2024 11:19:38 +0200 Subject: [PATCH 2/4] GithubCI: use nugetPreRelease.fsx to get version --- .github/workflows/dotnet.yml | 3 +-- nugetPreRelease.fsx | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 nugetPreRelease.fsx diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 551753bec..58d28017b 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -59,8 +59,7 @@ jobs: run: | cd Nethereum - # TODO: use Fsdk like FSharpLint does: https://github.com/fsprojects/FSharpLint/blob/master/nugetPreRelease.fsx - VERSION="${{env.BASE_VERSION}}" + VERSION="$(dotnet fsi ../nugetPreRelease.fsx $BASE_VERSION)" dotnet pack \ --configuration Release \ 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 From c7cafe0e9bcec1260d4720ce7bbb5e448962fa17 Mon Sep 17 00:00:00 2001 From: webwarrior Date: Mon, 1 Apr 2024 12:05:44 +0200 Subject: [PATCH 3/4] GithubCI: publish package on nuget --- .github/workflows/dotnet.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 58d28017b..97b5b7f3f 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -68,9 +68,8 @@ jobs: --property:IncludeContentInPack=false \ --property:TargetFrameworks=netstandard2.0 \ --property:Version=$VERSION - -# disabled for now, comes from https://github.com/Mersho/Nethereum/commits/NethMetapackage -# - name: Push -# run: | -# cd dist -# dotnet nuget push *.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json + + - name: Push + run: | + cd dist + dotnet nuget push *.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json From c5146b57a3d9781947dd9e60742971b6c9f3ee45 Mon Sep 17 00:00:00 2001 From: webwarrior Date: Tue, 2 Apr 2024 10:08:54 +0200 Subject: [PATCH 4/4] 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 97b5b7f3f..b803ca828 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -70,6 +70,9 @@ jobs: --property:Version=$VERSION - name: Push + if: github.event_name == 'push' && github.ref == 'refs/heads/upstream' run: | cd dist - dotnet nuget push *.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json + 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