-
Notifications
You must be signed in to change notification settings - Fork 32
92 lines (77 loc) · 3.42 KB
/
Copy pathdotnet-nuget.yml
File metadata and controls
92 lines (77 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: .NET Build and Publish Nuget
permissions:
contents: write # required to create releases/tags
env:
# One entry per package, in publish order. Optional "|extra-restore-args" suffix
# is appended to the `dotnet restore` call for that project only.
PACK_PROJECTS: |
src/Stride.CommunityToolkit/Stride.CommunityToolkit.csproj
src/Stride.CommunityToolkit.Windows/Stride.CommunityToolkit.Windows.csproj|--runtime win-x64
src/Stride.CommunityToolkit.Linux/Stride.CommunityToolkit.Linux.csproj
src/Stride.CommunityToolkit.Skyboxes/Stride.CommunityToolkit.Skyboxes.csproj
src/Stride.CommunityToolkit.Bepu/Stride.CommunityToolkit.Bepu.csproj
src/Stride.CommunityToolkit.Bullet/Stride.CommunityToolkit.Bullet.csproj
src/Stride.CommunityToolkit.DebugShapes/Stride.CommunityToolkit.DebugShapes.csproj
src/Stride.CommunityToolkit.ImGui/Stride.CommunityToolkit.ImGui.csproj
TEST_PROJECT: tests/Stride.CommunityToolkit.Tests/Stride.CommunityToolkit.Tests.csproj
COMMON_SETTINGS_PATH: src/CommonSettings.props
VERSION: "1.0.0.0-preview.${{ github.run_number }}"
NUGET_SOURCE: "https://api.nuget.org/v3/index.json"
NUPKG_ROOT: nupkgs
on:
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout Stride Community Toolkit
uses: actions/checkout@v7
- name: .NET Setup
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
- name: Set Version in csproj
run: |
$settingsContent = Get-Content -Path "${{ env.COMMON_SETTINGS_PATH }}" -Raw
$updatedCsprojContent = $settingsContent -replace '<Version>.*?</Version>', "<Version>${{ env.VERSION }}</Version>"
Set-Content -Path "${{ env.COMMON_SETTINGS_PATH }}" -Value $updatedCsprojContent
# Not needed as Directory.Build.props added a condition to this target
# - name: Create .sarif Directory
# run: New-Item -ItemType Directory -Force -Path D:\.sarif
# shell: pwsh
# Run the tests before anything is packed, so a failure costs nothing
- name: Test
run: dotnet test ${{ env.TEST_PROJECT }} -c Release --verbosity normal
# Everything is packed first and pushed afterwards: a build failure half-way
# through must not leave a partially published version on nuget.org
- name: Build and pack all packages
shell: bash
run: |
set -eo pipefail
while IFS= read -r entry; do
entry="${entry//$'\r'/}"
if [ -z "$entry" ]; then
continue
fi
project="${entry%%|*}"
restore_args=""
if [ "$entry" != "$project" ]; then
restore_args="${entry#*|}"
fi
echo "::group::$project"
dotnet restore "$project" $restore_args
dotnet build "$project" --no-restore -c Release
dotnet pack "$project" --no-build -c Release -o "$NUPKG_ROOT"
echo "::endgroup::"
done <<< "$PACK_PROJECTS"
- name: List packages
shell: bash
run: ls -l "$NUPKG_ROOT"
- name: Publish all packages
run: dotnet nuget push "${{ env.NUPKG_ROOT }}\*.nupkg" --source "${{ env.NUGET_SOURCE }}" --api-key "${{ secrets.NUGET_API_KEY }}" --skip-duplicate
# Create release
- name: Create GitHub Release
run: |
gh release create ${{ env.VERSION }} --title "v${{ env.VERSION }}" --notes "Release notes for ${{ env.VERSION }}" --draft
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}