From 5c1986a349d4705e3416f7a7b5e5e5b022d41081 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Thu, 6 Jun 2024 17:36:28 -0700 Subject: [PATCH 1/2] Add release workflow Signed-off-by: James Sturtevant --- .github/workflows/build.yml | 52 +++++++++++++++++++ Directory.Packages.props | 1 + README.md | 6 +-- RELEASE.md | 20 +++++++ .../WasmComponent.Sdk.csproj | 13 +++++ src/WitBindgen/WitBindgen.csproj | 13 +++++ test/E2ETest/PackageTest/PackageTest.csproj | 4 +- .../testapps/E2EConsumer/E2EConsumer.csproj | 2 +- .../testapps/E2EProducer/E2EProducer.csproj | 2 +- test/E2ETest/testapps/nuget.config | 4 +- 10 files changed, 107 insertions(+), 10 deletions(-) create mode 100644 RELEASE.md diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c568e2b..a9b850c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: @@ -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 "(?<=)[^<]+") + 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 }}" diff --git a/Directory.Packages.props b/Directory.Packages.props index 3a7d7eb..93ccefc 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,6 +3,7 @@ true + diff --git a/README.md b/README.md index 01b2769..990d042 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000..9f98abb --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,20 @@ +# Releasing the package + +1. Open a PR to update the `` 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 +``` \ No newline at end of file diff --git a/src/WasmComponent.Sdk/WasmComponent.Sdk.csproj b/src/WasmComponent.Sdk/WasmComponent.Sdk.csproj index ff1c896..cf7c32d 100644 --- a/src/WasmComponent.Sdk/WasmComponent.Sdk.csproj +++ b/src/WasmComponent.Sdk/WasmComponent.Sdk.csproj @@ -2,6 +2,15 @@ + ByteCodeAlliance.Componentize.DotNet.Wasm.SDK + ByteCode Alliance Developers + Tooling for creating WebAssembly components from C# + https://github.com/bytecodealliance/componentize-dotnet + Apache-2.0 WITH LLVM-exception + Readme.md + webassembly, .net, wasm + https://github.com/bytecodealliance/componentize-dotnet/releases/tag/$(PackageVersion) + net8.0 enable enable @@ -27,6 +36,10 @@ + + + + diff --git a/src/WitBindgen/WitBindgen.csproj b/src/WitBindgen/WitBindgen.csproj index 9ea6483..a64dbd6 100644 --- a/src/WitBindgen/WitBindgen.csproj +++ b/src/WitBindgen/WitBindgen.csproj @@ -2,6 +2,15 @@ + ByteCodeAlliance.Componentize.DotNet.WitBindgen + ByteCode Alliance Developers + Tooling for creating WebAssembly components from C# + https://github.com/bytecodealliance/componentize-dotnet + Apache-2.0 WITH LLVM-exception + Readme.md + webassembly, .net, wasm + https://github.com/bytecodealliance/componentize-dotnet/releases/tag/$(PackageVersion) + net8.0 enable enable @@ -22,6 +31,10 @@ false + + + + diff --git a/test/E2ETest/PackageTest/PackageTest.csproj b/test/E2ETest/PackageTest/PackageTest.csproj index 35813e5..8509b2b 100644 --- a/test/E2ETest/PackageTest/PackageTest.csproj +++ b/test/E2ETest/PackageTest/PackageTest.csproj @@ -33,8 +33,8 @@ - - + + diff --git a/test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj b/test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj index 46e70a9..053135b 100644 --- a/test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj +++ b/test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj @@ -16,7 +16,7 @@ - + diff --git a/test/E2ETest/testapps/E2EProducer/E2EProducer.csproj b/test/E2ETest/testapps/E2EProducer/E2EProducer.csproj index f9cd312..7abfe48 100644 --- a/test/E2ETest/testapps/E2EProducer/E2EProducer.csproj +++ b/test/E2ETest/testapps/E2EProducer/E2EProducer.csproj @@ -14,7 +14,7 @@ - + diff --git a/test/E2ETest/testapps/nuget.config b/test/E2ETest/testapps/nuget.config index 7e522b7..b3330dd 100644 --- a/test/E2ETest/testapps/nuget.config +++ b/test/E2ETest/testapps/nuget.config @@ -5,8 +5,8 @@ - - + + From b64e10348a483af3fce763fe4a99dfe6c83c5c87 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Fri, 14 Jun 2024 16:44:58 -0700 Subject: [PATCH 2/2] targets must match package_id https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview#custom-targets Signed-off-by: James Sturtevant --- .github/workflows/build.yml | 2 +- CONTRIBUTING.md | 2 +- src/WasmComponent.Sdk/WasmComponent.Sdk.csproj | 2 +- ...rops => ByteCodeAlliance.Componentize.DotNet.Wasm.SDK.props} | 0 ...ts => ByteCodeAlliance.Componentize.DotNet.Wasm.SDK.targets} | 0 src/WitBindgen/WitBindgen.csproj | 2 +- ...ps => ByteCodeAlliance.Componentize.DotNet.WitBindgen.props} | 0 ... => ByteCodeAlliance.Componentize.DotNet.WitBindgen.targets} | 0 8 files changed, 4 insertions(+), 4 deletions(-) rename src/WasmComponent.Sdk/build/{WasmComponent.Sdk.props => ByteCodeAlliance.Componentize.DotNet.Wasm.SDK.props} (100%) rename src/WasmComponent.Sdk/build/{WasmComponent.Sdk.targets => ByteCodeAlliance.Componentize.DotNet.Wasm.SDK.targets} (100%) rename src/WitBindgen/build/{WitBindgen.props => ByteCodeAlliance.Componentize.DotNet.WitBindgen.props} (100%) rename src/WitBindgen/build/{WitBindgen.targets => ByteCodeAlliance.Componentize.DotNet.WitBindgen.targets} (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a9b850c..aac4613 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 42e78a7..52b4646 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 ``` diff --git a/src/WasmComponent.Sdk/WasmComponent.Sdk.csproj b/src/WasmComponent.Sdk/WasmComponent.Sdk.csproj index cf7c32d..a63abbc 100644 --- a/src/WasmComponent.Sdk/WasmComponent.Sdk.csproj +++ b/src/WasmComponent.Sdk/WasmComponent.Sdk.csproj @@ -1,5 +1,5 @@  - + ByteCodeAlliance.Componentize.DotNet.Wasm.SDK diff --git a/src/WasmComponent.Sdk/build/WasmComponent.Sdk.props b/src/WasmComponent.Sdk/build/ByteCodeAlliance.Componentize.DotNet.Wasm.SDK.props similarity index 100% rename from src/WasmComponent.Sdk/build/WasmComponent.Sdk.props rename to src/WasmComponent.Sdk/build/ByteCodeAlliance.Componentize.DotNet.Wasm.SDK.props diff --git a/src/WasmComponent.Sdk/build/WasmComponent.Sdk.targets b/src/WasmComponent.Sdk/build/ByteCodeAlliance.Componentize.DotNet.Wasm.SDK.targets similarity index 100% rename from src/WasmComponent.Sdk/build/WasmComponent.Sdk.targets rename to src/WasmComponent.Sdk/build/ByteCodeAlliance.Componentize.DotNet.Wasm.SDK.targets diff --git a/src/WitBindgen/WitBindgen.csproj b/src/WitBindgen/WitBindgen.csproj index a64dbd6..d831d18 100644 --- a/src/WitBindgen/WitBindgen.csproj +++ b/src/WitBindgen/WitBindgen.csproj @@ -1,5 +1,5 @@  - + ByteCodeAlliance.Componentize.DotNet.WitBindgen diff --git a/src/WitBindgen/build/WitBindgen.props b/src/WitBindgen/build/ByteCodeAlliance.Componentize.DotNet.WitBindgen.props similarity index 100% rename from src/WitBindgen/build/WitBindgen.props rename to src/WitBindgen/build/ByteCodeAlliance.Componentize.DotNet.WitBindgen.props diff --git a/src/WitBindgen/build/WitBindgen.targets b/src/WitBindgen/build/ByteCodeAlliance.Componentize.DotNet.WitBindgen.targets similarity index 100% rename from src/WitBindgen/build/WitBindgen.targets rename to src/WitBindgen/build/ByteCodeAlliance.Componentize.DotNet.WitBindgen.targets