Skip to content

Commit

Permalink
[**Fixed**] NuGet Release (#3338)
Browse files Browse the repository at this point in the history
* Added Nuget release when new published release

* Added some comments

* Removed current nuget release

* Added forgotten slashes
  • Loading branch information
cschuchardt88 authored Jun 19, 2024
1 parent 2bd2a45 commit 90468e8
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 96 deletions.
95 changes: 2 additions & 93 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
--source https://nuget.pkg.github.com/neo-project/index.json \
--api-key "${{ secrets.GITHUB_TOKEN }}" \
--disable-buffering \
--no-service-endpoint;
--no-service-endpoint
- name: Publish to myGet
working-directory: ./out
Expand All @@ -152,95 +152,4 @@ jobs:
--source https://www.myget.org/F/neo/api/v3/index.json \
--api-key "${{ secrets.MYGET_TOKEN }}" \
--disable-buffering \
--no-service-endpoint;
Release:
if: github.ref == 'refs/heads/master' && startsWith(github.repository, 'neo-project/')
needs: [Test]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get version
id: get_version
run: |
sudo apt install xmlstarlet
find src -name Directory.Build.props | xargs xmlstarlet sel -N i=http://schemas.microsoft.com/developer/msbuild/2003 -t -v "concat('::set-output name=version::v',//i:VersionPrefix/text())" | xargs echo
- name: Check tag
id: check_tag
run: curl -s -I ${{ format('https://github.com/{0}/releases/tag/{1}', github.repository, steps.get_version.outputs.version) }} | head -n 1 | cut -d$' ' -f2 | xargs printf "::set-output name=statusCode::%s" | xargs echo

- name: Create release
if: steps.check_tag.outputs.statusCode == '404'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.version }}
release_name: ${{ steps.get_version.outputs.version }}
prerelease: ${{ contains(steps.get_version.outputs.version, '-') }}

- name: Setup .NET
if: steps.check_tag.outputs.statusCode == '404'
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name : Pack (Neo)
if: steps.check_tag.outputs.statusCode == '404'
run: |
dotnet pack ./src/Neo \
--configuration Release \
--output ./out
- name : Pack (Neo.IO)
if: steps.check_tag.outputs.statusCode == '404'
run: |
dotnet pack ./src/Neo.IO \
--configuration Release \
--output ./out
- name : Pack (Neo.Extensions)
if: steps.check_tag.outputs.statusCode == '404'
run: |
dotnet pack ./src/Neo.Extensions \
--configuration Release \
--output ./out
- name : Pack (Neo.Json)
if: steps.check_tag.outputs.statusCode == '404'
run: |
dotnet pack ./src/Neo.Json \
--configuration Release \
--output ./out
- name : Pack (Neo.VM)
if: steps.check_tag.outputs.statusCode == '404'
run: |
dotnet pack ./src/Neo.VM \
--configuration Release \
--output ./out
- name : Pack (Neo.ConsoleService)
if: steps.check_tag.outputs.statusCode == '404'
run: |
dotnet pack ./src/Neo.ConsoleService \
--configuration Release \
--output ./out
- name : Pack (Neo.Cryptography.BLS12_381)
if: steps.check_tag.outputs.statusCode == '404'
run: |
dotnet pack ./src/Neo.Cryptography.BLS12_381 \
--configuration Release \
--output ./out
- name: Publish to NuGet
if: steps.check_tag.outputs.statusCode == '404'
run: |
dotnet nuget push out/*.nupkg -s https://api.nuget.org/v3/index.json -k ${NUGET_TOKEN} --skip-duplicate
env:
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
--no-service-endpoint
46 changes: 46 additions & 0 deletions .github/workflows/nuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Release (nuget)

# Trigger the workflow on a release event when a new release is published
on:
release:
types: [published]

# Define environment variables
env:
DOTNET_VERSION: 8.0.x
CONFIGURATION: Release

jobs:
nuget-release:
runs-on: ubuntu-latest
steps:
# Step to set the application version from the release tag
- name: Set Application Version (Environment Variable)
run: |
APP_VERSION=$(echo '${{ github.event.release.tag_name }}' | cut -d 'v' -f 2)
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Pack NuGet Packages
run: |
dotnet pack ./neo.sln \
--configuration Release \
--output ./sbin \
--verbosity normal \ # Normal verbosity level
-p:VersionPrefix=${{ env.APP_VERSION }} # Set the version prefix from tag_name
- name: Publish to NuGet.org
run: |
dotnet nuget push ./sbin/*.nupkg \
--source https://api.nuget.org/v3/index.json \
--api-key ${{ secrets.NUGET_TOKEN }} \
--skip-duplicate
8 changes: 8 additions & 0 deletions benchmarks/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<IsPackable>false</IsPackable>
</PropertyGroup>

</Project>
1 change: 0 additions & 1 deletion benchmarks/Neo.Benchmarks/Neo.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<TargetFrameworks>net8.0</TargetFrameworks>
<RootNamespace>Neo</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion benchmarks/Neo.VM.Benchmarks/Neo.VM.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<RootNamespace>Neo.VM</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

<PropertyGroup>
<Copyright>2015-2024 The Neo Project</Copyright>
<VersionPrefix>3.7.4</VersionPrefix>
<LangVersion>12.0</LangVersion>
<Authors>The Neo Project</Authors>
<IsPackable>true</IsPackable>
<PackageIcon>neo.png</PackageIcon>
<PackageProjectUrl>https://github.com/neo-project/neo</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
1 change: 1 addition & 0 deletions src/Neo.CLI/Neo.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<ApplicationIcon>neo.ico</ApplicationIcon>
<Nullable>enable</Nullable>
<OutputPath>../../bin/$(AssemblyTitle)</OutputPath>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/Neo.GUI/Neo.GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<ApplicationIcon>neo.ico</ApplicationIcon>
<GenerateResourceWarnOnBinaryFormatterUse>false</GenerateResourceWarnOnBinaryFormatterUse>
<OutputPath>../../bin/$(AssemblyTitle)</OutputPath>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 90468e8

Please sign in to comment.