Skip to content

Commit cb90413

Browse files
authored
CSHARP-4765: CI script to generate Driver's dev-package (#1169)
1 parent 927c445 commit cb90413

File tree

12 files changed

+224
-6
lines changed

12 files changed

+224
-6
lines changed

.editorconfig

+1
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,6 @@ indent_size = 2
187187
# Shell scripts
188188
[*.sh]
189189
end_of_line = lf
190+
indent_size = 2
190191
[*.{cmd, bat}]
191192
end_of_line = crlf

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ src/packages
4848

4949
# Nupkg artifacts
5050
*.nupkg
51+
*.snupkg
5152

5253
# NCrunch artifacts
5354
*.ncrunch*

evergreen/evergreen.yml

+137-6
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ functions:
3131
- command: git.get_project
3232
params:
3333
directory: mongo-csharp-driver
34-
# Applies the subitted patch, if any
34+
# Applies the submitted patch, if any
3535
# Deprecated. Should be removed. But still needed for certain agents (ZAP)
3636
- command: git.apply_patch
37-
# Make an evergreen exapanstion file with dynamic values
37+
# Make an evergreen expansion file with dynamic values
3838
- command: shell.exec
3939
params:
4040
working_dir: mongo-csharp-driver
@@ -46,6 +46,11 @@ functions:
4646
CURRENT_VERSION=latest
4747
fi
4848
49+
if [ "${PACKAGE_TARGET}" != "" ]; then
50+
PACKAGE_VERSION=$(PACKAGE_TARGET="${PACKAGE_TARGET}" sh ./evergreen/packages-version.sh)
51+
fi
52+
53+
export DOTNET_SDK_PATH="$(pwd)/../.dotnet"
4954
export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
5055
5156
if [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin
@@ -68,6 +73,8 @@ functions:
6873
MONGODB_BINARIES: "$MONGODB_BINARIES"
6974
UPLOAD_BUCKET: "$UPLOAD_BUCKET"
7075
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
76+
PACKAGE_VERSION: "$PACKAGE_VERSION"
77+
DOTNET_SDK_PATH: "$DOTNET_SDK_PATH"
7178
PREPARE_SHELL: |
7279
set -o errexit
7380
set -o xtrace
@@ -76,14 +83,16 @@ functions:
7683
export MONGODB_BINARIES="$MONGODB_BINARIES"
7784
export UPLOAD_BUCKET="$UPLOAD_BUCKET"
7885
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
79-
86+
export PACKAGE_VERSION="$PACKAGE_VERSION"
8087
export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
81-
export PATH="$MONGODB_BINARIES:$PATH"
88+
export PATH="$DOTNET_SDK_PATH:$MONGODB_BINARIES:$PATH"
8289
export PROJECT="${project}"
8390
EOT
8491
# See what we've done
8592
cat expansion.yml
8693
94+
# Do not output expansion.yml contents after this point
95+
8796
# Add CSFLE variables that shouldn't be output to the logs
8897
cat <<EOT >> expansion.yml
8998
PREPARE_CSFLE: |
@@ -97,13 +106,19 @@ functions:
97106
export FLE_GCP_PRIVATE_KEY=${FLE_GCP_PRIVATE_KEY}
98107
set -o xtrace # Enable tracing.
99108
EOT
100-
# Do not output expansion.yml contents after this point
101109
102110
# Load the expansion file to make an evergreen variable with the current unique version
103111
- command: expansions.update
104112
params:
105113
file: mongo-csharp-driver/expansion.yml
106114

115+
install-dotnet:
116+
- command: shell.exec
117+
params:
118+
script: |
119+
${PREPARE_SHELL}
120+
OS=${OS} sh ${PROJECT_DIRECTORY}/evergreen/install-dotnet.sh
121+
107122
prepare-resources:
108123
- command: shell.exec
109124
params:
@@ -1023,6 +1038,61 @@ functions:
10231038
${PREPARE_SHELL}
10241039
echo '{"results": [{ "status": "FAIL", "test_file": "Build", "log_raw": "No test-results.json found was created" } ]}' > ${PROJECT_DIRECTORY}/test-results.json
10251040
1041+
packages-pack:
1042+
- command: shell.exec
1043+
params:
1044+
working_dir: mongo-csharp-driver
1045+
script: |
1046+
${PREPARE_SHELL}
1047+
. ./evergreen/packages-pack.sh
1048+
1049+
packages-push:
1050+
- command: shell.exec
1051+
params:
1052+
working_dir: mongo-csharp-driver
1053+
env:
1054+
PACKAGES_SOURCE: ${PACKAGES_SOURCE}
1055+
PACKAGES_SOURCE_KEY: ${PACKAGES_SOURCE_KEY}
1056+
script: |
1057+
${PREPARE_SHELL}
1058+
. ./evergreen/packages-push.sh
1059+
1060+
upload-package:
1061+
- command: s3.put
1062+
params:
1063+
aws_key: ${aws_key}
1064+
aws_secret: ${aws_secret}
1065+
local_file: ${PROJECT_DIRECTORY}/build/nuget/${PACKAGE_ID}.${PACKAGE_VERSION}.nupkg
1066+
remote_file: ${UPLOAD_BUCKET}/${revision}/${PACKAGE_ID}.${PACKAGE_VERSION}.nupkg
1067+
bucket: mciuploads
1068+
permissions: public-read
1069+
content_type: ${content_type|application/octet-stream}
1070+
- command: s3.put
1071+
params:
1072+
aws_key: ${aws_key}
1073+
aws_secret: ${aws_secret}
1074+
local_file: ${PROJECT_DIRECTORY}/build/nuget/${PACKAGE_ID}.${PACKAGE_VERSION}.snupkg
1075+
remote_file: ${UPLOAD_BUCKET}/${revision}/${PACKAGE_ID}.${PACKAGE_VERSION}.snupkg
1076+
bucket: mciuploads
1077+
permissions: public-read
1078+
content_type: ${content_type|application/octet-stream}
1079+
1080+
download-package:
1081+
- command: s3.get
1082+
params:
1083+
aws_key: ${aws_key}
1084+
aws_secret: ${aws_secret}
1085+
local_file: ${PROJECT_DIRECTORY}/build/nuget/${PACKAGE_ID}.${PACKAGE_VERSION}.nupkg
1086+
remote_file: ${UPLOAD_BUCKET}/${revision}/${PACKAGE_ID}.${PACKAGE_VERSION}.nupkg
1087+
bucket: mciuploads
1088+
- command: s3.get
1089+
params:
1090+
aws_key: ${aws_key}
1091+
aws_secret: ${aws_secret}
1092+
local_file: ${PROJECT_DIRECTORY}/build/nuget/${PACKAGE_ID}.${PACKAGE_VERSION}.snupkg
1093+
remote_file: ${UPLOAD_BUCKET}/${revision}/${PACKAGE_ID}.${PACKAGE_VERSION}.snupkg
1094+
bucket: mciuploads
1095+
10261096
pre:
10271097
- func: fetch-source
10281098
- func: prepare-resources
@@ -1040,7 +1110,6 @@ post:
10401110
- func: cleanup
10411111

10421112
tasks:
1043-
10441113
- name: test-net472
10451114
commands:
10461115
- func: bootstrap-mongo-orchestration
@@ -1676,6 +1745,47 @@ tasks:
16761745
export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME}
16771746
GCPKMS_CMD="MONGODB_URI='mongodb://localhost:27017' ./evergreen/run-csfle-gcp-tests.sh" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh
16781747
1748+
- name: packages-create
1749+
commands:
1750+
- func: packages-pack
1751+
- func: upload-package
1752+
vars:
1753+
PACKAGE_ID: "MongoDB.Bson"
1754+
- func: upload-package
1755+
vars:
1756+
PACKAGE_ID: "MongoDB.Driver"
1757+
- func: upload-package
1758+
vars:
1759+
PACKAGE_ID: "MongoDB.Driver.Core"
1760+
- func: upload-package
1761+
vars:
1762+
PACKAGE_ID: "MongoDB.Driver.GridFS"
1763+
- func: upload-package
1764+
vars:
1765+
PACKAGE_ID: "mongocsharpdriver"
1766+
1767+
- name: packages-push
1768+
commands:
1769+
- func: download-package
1770+
vars:
1771+
PACKAGE_ID: "MongoDB.Bson"
1772+
- func: download-package
1773+
vars:
1774+
PACKAGE_ID: "MongoDB.Driver"
1775+
- func: download-package
1776+
vars:
1777+
PACKAGE_ID: "MongoDB.Driver.Core"
1778+
- func: download-package
1779+
vars:
1780+
PACKAGE_ID: "MongoDB.Driver.GridFS"
1781+
- func: download-package
1782+
vars:
1783+
PACKAGE_ID: "mongocsharpdriver"
1784+
- func: packages-push
1785+
vars:
1786+
PACKAGES_SOURCE: "https://api.nuget.org/v3/index.json"
1787+
PACKAGES_SOURCE_KEY: ${nuget_api_key}
1788+
16791789
axes:
16801790
- id: version
16811791
display_name: MongoDB Version
@@ -1897,6 +2007,19 @@ task_groups:
18972007
tasks:
18982008
- test-csfle-with-gcp-kms
18992009

2010+
- name: dev-package
2011+
setup_task:
2012+
- func: fetch-source
2013+
vars:
2014+
PACKAGE_TARGET: "dev"
2015+
- func: prepare-resources
2016+
- func: fix-absolute-paths
2017+
- func: make-files-executable
2018+
- func: install-dotnet
2019+
tasks:
2020+
- packages-create
2021+
- packages-push
2022+
19002023
buildvariants:
19012024

19022025
- matrix_name: "secure-tests"
@@ -2200,3 +2323,11 @@ buildvariants:
22002323
- name: test-smoke-tests-netcoreapp31
22012324
- name: test-smoke-tests-net50
22022325
- name: test-smoke-tests-net60
2326+
2327+
- name: dev-package-pack
2328+
git_tag_only: true
2329+
display_name: "Dev Package Pack"
2330+
run_on: ubuntu1804-small
2331+
tags: ["dev-package"]
2332+
tasks:
2333+
- name: dev-package

evergreen/install-dotnet.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
set -o errexit # Exit the script with error if any of the commands fail
3+
4+
DOTNET_SDK_PATH=./.dotnet
5+
mkdir -p "$DOTNET_SDK_PATH"
6+
7+
if [[ $OS =~ [Ww]indows.* ]]; then
8+
echo "Downloading Windows .NET SDK installer into $DOTNET_SDK_PATH folder..."
9+
curl -Lfo "$DOTNET_SDK_PATH"/dotnet-install.ps1 https://dot.net/v1/dotnet-install.ps1
10+
echo "Installing .NET LTS SDK..."
11+
powershell.exe "$DOTNET_SDK_PATH"/dotnet-install.ps1 -Channel 6.0 -InstallDir "$DOTNET_SDK_PATH" -NoPath
12+
else
13+
echo "Downloading .NET SDK installer into $DOTNET_SDK_PATH folder..."
14+
curl -Lfo "$DOTNET_SDK_PATH"/dotnet-install.sh https://dot.net/v1/dotnet-install.sh
15+
echo "Installing .NET LTS SDK..."
16+
bash "$DOTNET_SDK_PATH"/dotnet-install.sh --channel 6.0 --install-dir "$DOTNET_SDK_PATH" --no-path
17+
fi

evergreen/packages-pack.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
set -o errexit # Exit the script with error if any of the commands fail
3+
4+
if [ -z "$PACKAGE_VERSION" ]; then
5+
PACKAGE_VERSION=$(sh ./evergreen/packages-version.sh)
6+
echo Calculated PACKAGE_VERSION value: "$PACKAGE_VERSION"
7+
fi
8+
9+
echo Creating nuget package...
10+
11+
dotnet clean ./CSharpDriver.sln
12+
dotnet pack ./CSharpDriver.sln -o ./build/nuget -c Release -p:Version="$PACKAGE_VERSION" --include-symbols -p:SymbolPackageFormat=snupkg

evergreen/packages-push.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
set -o errexit # Exit the script with error if any of the commands fail
3+
set +o xtrace # Disable tracing.
4+
5+
if [ -z "$PACKAGES_SOURCE" ]; then
6+
echo "PACKAGES_SOURCE variable should be set"
7+
exit 1
8+
fi
9+
10+
if [ -z "$PACKAGES_SOURCE_KEY" ]; then
11+
echo "PACKAGES_SOURCE_KEY variable should be set"
12+
exit 1
13+
fi
14+
15+
if [ -z "$PACKAGE_VERSION" ]; then
16+
echo "PACKAGE_VERSION variable should be set"
17+
exit 1
18+
fi
19+
20+
dotnet nuget push --source "$PACKAGES_SOURCE" --api-key "$PACKAGES_SOURCE_KEY" ./build/nuget/MongoDB.Bson."$PACKAGE_VERSION".nupkg
21+
dotnet nuget push --source "$PACKAGES_SOURCE" --api-key "$PACKAGES_SOURCE_KEY" ./build/nuget/MongoDB.Driver.Core."$PACKAGE_VERSION".nupkg
22+
dotnet nuget push --source "$PACKAGES_SOURCE" --api-key "$PACKAGES_SOURCE_KEY" ./build/nuget/MongoDB.Driver."$PACKAGE_VERSION".nupkg
23+
dotnet nuget push --source "$PACKAGES_SOURCE" --api-key "$PACKAGES_SOURCE_KEY" ./build/nuget/MongoDB.Driver.GridFS."$PACKAGE_VERSION".nupkg
24+
dotnet nuget push --source "$PACKAGES_SOURCE" --api-key "$PACKAGES_SOURCE_KEY" ./build/nuget/mongocsharpdriver."$PACKAGE_VERSION".nupkg
25+
26+

evergreen/packages-version.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
set -o errexit # Exit the script with error if any of the commands fail
3+
4+
if [ -z "$PACKAGE_TARGET" ]; then
5+
# Use production release tag if nothing was passed
6+
PACKAGE_TARGET="release"
7+
fi
8+
9+
if [ "${PACKAGE_TARGET}" = "dev" ]; then
10+
PACKAGE_VERSION_MATCH="v[0-9]*.[0-9]*.[0-9]*-dev[0-9]*"
11+
PACKAGE_VERSION_EXCLUDE=""
12+
elif [ "${PACKAGE_TARGET}" = "release" ]; then
13+
PACKAGE_VERSION_MATCH="v[0-9]*.[0-9]*.[0-9]*"
14+
PACKAGE_VERSION_EXCLUDE="*-dev[0-9]*"
15+
else
16+
echo "Unexpected value of PACKAGE_TARGET: ${PACKAGE_TARGET}"
17+
fi
18+
19+
PACKAGE_VERSION=$(git describe --tags --abbrev=0 --match="${PACKAGE_VERSION_MATCH}" --exclude="${PACKAGE_VERSION_EXCLUDE}")
20+
PACKAGE_VERSION=$(echo $PACKAGE_VERSION | cut -c 2-)
21+
echo "$PACKAGE_VERSION"

src/MongoDB.Bson/MongoDB.Bson.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
<PropertyGroup>
88
<AssemblyTitle>MongoDB.Bson</AssemblyTitle>
99
<Product>MongoDB.Bson</Product>
10+
<PackageId>MongoDB.Bson</PackageId>
1011
<Description>Official MongoDB supported BSON library. See https://www.mongodb.com/docs/drivers/csharp/ for more details.</Description>
1112
<PackageDescription>MongoDB's Official Bson Library.</PackageDescription>
1213
<PackageTags>$(PackageTags);bson</PackageTags>
14+
<IsPackable>true</IsPackable>
1315
</PropertyGroup>
1416

1517
<ItemGroup>

src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
<PropertyGroup>
77
<AssemblyTitle>MongoDB.Driver.Core</AssemblyTitle>
88
<Product>MongoDB.Driver.Core</Product>
9+
<PackageId>MongoDB.Driver.Core</PackageId>
910
<Description>Official MongoDB supported Driver Core library. See https://www.mongodb.com/docs/drivers/csharp/ for more details.</Description>
1011
<PackageDescription>Core Component of the Official MongoDB .NET Driver.</PackageDescription>
12+
<IsPackable>true</IsPackable>
1113
</PropertyGroup>
1214

1315
<PropertyGroup>

src/MongoDB.Driver.GridFS/MongoDB.Driver.GridFS.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
<PropertyGroup>
88
<AssemblyTitle>MongoDB.Driver.GridFS</AssemblyTitle>
99
<Product>MongoDB.Driver.GridFS</Product>
10+
<PackageId>MongoDB.Driver.GridFS</PackageId>
1011
<Description>Official MongoDB supported driver for MongoDB GridFS implementation. See https://www.mongodb.com/docs/drivers/csharp/ for more details.</Description>
1112
<PackageDescription>GridFS Component of the Official MongoDB .NET Driver.</PackageDescription>
1213
<PackageTags>$(PackageTags);gridfs</PackageTags>
14+
<IsPackable>true</IsPackable>
1315
</PropertyGroup>
1416

1517
<ItemGroup>

src/MongoDB.Driver.Legacy/MongoDB.Driver.Legacy.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<PackageId>mongocsharpdriver</PackageId>
1212
<PackageDescription>This package contains the legacy driver. The new driver's package name is MongoDB.Driver</PackageDescription>
1313
<PackageTags></PackageTags>
14+
<IsPackable>true</IsPackable>
1415
</PropertyGroup>
1516

1617
<PropertyGroup>

src/MongoDB.Driver/MongoDB.Driver.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
<PropertyGroup>
88
<AssemblyTitle>MongoDB.Driver</AssemblyTitle>
99
<Product>MongoDB.Driver</Product>
10+
<PackageId>MongoDB.Driver</PackageId>
1011
<Description>Official MongoDB supported driver for MongoDB. See https://www.mongodb.com/docs/drivers/csharp/ for more details.</Description>
1112
<PackageDescription>Official .NET driver for MongoDB.</PackageDescription>
13+
<IsPackable>true</IsPackable>
1214
</PropertyGroup>
1315

1416
<ItemGroup>

0 commit comments

Comments
 (0)