Skip to content

Commit a282258

Browse files
authored
RUST-1921 Minor release script refactor (#1089)
1 parent bedae69 commit a282258

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

.evergreen/release-danger-do-not-run-manually.sh

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,16 @@ set +x
1313

1414
set -o errexit
1515

16-
if [[ -z "$TAG" ]]; then
17-
echo >&2 "\$TAG must be set to the git tag of the release"
18-
exit 1
19-
fi
20-
2116
if [[ -z "$TOKEN" ]]; then
2217
echo >&2 "\$TOKEN must be set to the crates.io authentication token"
2318
exit 1
2419
fi
2520

26-
git fetch origin tag $TAG --no-tags
27-
git checkout $TAG
28-
2921
source ./.evergreen/env.sh
3022

31-
cargo publish --token $TOKEN
23+
EXTRA=""
24+
if [[ "${DRY_RUN}" == "yes" ]]; then
25+
EXTRA="--dry-run"
26+
fi
27+
28+
cargo publish --token $TOKEN ${EXTRA}

.evergreen/release-fetch-tag.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
5+
if [[ -z "$GIT_TAG" ]]; then
6+
echo >&2 "\$GIT_TAG must be set to the git tag of the release"
7+
exit 1
8+
fi
9+
10+
git fetch origin tag $GIT_TAG --no-tags
11+
git checkout $GIT_TAG

.evergreen/releases.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ functions:
4747
${PREPARE_SHELL}
4848
.evergreen/install-dependencies.sh rust
4949
50+
"fetch tag":
51+
command: subprocess.exec
52+
params:
53+
working_dir: "src"
54+
add_expansions_to_env: true
55+
binary: bash
56+
args:
57+
- .evergreen/release-fetch-tag.sh
58+
5059
"publish release":
5160
- command: shell.exec
5261
type: test
@@ -57,6 +66,7 @@ functions:
5766
5867
TAG=${GIT_TAG} \
5968
TOKEN=${CRATES_IO_TOKEN} \
69+
DRY_RUN=${DRY_RUN} \
6070
PROJECT_DIRECTORY="$(pwd)" \
6171
bash .evergreen/release-danger-do-not-run-manually.sh
6272
@@ -65,9 +75,10 @@ tasks:
6575
commands:
6676
- func: "fetch source"
6777
- func: "install dependencies"
68-
- func: "publish release"
78+
- func: "fetch tag"
6979
vars:
7080
GIT_TAG: ${triggered_by_git_tag}
81+
- func: "publish release"
7182

7283
axes:
7384
- id: "os"

0 commit comments

Comments
 (0)