Skip to content
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
54 changes: 53 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
# used for [release](https://github.com/bytecodealliance/componentize-dotnet/blob/main/RELEASE.md)
branches: [ "main" ]
inputs:
test-run:
description: 'Run the workflow with out publishing step'
default: 'true'
required: false


jobs:
build:
Expand All @@ -25,7 +34,7 @@ jobs:
- name: Restore dependencies
run: dotnet restore
- name: Prepare WASM SDKs
run: dotnet msbuild src/WitBindgen/build/WitBindgen.targets /t:PrepareWasmSdks
run: dotnet msbuild src/WitBindgen/build/ByteCodeAlliance.Componentize.DotNet.WitBindgen.targets /t:PrepareWasmSdks
- name: Build
run: dotnet build --no-restore /p:BuildNumber=${{ github.run_number }}
- name: Test
Expand All @@ -39,3 +48,46 @@ jobs:
path: artifacts/*.nupkg
if-no-files-found: error
if: ${{ matrix.dotnet == '8.x' }} # only need one package published https://github.com/actions/upload-artifact?tab=readme-ov-file#not-uploading-to-the-same-artifact

release:
runs-on: windows-latest
needs: build
permissions:
contents: write
name: Release
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: nuget-packages
- name: Extract nuget version
id: extract_version
run: |
version=$(unzip -p artifacts/SDK*.nupkg '*.nuspec' | grep -oPm1 "(?<=<version>)[^<]+")
echo "Version: $version"
ls *.nupkg
echo "version=$version" >> $GITHUB_OUTPUT
# Publish to https://nuget.org and tag the version on repo if test-run=false
- name: Publish
run: dotnet nuget push ./*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
if: ${{ !inputs.test-run }}
- name: Push version tag
if: ${{ !inputs.test-run }}
env:
TAG: v${{ steps.extract_version.outputs.version }}"
run: |
git tag $TAG
git push origin $TAG
- name: Create release
if: ${{ !inputs.dry_run }}
run: |
gh release create $TAG --generate-notes --prerelease
env:
GH_TOKEN: ${{ github.token }}
TAG: v${{ steps.extract_version.outputs.version }}"
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Requires [.NET 8+](https://dotnet.microsoft.com/en-us/download)

```
## needed to avoid errors with multiple projects calling and downloading the sdks at same time (https://github.com/bytecodealliance/componentize-dotnet/issues/8)
dotnet msbuild src/WitBindgen/build/WitBindgen.targets /t:PrepareWasmSdks
dotnet msbuild src/WitBindgen/build/ByteCodeAlliance.Componentize.DotNet.WitBindgen.targets /t:PrepareWasmSdks
dotnet build
```

Expand Down
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<!-- find latest versions at https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet-experimental by name of package -->
<PackageVersion Include="Microsoft.DotNet.ILCompiler.LLVM" Version="9.0.0-preview.5.24304.1" />
<PackageVersion Include="runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM" Version="9.0.0-preview.5.24304.1" />

Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ With this package, you can add one NuGet reference. The build output is fully AO

If you don't already have it, install [.NET 8+ SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)

### 2. Create a project and add WasmComponent.Sdk package
### 2. Create a project and add ByteCodeAlliance.Componentize.DotNet.Wasm.SDK package

* `dotnet new console -o MyApp`
* `cd MyApp`
* `dotnet new nugetconfig`
* `dotnet nuget add source --name dotnet8-experimental https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json`
* `dotnet add package WasmComponent.Sdk --prerelease`
* `dotnet add package ByteCodeAlliance.Componentize.DotNet.Wasm.SDK --prerelease`

### 3. Configure the compilation output

Expand Down
20 changes: 20 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Releasing the package

1. Open a PR to update the `<VersionPrefix>` tag in [Directory.Build.Props](./Directory.Build.props)
2. Maintainers approve and merge PR
3. After the PR merges a maintainer triggers the Release workflow on the main branch via the github Actions UI or runs:

```
gh workflow run build -f test-run=false
```

4. The release flow will build and publish the packages to nuget, tag the repository with version of the release, and create a GH release
5. Maintainer updates release notes with package info:

```
# https://www.nuget.org/packages/ByteCodeAlliance.Componentize.DotNet.Wasm.SDK
dotnet add package ByteCodeAlliance.Componentize.DotNet.Wasm.SDK

# https://www.nuget.org/packages/ByteCodeAlliance.Componentize.DotNet.WitBindgen
dotnet add package ByteCodeAlliance.Componentize.DotNet.WitBindgen
```
15 changes: 14 additions & 1 deletion src/WasmComponent.Sdk/WasmComponent.Sdk.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="build\WasmComponent.Sdk.props" />
<Import Project="build\ByteCodeAlliance.Componentize.DotNet.Wasm.SDK.props" />

<PropertyGroup>
<PackageId>ByteCodeAlliance.Componentize.DotNet.Wasm.SDK</PackageId>
<Authors>ByteCode Alliance Developers</Authors>
<Description>Tooling for creating WebAssembly components from C#</Description>
<RepositoryUrl>https://github.com/bytecodealliance/componentize-dotnet</RepositoryUrl>
<PackageLicenseExpression>Apache-2.0 WITH LLVM-exception</PackageLicenseExpression>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<PackageTags>webassembly, .net, wasm</PackageTags>
<PackageReleaseNotes>https://github.com/bytecodealliance/componentize-dotnet/releases/tag/$(PackageVersion)</PackageReleaseNotes>

<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand All @@ -27,6 +36,10 @@
<ProjectReference Include="..\WitBindgen\WitBindgen.csproj" PrivateAssets="None" />
</ItemGroup>

<ItemGroup>
<None Include="../../Readme.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
<None Include="ImportInDev.proj" />
</ItemGroup>
Expand Down
15 changes: 14 additions & 1 deletion src/WitBindgen/WitBindgen.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="build\WitBindgen.props" />
<Import Project="build\ByteCodeAlliance.Componentize.DotNet.WitBindgen.props" />

<PropertyGroup>
<PackageId>ByteCodeAlliance.Componentize.DotNet.WitBindgen</PackageId>
<Authors>ByteCode Alliance Developers</Authors>
<Description>Tooling for creating WebAssembly components from C#</Description>
<RepositoryUrl>https://github.com/bytecodealliance/componentize-dotnet</RepositoryUrl>
<PackageLicenseExpression>Apache-2.0 WITH LLVM-exception</PackageLicenseExpression>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<PackageTags>webassembly, .net, wasm</PackageTags>
<PackageReleaseNotes>https://github.com/bytecodealliance/componentize-dotnet/releases/tag/$(PackageVersion)</PackageReleaseNotes>

<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand All @@ -22,6 +31,10 @@
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>

<ItemGroup>
<None Include="../../Readme.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<Target Name="BuildOrDownloadNativeTooling" BeforeTargets="BeforeBuild" DependsOnTargets="BuildNativeTooling; DownloadNativeTooling">
</Target>

Expand Down
4 changes: 2 additions & 2 deletions test/E2ETest/PackageTest/PackageTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
<!-- The next targets (+ nuget.config in folder above) ensures we have the latest nuget packages for the e2e test since there is no great way to force a project to use a particular nuget pacakage -->
<Target Name="BuildTestProjects" DependsOnTargets="PackPackagesForE2ETest" BeforeTargets="Build">
<Message Importance="high" Text="Rebuilding e2e test projects..." />
<RemoveDir Directories="$(NugetPackageRoot)\witbindgen\$(PackageVersion)" />
<RemoveDir Directories="$(NugetPackageRoot)\wasmcomponent.sdk\$(PackageVersion)" />
<RemoveDir Directories="$(NugetPackageRoot)\bytecodealliance.componentize.dotnet.wasm.sdk\$(PackageVersion)" />
<RemoveDir Directories="$(NugetPackageRoot)\bytecodealliance.componentize.dotnet.witbindgen\$(PackageVersion)" />
<RemoveDir Directories="..\testapps\E2EProducer\obj" />
<RemoveDir Directories="..\testapps\E2EConsumer\obj" />
<Exec Command="dotnet restore --no-cache" WorkingDirectory="..\testapps\E2EConsumer" />
Expand Down
2 changes: 1 addition & 1 deletion test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="WasmComponent.Sdk" Version="$(PackageVersion)" />
<PackageReference Include="ByteCodeAlliance.Componentize.DotNet.Wasm.SDK" Version="$(PackageVersion)" />

<!-- Just to ensure build order -->
<ProjectReference Include="..\E2EProducer\E2EProducer.csproj" ReferenceOutputAssembly="false" />
Expand Down
2 changes: 1 addition & 1 deletion test/E2ETest/testapps/E2EProducer/E2EProducer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="WasmComponent.Sdk" Version="$(PackageVersion)" />
<PackageReference Include="ByteCodeAlliance.Componentize.DotNet.Wasm.SDK" Version="$(PackageVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions test/E2ETest/testapps/nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</packageSources>
<packageSourceMapping>
<packageSource key="dev">
<package pattern="WitBindgen" />
<package pattern="WasmComponent.Sdk" />
<package pattern="ByteCodeAlliance.Componentize.DotNet.WitBindgen" />
<package pattern="ByteCodeAlliance.Componentize.DotNet.Wasm.SDK" />
</packageSource>
</packageSourceMapping>
</configuration>