Skip to content

Commit d786db1

Browse files
authored
Update GHA for NuGet publishing (#1406)
* Update GHA for NuGet publishing Follow-up to #1398 * Only build RabbitMQ.Client for the publish nuget step, and only push version 7 and higher * Enable RABBITMQ_LONG_RUNNING_TESTS in GHA
1 parent 4b3e1ff commit d786db1

File tree

12 files changed

+188
-161
lines changed

12 files changed

+188
-161
lines changed

.ci/oauth2/setup.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ declare -r keycloak_image_version='20.0'
1414
declare -r docker_network="$docker_name_prefix-net"
1515
declare -r rabbitmq_docker_name="$docker_name_prefix-rabbitmq"
1616

17-
function err_todo
18-
{
19-
echo '[ERROR] TODO' 1>&2
20-
exit 69
21-
}
22-
2317
function mode_is_uaa
2418
{
2519
[[ $mode == 'uaa' ]]

.ci/ubuntu/gha-setup.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ set -o nounset
2727

2828
declare -r rabbitmq_docker_name="$docker_name_prefix-rabbitmq"
2929

30-
function err_todo
31-
{
32-
echo '[ERROR] TODO' 1>&2
33-
exit 69
34-
}
35-
3630
function start_rabbitmq
3731
{
3832
chmod 0777 "$GITHUB_WORKSPACE/.ci/ubuntu/log"

.ci/windows/gha-run-tests.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ New-Variable -Name ci_dir -Option Constant -Value (Join-Path -Path $env:GITHUB_W
3131
New-Variable -Name certs_dir -Option Constant -Value (Join-Path -Path $ci_dir -ChildPath 'certs')
3232

3333
$csproj_file = Resolve-Path -LiteralPath (Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'projects' | Join-Path -ChildPath 'Unit' | Join-Path -ChildPath 'Unit.csproj')
34-
dotnet test --environment RABBITMQ_RABBITMQCTL_PATH=$rabbitmqctl_path --environment PASSWORD=grapefruit --environment SSL_CERTS_DIR=$certs_dir $csproj_file --no-restore --no-build --logger "console;verbosity=detailed"
34+
35+
dotnet test --environment "RABBITMQ_RABBITMQCTL_PATH=$rabbitmqctl_path" `
36+
--environment 'RABBITMQ_LONG_RUNNING_TESTS=true' `
37+
--environment 'PASSWORD=grapefruit' `
38+
--environment "SSL_CERTS_DIR=$certs_dir" `
39+
$csproj_file --no-restore --no-build --logger "console;verbosity=detailed"

.ci/windows/versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"erlang": "26.1.1",
2+
"erlang": "26.1.2",
33
"rabbitmq": "3.12.6"
44
}

.github/workflows/build-test.yaml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: build/test rabbitmq-dotnet-client
2+
3+
on:
4+
- workflow_call
5+
6+
jobs:
7+
build-win32:
8+
name: build/test on windows-latest
9+
runs-on: windows-latest
10+
# https://github.com/NuGet/Home/issues/11548
11+
env:
12+
NUGET_CERT_REVOCATION_MODE: offline
13+
steps:
14+
- name: Clone repository
15+
uses: actions/checkout@v4
16+
with:
17+
submodules: true
18+
- name: Cache installers
19+
uses: actions/cache@v3
20+
with:
21+
# Note: the cache path is relative to the workspace directory
22+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action
23+
path: ~/installers
24+
key: ${{ runner.os }}-v0-${{ hashFiles('.ci/versions.json') }}
25+
- name: Cache NuGet packages
26+
uses: actions/cache@v3
27+
with:
28+
path: |
29+
~/.nuget/packages
30+
~/AppData/Local/NuGet/v3-cache
31+
key: ${{ runner.os }}-v1-nuget-${{ hashFiles('**/*.csproj') }}
32+
restore-keys: |
33+
${{ runner.os }}-v1-nuget-
34+
- name: Install and Start RabbitMQ
35+
run: .\.ci\windows\gha-setup.ps1
36+
- name: List NuGet sources
37+
run: dotnet nuget locals all --list
38+
- name: Build
39+
run: dotnet build ${{ github.workspace }}\Build.csproj
40+
- name: Verify
41+
run: dotnet format ${{ github.workspace }}\RabbitMQDotNetClient.sln --verify-no-changes --verbosity=diagnostic
42+
- name: Test
43+
run: .\.ci\windows\gha-run-tests.ps1
44+
- name: Maybe upload RabbitMQ logs
45+
if: failure()
46+
uses: actions/upload-artifact@v3
47+
with:
48+
name: rabbitmq-logs
49+
path: ~/AppData/Roaming/RabbitMQ/log/
50+
build:
51+
name: build/test on ubuntu-latest
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Clone repository
55+
uses: actions/checkout@v4
56+
with:
57+
submodules: true
58+
- name: Setup .NET
59+
uses: actions/setup-dotnet@v3
60+
with:
61+
dotnet-version: 6.x
62+
- name: Cache NuGet packages
63+
uses: actions/cache@v3
64+
with:
65+
path: |
66+
~/.nuget/packages
67+
~/.local/share/NuGet/v3-cache
68+
key: ${{ runner.os }}-v1-nuget-${{ hashFiles('**/*.csproj') }}
69+
restore-keys: |
70+
${{ runner.os }}-v1-nuget-
71+
- name: Start RabbitMQ
72+
id: start-rabbitmq
73+
run: ${{ github.workspace }}/.ci/ubuntu/gha-setup.sh
74+
- name: List NuGet sources
75+
run: dotnet nuget locals all --list
76+
- name: Build
77+
run: dotnet build ${{ github.workspace }}/Build.csproj
78+
- name: Verify
79+
run: dotnet format ${{ github.workspace }}/RabbitMQDotNetClient.sln --verify-no-changes --verbosity=diagnostic
80+
- name: Test
81+
run: |
82+
dotnet test \
83+
--environment "RABBITMQ_RABBITMQCTL_PATH=DOCKER:${{ steps.start-rabbitmq.outputs.id }}" \
84+
--environment 'RABBITMQ_LONG_RUNNING_TESTS=true' \
85+
--environment 'PASSWORD=grapefruit' \
86+
--environment SSL_CERTS_DIR="${{ github.workspace }}/.ci/certs" \
87+
"${{ github.workspace }}/projects/Unit/Unit.csproj" --no-restore --no-build --logger 'console;verbosity=detailed' --framework 'net6.0'
88+
- name: Maybe upload RabbitMQ logs
89+
if: failure()
90+
uses: actions/upload-artifact@v3
91+
with:
92+
name: rabbitmq-logs
93+
path: ${{ github.workspace }}/.ci/ubuntu/log/

.github/workflows/main.yaml

Lines changed: 2 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -7,95 +7,5 @@ on:
77
branches: [ main ]
88

99
jobs:
10-
build-win32:
11-
name: build/test on windows-latest
12-
13-
runs-on: windows-latest
14-
15-
# https://github.com/NuGet/Home/issues/11548
16-
env:
17-
NUGET_CERT_REVOCATION_MODE: offline
18-
19-
steps:
20-
- name: Clone repository
21-
uses: actions/checkout@v4
22-
with:
23-
submodules: true
24-
- name: Cache installers
25-
uses: actions/cache@v3
26-
with:
27-
# Note: the cache path is relative to the workspace directory
28-
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action
29-
path: ~/installers
30-
key: ${{ runner.os }}-v0-${{ hashFiles('.ci/versions.json') }}
31-
- name: Cache NuGet packages
32-
uses: actions/cache@v3
33-
with:
34-
path: |
35-
~/.nuget/packages
36-
~/AppData/Local/NuGet/v3-cache
37-
key: ${{ runner.os }}-v1-nuget-${{ hashFiles('**/*.csproj') }}
38-
restore-keys: |
39-
${{ runner.os }}-v1-nuget-
40-
- name: Install and Start RabbitMQ
41-
run: .\.ci\windows\gha-setup.ps1
42-
- name: List NuGet sources
43-
run: dotnet nuget locals all --list
44-
- name: Build
45-
run: dotnet build ${{ github.workspace }}\Build.csproj
46-
- name: Verify
47-
run: dotnet format ${{ github.workspace }}\RabbitMQDotNetClient.sln --verify-no-changes --verbosity=diagnostic
48-
- name: Test
49-
run: .\.ci\windows\gha-run-tests.ps1
50-
- name: Maybe upload RabbitMQ logs
51-
if: failure()
52-
uses: actions/upload-artifact@v3
53-
with:
54-
name: rabbitmq-logs
55-
path: ~/AppData/Roaming/RabbitMQ/log/
56-
57-
build:
58-
name: build/test on ubuntu-latest
59-
60-
runs-on: ubuntu-latest
61-
62-
steps:
63-
- name: Clone repository
64-
uses: actions/checkout@v4
65-
with:
66-
submodules: true
67-
- name: Setup .NET
68-
uses: actions/setup-dotnet@v3
69-
with:
70-
dotnet-version: 6.x
71-
- name: Cache NuGet packages
72-
uses: actions/cache@v3
73-
with:
74-
path: |
75-
~/.nuget/packages
76-
~/.local/share/NuGet/v3-cache
77-
key: ${{ runner.os }}-v0-nuget-${{ hashFiles('**/*.csproj') }}
78-
restore-keys: |
79-
${{ runner.os }}-v0-nuget-
80-
- name: Start RabbitMQ
81-
id: start-rabbitmq
82-
run: ${{ github.workspace }}/.ci/ubuntu/gha-setup.sh
83-
- name: List NuGet sources
84-
run: dotnet nuget locals all --list
85-
- name: Build
86-
run: dotnet build ${{ github.workspace }}/Build.csproj
87-
- name: Verify
88-
run: dotnet format ${{ github.workspace }}/RabbitMQDotNetClient.sln --verify-no-changes --verbosity=diagnostic
89-
- name: Test
90-
run: |
91-
dotnet test \
92-
--environment RABBITMQ_RABBITMQCTL_PATH=DOCKER:${{ steps.start-rabbitmq.outputs.id }} \
93-
--environment PASSWORD=grapefruit \
94-
--environment SSL_CERTS_DIR="${{ github.workspace }}/.ci/certs" \
95-
"${{ github.workspace }}/projects/Unit/Unit.csproj" --no-restore --no-build --logger 'console;verbosity=detailed' --framework 'net6.0'
96-
- name: Maybe upload RabbitMQ logs
97-
if: failure()
98-
uses: actions/upload-artifact@v3
99-
with:
100-
name: rabbitmq-logs
101-
path: ${{ github.workspace }}/.ci/ubuntu/log/
10+
call-build-test:
11+
uses: ./.github/workflows/build-test.yaml

.github/workflows/publish-nuget.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: publish-nuget
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
NUGET_API_KEY:
7+
required: true
8+
9+
jobs:
10+
publish-nuget:
11+
runs-on: windows-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/cache@v3
15+
with:
16+
path: |
17+
~/.nuget/packages
18+
~/.local/share/NuGet/v3-cache
19+
key: ${{ runner.os }}-v1-nuget-${{ hashFiles('**/*.csproj') }}
20+
restore-keys: |
21+
${{ runner.os }}-v1-nuget-
22+
- name: Build (Release)
23+
run: dotnet build ${{ github.workspace }}\projects\RabbitMQ.Client\RabbitMQ.Client.csproj --verbosity=normal --configuration=Release --property CI=true
24+
- name: Publish to NuGet
25+
run: dotnet nuget push --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source 'https://api.nuget.org/v3/index.json' ${{ github.workspace }}\packages\RabbitMQ.Client.7.*.nupkg

.github/workflows/publish.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: publish rabbitmq-dotnet-client
2+
3+
on:
4+
release:
5+
types:
6+
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release
7+
- published
8+
9+
jobs:
10+
call-build-test:
11+
uses: ./.github/workflows/build-test.yaml
12+
call-publish-nuget:
13+
uses: ./.github/workflows/publish-nuget.yaml
14+
needs: call-build-test
15+
secrets: inherit

projects/RabbitMQ.Client.OAuth2/RabbitMQ.Client.OAuth2.csproj

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<Company>VMware, Inc. or its affiliates.</Company>
1010
<Copyright>Copyright © 2007-2023 VMware, Inc. or its affiliates.</Copyright>
1111
<Description>The RabbitMQ OAuth2 Client Library for .NET enables OAuth2 token refresh for RabbitMQ.Client</Description>
12-
<EmbedUntrackedSources>true</EmbedUntrackedSources>
1312
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1413
<PackageIcon>icon.png</PackageIcon>
1514
<PackageLicenseExpression>Apache-2.0 OR MPL-2.0</PackageLicenseExpression>
@@ -32,19 +31,15 @@
3231
<PackageReadmeFile>README.md</PackageReadmeFile>
3332
</PropertyGroup>
3433

35-
<PropertyGroup Condition="'$(CONCOURSE_CI_BUILD)' == 'true'">
34+
<PropertyGroup Condition="'$(Configuration)' == 'Release' And '$(CI)' == 'true'">
3635
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
3736
<Deterministic>true</Deterministic>
37+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
3838
</PropertyGroup>
3939

40-
<Target Name="SetVersionFromConcourseData" AfterTargets="MinVer" Condition="'$(CONCOURSE_PULL_REQUEST_NUMBER)' != ''">
41-
<PropertyGroup>
42-
<PackageVersion>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch)-$(MinVerPreRelease)-pr.$(CONCOURSE_PULL_REQUEST_NUMBER)</PackageVersion>
43-
<PackageVersion Condition="'$(MinVerBuildMetadata)' != ''">$(PackageVersion)+$(MinVerBuildMetadata)</PackageVersion>
44-
<Version>$(PackageVersion)</Version>
45-
</PropertyGroup>
46-
<Message Importance="normal" Text="SetVersionFromConcourseData: PackageVersion=$(PackageVersion) Version=$(Version)" />
47-
</Target>
40+
<ItemGroup Condition="'$(Configuration)' == 'Release' and '$(SourceRoot)' == ''">
41+
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/>
42+
</ItemGroup>
4843

4944
<ItemGroup>
5045
<None Remove="icon.png" />

projects/RabbitMQ.Client/RabbitMQ.Client.csproj

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<Company>VMware, Inc. or its affiliates.</Company>
1010
<Copyright>Copyright © 2007-2022 VMware, Inc. or its affiliates.</Copyright>
1111
<Description>The RabbitMQ .NET client is the official client library for C# (and, implicitly, other .NET languages)</Description>
12-
<EmbedUntrackedSources>true</EmbedUntrackedSources>
1312
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1413
<PackageIcon>icon.png</PackageIcon>
1514
<PackageLicenseExpression>Apache-2.0 OR MPL-2.0</PackageLicenseExpression>
@@ -32,19 +31,15 @@
3231
<PackageReadmeFile>README.md</PackageReadmeFile>
3332
</PropertyGroup>
3433

35-
<PropertyGroup Condition="'$(CONCOURSE_CI_BUILD)' == 'true'">
34+
<PropertyGroup Condition="'$(Configuration)' == 'Release' And '$(CI)' == 'true'">
3635
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
3736
<Deterministic>true</Deterministic>
37+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
3838
</PropertyGroup>
3939

40-
<Target Name="SetVersionFromConcourseData" AfterTargets="MinVer" Condition="'$(CONCOURSE_PULL_REQUEST_NUMBER)' != ''">
41-
<PropertyGroup>
42-
<PackageVersion>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch)-$(MinVerPreRelease)-pr.$(CONCOURSE_PULL_REQUEST_NUMBER)</PackageVersion>
43-
<PackageVersion Condition="'$(MinVerBuildMetadata)' != ''">$(PackageVersion)+$(MinVerBuildMetadata)</PackageVersion>
44-
<Version>$(PackageVersion)</Version>
45-
</PropertyGroup>
46-
<Message Importance="normal" Text="SetVersionFromConcourseData: PackageVersion=$(PackageVersion) Version=$(Version)" />
47-
</Target>
40+
<ItemGroup Condition="'$(Configuration)' == 'Release' and '$(SourceRoot)' == ''">
41+
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/>
42+
</ItemGroup>
4843

4944
<ItemGroup>
5045
<None Remove="icon.png" />

projects/Unit/Fixtures.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,6 @@ internal void AssertPreconditionFailed(ShutdownEventArgs args)
372372
AssertShutdownError(args, Constants.PreconditionFailed);
373373
}
374374

375-
internal bool InitiatedByPeerOrLibrary(ShutdownEventArgs evt)
376-
{
377-
return !(evt.Initiator == ShutdownInitiator.Application);
378-
}
379-
380375
//
381376
// Concurrency
382377
//

0 commit comments

Comments
 (0)