Skip to content

Commit d08c5c7

Browse files
author
Oleksandr Poliakov
committed
CSHARP-4765: CI script to generate Driver's dev-package
1 parent b4754f0 commit d08c5c7

File tree

12 files changed

+224
-6
lines changed

12 files changed

+224
-6
lines changed

Diff for: .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

Diff for: .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*

Diff for: 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:
@@ -1013,6 +1028,61 @@ functions:
10131028
${PREPARE_SHELL}
10141029
echo '{"results": [{ "status": "FAIL", "test_file": "Build", "log_raw": "No test-results.json found was created" } ]}' > ${PROJECT_DIRECTORY}/test-results.json
10151030
1031+
packages-pack:
1032+
- command: shell.exec
1033+
params:
1034+
working_dir: mongo-csharp-driver
1035+
script: |
1036+
${PREPARE_SHELL}
1037+
. ./evergreen/packages-pack.sh
1038+
1039+
packages-push:
1040+
- command: shell.exec
1041+
params:
1042+
working_dir: mongo-csharp-driver
1043+
env:
1044+
PACKAGES_SOURCE: ${PACKAGES_SOURCE}
1045+
PACKAGES_SOURCE_KEY: ${PACKAGES_SOURCE_KEY}
1046+
script: |
1047+
${PREPARE_SHELL}
1048+
. ./evergreen/packages-push.sh
1049+
1050+
upload-package:
1051+
- command: s3.put
1052+
params:
1053+
aws_key: ${aws_key}
1054+
aws_secret: ${aws_secret}
1055+
local_file: ${PROJECT_DIRECTORY}/build/nuget/${PACKAGE_ID}.${PACKAGE_VERSION}.nupkg
1056+
remote_file: ${UPLOAD_BUCKET}/${revision}/${PACKAGE_ID}.${PACKAGE_VERSION}.nupkg
1057+
bucket: mciuploads
1058+
permissions: public-read
1059+
content_type: ${content_type|application/octet-stream}
1060+
- command: s3.put
1061+
params:
1062+
aws_key: ${aws_key}
1063+
aws_secret: ${aws_secret}
1064+
local_file: ${PROJECT_DIRECTORY}/build/nuget/${PACKAGE_ID}.${PACKAGE_VERSION}.snupkg
1065+
remote_file: ${UPLOAD_BUCKET}/${revision}/${PACKAGE_ID}.${PACKAGE_VERSION}.snupkg
1066+
bucket: mciuploads
1067+
permissions: public-read
1068+
content_type: ${content_type|application/octet-stream}
1069+
1070+
download-package:
1071+
- command: s3.get
1072+
params:
1073+
aws_key: ${aws_key}
1074+
aws_secret: ${aws_secret}
1075+
local_file: ${PROJECT_DIRECTORY}/build/nuget/${PACKAGE_ID}.${PACKAGE_VERSION}.nupkg
1076+
remote_file: ${UPLOAD_BUCKET}/${revision}/${PACKAGE_ID}.${PACKAGE_VERSION}.nupkg
1077+
bucket: mciuploads
1078+
- command: s3.get
1079+
params:
1080+
aws_key: ${aws_key}
1081+
aws_secret: ${aws_secret}
1082+
local_file: ${PROJECT_DIRECTORY}/build/nuget/${PACKAGE_ID}.${PACKAGE_VERSION}.snupkg
1083+
remote_file: ${UPLOAD_BUCKET}/${revision}/${PACKAGE_ID}.${PACKAGE_VERSION}.snupkg
1084+
bucket: mciuploads
1085+
10161086
pre:
10171087
- func: fetch-source
10181088
- func: prepare-resources
@@ -1030,7 +1100,6 @@ post:
10301100
- func: cleanup
10311101

10321102
tasks:
1033-
10341103
- name: test-net472
10351104
commands:
10361105
- func: bootstrap-mongo-orchestration
@@ -1666,6 +1735,47 @@ tasks:
16661735
export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME}
16671736
GCPKMS_CMD="MONGODB_URI='mongodb://localhost:27017' ./evergreen/run-csfle-gcp-tests.sh" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh
16681737
1738+
- name: packages-create
1739+
commands:
1740+
- func: packages-pack
1741+
- func: upload-package
1742+
vars:
1743+
PACKAGE_ID: "MongoDB.Bson"
1744+
- func: upload-package
1745+
vars:
1746+
PACKAGE_ID: "MongoDB.Driver"
1747+
- func: upload-package
1748+
vars:
1749+
PACKAGE_ID: "MongoDB.Driver.Core"
1750+
- func: upload-package
1751+
vars:
1752+
PACKAGE_ID: "MongoDB.Driver.GridFS"
1753+
- func: upload-package
1754+
vars:
1755+
PACKAGE_ID: "mongocsharpdriver"
1756+
1757+
- name: packages-push-github
1758+
commands:
1759+
- func: download-package
1760+
vars:
1761+
PACKAGE_ID: "MongoDB.Bson"
1762+
- func: download-package
1763+
vars:
1764+
PACKAGE_ID: "MongoDB.Driver"
1765+
- func: download-package
1766+
vars:
1767+
PACKAGE_ID: "MongoDB.Driver.Core"
1768+
- func: download-package
1769+
vars:
1770+
PACKAGE_ID: "MongoDB.Driver.GridFS"
1771+
- func: download-package
1772+
vars:
1773+
PACKAGE_ID: "mongocsharpdriver"
1774+
- func: packages-push
1775+
vars:
1776+
PACKAGES_SOURCE: "https://nuget.pkg.github.com/mongodb/index.json"
1777+
PACKAGES_SOURCE_KEY: ${github_packages_key}
1778+
16691779
axes:
16701780
- id: version
16711781
display_name: MongoDB Version
@@ -1887,6 +1997,19 @@ task_groups:
18871997
tasks:
18881998
- test-csfle-with-gcp-kms
18891999

2000+
- name: dev-package
2001+
setup_task:
2002+
- func: fetch-source
2003+
vars:
2004+
PACKAGE_TARGET: "dev"
2005+
- func: prepare-resources
2006+
- func: fix-absolute-paths
2007+
- func: make-files-executable
2008+
- func: install-dotnet
2009+
tasks:
2010+
- packages-create
2011+
- packages-push-github
2012+
18902013
buildvariants:
18912014

18922015
- matrix_name: "secure-tests"
@@ -2190,3 +2313,11 @@ buildvariants:
21902313
- name: test-smoke-tests-netcoreapp31
21912314
- name: test-smoke-tests-net50
21922315
- name: test-smoke-tests-net60
2316+
2317+
- name: dev-package-pack
2318+
git_tag_only: true
2319+
display_name: "Dev Package Pack"
2320+
run_on: ubuntu1804-small
2321+
tags: ["dev-package"]
2322+
tasks:
2323+
- name: dev-package

Diff for: 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

Diff for: 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

Diff for: 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+

Diff for: 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"

Diff for: 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>

Diff for: 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>

Diff for: 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>

Diff for: 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>

Diff for: 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)