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

feat: also publish a nuget package for c# scripting users #3

Merged
merged 2 commits into from
Jan 19, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 91 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
- name: 🧾 Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_BASIC }}
lfs: true
submodules: "recursive"
fetch-depth: 0 # So we can get all tags.
Expand Down Expand Up @@ -131,7 +130,6 @@ jobs:
- name: 🧾 Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_BASIC }}
lfs: true
submodules: "recursive"
fetch-depth: 0 # So we can get all tags.
Expand All @@ -156,6 +154,71 @@ jobs:
name: linux-artifacts
path: ./addons/platform/builds/linux

# Project is shipped as GDExtension for GDScript users, and also as a nuget
# package for C# scripting users.
build-for-nuget:
runs-on: ubuntu-latest
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
steps:
- name: 🧾 Checkout
uses: actions/checkout@v4
with:
lfs: true
submodules: 'recursive'
fetch-depth: 0 # So we can get all tags.

- name: 🔎 Read Current Project Version
id: current-version
uses: WyriHaximus/github-action-get-previous-tag@v1
with:
fallback: "0.0.0-devbuild"

- name: 🖨 Print Current Version
run: |
echo "Current Version: ${{ steps.current-version.outputs.tag }}"

- name: 🧮 Compute Next Version
uses: chickensoft-games/next-godot-csproj-version@v1
id: next-version
with:
project-version: ${{ steps.current-version.outputs.tag }}
godot-version: global.json
bump: ${{ inputs.bump }}

- uses: actions/setup-dotnet@v4
name: 💽 Setup .NET SDK
with:
# Use the .NET SDK from global.json in the root of the repository.
global-json-file: global.json

# Write version to file so .NET will build correct version.
- name: 📝 Write Version to File
uses: jacobtomlinson/gha-find-replace@v3
with:
find: "0.0.0-devbuild"
replace: ${{ steps.next-version.outputs.version }}
regex: false
include: Chickensoft.Platform/Chickensoft.Platform.csproj

- name: 📦 Build
run: dotnet build \
Chickensoft.Platform/Chickensoft.Platform.csproj -c Release

- name: 🔎 Get Package Path
id: package-path
run: |
package=$(find ./Chickensoft.Platform/nupkg -name "*.nupkg")
echo "package=$package" >> "$GITHUB_OUTPUT"
echo "📦 Found package: $package"

- name: ⬆️ Upload nuget package artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-artifact
path: ${{ steps.package-path.outputs.package }}

consolidate-artifacts:
runs-on: ubuntu-latest
needs:
Expand All @@ -166,7 +229,6 @@ jobs:
- name: 🧾 Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_BASIC }}
lfs: true
submodules: "recursive"
fetch-depth: 0 # So we can get all tags.
Expand Down Expand Up @@ -197,7 +259,9 @@ jobs:

create-release:
runs-on: ubuntu-latest
needs: consolidate-artifacts
needs:
- consolidate-artifacts
- build-for-nuget
steps:
- name: 🧾 Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -227,12 +291,25 @@ jobs:
godot-version: 1.0.0
bump: ${{ inputs.bump }}

- name: Download consolidated artifact
- name: Download GDExtension artifacts
uses: actions/download-artifact@v4
with:
name: platform
path: ./platform

- name: Download nuget package artifact
uses: actions/download-artifact@v4
with:
name: nuget-artifact
path: ./nuget

- name: 🔎 Get Nuget Package Path
id: package-path
run: |
package=$(find ./nuget -name "*.nupkg")
echo "package=$package" >> "$GITHUB_OUTPUT"
echo "📦 Found nuget package: $package"

- name: ✨ Create Release
env:
GITHUB_TOKEN: ${{ secrets.GH_BASIC }}
Expand All @@ -241,5 +318,13 @@ jobs:

version="${{ steps.next-version.outputs.version }}"

NUGET_PKG="${{ steps.package-path.outputs.package }}"

gh release create --title "v$version" --generate-notes "$version" \
./platform.zip
./platform.zip "$NUGET_PKG"

- name: 🛜 Publish Nuget Package
run: |
dotnet nuget push "${{ steps.package-path.outputs.package }}" \
--api-key "${{ secrets.NUGET_API_KEY }}" \
--source "https://api.nuget.org/v3/index.json" --skip-duplicate
109 changes: 37 additions & 72 deletions Chickensoft.Platform/Chickensoft.Platform.csproj
Original file line number Diff line number Diff line change
@@ -1,41 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFramework>net8.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<LangVersion>preview</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Nullable>enable</Nullable>
<IsAotCompatible>true</IsAotCompatible>
<PublishAot>true</PublishAot>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<StripSymbols>false</StripSymbols>

<CopyAllFiles>true</CopyAllFiles>
<RootNamespace>Chickensoft.Platform</RootNamespace>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<OutputPath>./nupkg</OutputPath>
<DebugType>portable</DebugType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<!-- <PublishAotUsingRuntimePack>true</PublishAotUsingRuntimePack> -->
<!-- <NativeLib>static</NativeLib>
<Optimized Condition="'$(Configuration)' == 'Release'">true</Optimized> -->
<ProcessedRuntimeIdentifier>$([System.String]::Copy('$(RuntimeIdentifier)').Replace('-', '.'))</ProcessedRuntimeIdentifier>
<ProcessedConfiguration Condition="'$(Configuration)' == 'Debug'">.debug</ProcessedConfiguration>
<ProcessedConfiguration Condition="'$(Configuration)' == 'Release'"></ProcessedConfiguration>
<AssemblyName>Platform</AssemblyName>
<AssemblyName Condition="$(RuntimeIdentifier) != ''">Platform$(ProcessedConfiguration).$(ProcessedRuntimeIdentifier)</AssemblyName>

<!-- To show generated files -->
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>.generated</CompilerGeneratedFilesOutputPath>

<Title>Platform</Title>
<Title>Chickensoft.Platform</Title>
<Version>0.0.0-devbuild</Version>
<Description>Platform-specific native extensions for Godot, written in C# and compiled ahead ahead-of-time (AOT).</Description>
<Copyright>© 2024 Chickensoft</Copyright>
<Authors>Chickensoft</Authors>
<Description>Chickensoft's native extensions for Godot.</Description>
<Copyright>© 2025 Joanna May</Copyright>
<Authors>Joanna May</Authors>
<Company>Chickensoft</Company>

<PackageId>Chickensoft.Platform</PackageId>
<PackageReleaseNotes>Platform release.</PackageReleaseNotes>
<PackageReleaseNotes>Chickensoft.Platform release.</PackageReleaseNotes>
<PackageIcon>icon.png</PackageIcon>
<PackageTags>state management;bloc;godot;game;state machine</PackageTags>
<PackageTags>godot;native;dll;platform;chickensoft;</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>https://github.com/chickensoft-games/Platform</PackageProjectUrl>
Expand All @@ -44,51 +32,28 @@
<RepositoryUrl>[email protected]:chickensoft-games/Platform.git</RepositoryUrl>
</PropertyGroup>

<!-- Platform Constants -->
<!-- macOS -->
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('osx'))">
<DefineConstants>$(DefineConstants);PLATFORM_MACOS</DefineConstants>
</PropertyGroup>
<!-- Linux -->
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('linux'))">
<DefineConstants>$(DefineConstants);PLATFORM_LINUX</DefineConstants>
</PropertyGroup>
<!-- Android -->
<!-- <PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('android'))">
<DefineConstants>$(DefineConstants);PLATFORM_ANDROID</DefineConstants>
<TargetFramework>net9.0-android</TargetFramework>
</PropertyGroup> -->
<!-- macOS Catalyst -->
<!-- <PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('maccatalyst'))">
<DefineConstants>$(DefineConstants);PLATFORM_MAC_CATALYST</DefineConstants>
<TargetFramework>net9.0-maccatalyst</TargetFramework>
</PropertyGroup> -->
<!-- iOS -->
<!-- <PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('ios'))">
<DefineConstants>$(DefineConstants);PLATFORM_IOS</DefineConstants>
<TargetFramework>net9.0-ios</TargetFramework>
</PropertyGroup> -->
<!-- Windows -->
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('win'))">
<DefineConstants>$(DefineConstants);PLATFORM_WINDOWS</DefineConstants>
</PropertyGroup>
<!-- Web (WASM) -->
<!-- <PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('browser'))">
<DefineConstants>$(DefineConstants);PLATFORM_WEB</DefineConstants>
<TargetFramework>net9.0-browser</TargetFramework>
</PropertyGroup> -->
<ItemGroup>
<None Include="../README.md" Pack="true" PackagePath="\" />
<None Include="../LICENSE" Pack="true" PackagePath="\" />
<None Include="./icon.png" Pack="true" PackagePath="" />
</ItemGroup>

<Target Name="LogConstants" AfterTargets="Build">
<Message Text="Defined Constants: $(DefineConstants)" Importance="High" />
</Target>
<ItemGroup>
<Compile Include="../Chickensoft.PlatformExt/src/**/*.*">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
</Compile>
</ItemGroup>

<ItemGroup>
<!-- You can find all available packages from the godot-dotnet nuget -->
<!-- source with the following command from this directory: -->
<!--
nuget list -Source godot-dotnet -AllVersions -Prerelease
-->
<PackageReference Include="Godot.Bindings" Version="4.4.0-nightly.24509.1" />
<PackageReference Include="Godot.SourceGenerators" Version="4.4.0-nightly.24509.1" />
<!-- Dependencies go here. -->
<PackageReference Include="IsExternalInit" Version="1.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SauceControl.InheritDoc" Version="2.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="GodotSharp" Version="4.2.2" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions Chickensoft.Platform/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 93 additions & 0 deletions Chickensoft.PlatformExt/Chickensoft.Platform.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAotCompatible>true</IsAotCompatible>
<PublishAot>true</PublishAot>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<StripSymbols>false</StripSymbols>
<DefineConstants>GDEXTENSION</DefineConstants>

<RootNamespace>Chickensoft.Platform</RootNamespace>

<Optimized Condition="'$(Configuration)' == 'Release'">true</Optimized>
<ProcessedRuntimeIdentifier>$([System.String]::Copy('$(RuntimeIdentifier)').Replace('-', '.'))</ProcessedRuntimeIdentifier>
<ProcessedConfiguration Condition="'$(Configuration)' == 'Debug'">.debug</ProcessedConfiguration>
<ProcessedConfiguration Condition="'$(Configuration)' == 'Release'"></ProcessedConfiguration>
<AssemblyName>Platform</AssemblyName>
<AssemblyName Condition="$(RuntimeIdentifier) != ''">Platform$(ProcessedConfiguration).$(ProcessedRuntimeIdentifier)</AssemblyName>

<!-- To show generated files -->
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>.generated</CompilerGeneratedFilesOutputPath>

<Title>Platform</Title>
<Version>0.0.0-devbuild</Version>
<Description>Platform-specific native extensions for Godot, written in C# and compiled ahead ahead-of-time (AOT).</Description>
<Copyright>© 2024 Chickensoft</Copyright>
<Authors>Chickensoft</Authors>
<Company>Chickensoft</Company>

<PackageId>Chickensoft.Platform</PackageId>
<PackageReleaseNotes>Platform release.</PackageReleaseNotes>
<PackageIcon>icon.png</PackageIcon>
<PackageTags>state management;bloc;godot;game;state machine</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>https://github.com/chickensoft-games/Platform</PackageProjectUrl>

<RepositoryType>git</RepositoryType>
<RepositoryUrl>[email protected]:chickensoft-games/Platform.git</RepositoryUrl>
</PropertyGroup>

<!-- Platform Constants -->
<!-- macOS -->
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('osx'))">
<DefineConstants>$(DefineConstants);PLATFORM_MACOS</DefineConstants>
</PropertyGroup>
<!-- Linux -->
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('linux'))">
<DefineConstants>$(DefineConstants);PLATFORM_LINUX</DefineConstants>
</PropertyGroup>
<!-- Android -->
<!-- <PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('android'))">
<DefineConstants>$(DefineConstants);PLATFORM_ANDROID</DefineConstants>
<TargetFramework>net9.0-android</TargetFramework>
</PropertyGroup> -->
<!-- macOS Catalyst -->
<!-- <PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('maccatalyst'))">
<DefineConstants>$(DefineConstants);PLATFORM_MAC_CATALYST</DefineConstants>
<TargetFramework>net9.0-maccatalyst</TargetFramework>
</PropertyGroup> -->
<!-- iOS -->
<!-- <PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('ios'))">
<DefineConstants>$(DefineConstants);PLATFORM_IOS</DefineConstants>
<TargetFramework>net9.0-ios</TargetFramework>
</PropertyGroup> -->
<!-- Windows -->
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('win'))">
<DefineConstants>$(DefineConstants);PLATFORM_WINDOWS</DefineConstants>
</PropertyGroup>
<!-- Web (WASM) -->
<!-- <PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('browser'))">
<DefineConstants>$(DefineConstants);PLATFORM_WEB</DefineConstants>
<TargetFramework>net9.0-browser</TargetFramework>
</PropertyGroup> -->

<Target Name="LogConstants" AfterTargets="Build">
<Message Text="Defined Constants: $(DefineConstants)" Importance="High" />
</Target>

<ItemGroup>
<!-- You can find all available packages from the godot-dotnet nuget -->
<!-- source with the following command from this directory: -->
<!--
nuget list -Source godot-dotnet -AllVersions -Prerelease
-->
<PackageReference Include="Godot.Bindings" Version="4.4.0-nightly.24509.1" />
<PackageReference Include="Godot.SourceGenerators" Version="4.4.0-nightly.24509.1" />
</ItemGroup>
</Project>
Loading
Loading