Skip to content

Commit 88d2d24

Browse files
committed
release: use GitHub's gh to create GitHub release
Signed-off-by: Ivan Valdes <[email protected]>
1 parent 5e238a0 commit 88d2d24

File tree

4 files changed

+184
-16
lines changed

4 files changed

+184
-16
lines changed

.github/workflows/release.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
Name-Email: [email protected]
2929
Expire-Date: 0
3030
EOF
31-
DRY_RUN=true ./scripts/release.sh --no-upload --no-docker-push --in-place 3.6.99
31+
DRY_RUN=true ./scripts/release.sh --no-upload --no-docker-push --no-gh-release --in-place 3.6.99
3232
- name: test-image
3333
run: |
3434
VERSION=3.6.99 ./scripts/test_images.sh

Documentation/contributor-guide/release.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ which don't need to be executed before releasing each version.
6262
4. Authenticate the image registry, refer to [Authentication methods](https://cloud.google.com/container-registry/docs/advanced-authentication).
6363
- `gcloud auth login`
6464
- `gcloud auth configure-docker`
65+
5. Install gh, refer to [GitHub's documentation](https://github.com/cli/cli#installation). Ensure that running
66+
`gh auth login` succeeds for the GitHub account you use to contribute to etcd.
6567

6668
### Release steps
6769

@@ -85,13 +87,8 @@ which don't need to be executed before releasing each version.
8587
It generates all release binaries under the directory `/tmp/etcd-release-${VERSION}/etcd/release/` and images. Binaries are pushed to the Google Cloud bucket
8688
under project `etcd-development`, and images are pushed to `quay.io` and `gcr.io`.
8789
7. Publish the release page on GitHub
88-
- Set the release title as the version name
89-
- Choose the correct release tag (generated from step #4)
90-
- Follow the format of previous release pages
91-
- Attach the generated binaries and signature file
92-
- Verify the historical binary size for each architecture. If there's a big difference, verify that it works for that architecture
93-
- Select whether it's a pre-release
94-
- Publish the release
90+
- Open the **draft** release URL shown by the release script
91+
- Review that it looks correct, then publish the release
9592
8. Announce to the etcd-dev googlegroup
9693

9794
Follow the format of previous release emails sent to [email protected], see an example below. After sending out the email, ask one of the mailing list maintainers to approve the email from the pending list. Additionally, label the release email as `Release`.

scripts/release.sh

+88-8
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ help() {
3333
echo "WARNING: This does not perform the 'Add API capabilities', 'Performance testing' "
3434
echo " or 'Documentation' steps. These steps must be performed manually BEFORE running this tool."
3535
echo ""
36-
echo "WARNING: This script does not sign releases, publish releases to github or sent announcement"
37-
echo " emails. These steps must be performed manually AFTER running this tool."
36+
echo "WARNING: This script does not send announcement emails. This step must be performed manually AFTER running this tool."
3837
echo ""
3938
echo " args:"
4039
echo " version: version of etcd to release, e.g. 'v3.2.18'"
4140
echo " flags:"
42-
echo " --no-upload: skip gs://etcd binary artifact uploads."
43-
echo " --no-docker-push: skip docker image pushes."
4441
echo " --in-place: build binaries using current branch."
42+
echo " --no-docker-push: skip docker image pushes."
43+
echo " --no-gh-release: skip creating the GitHub release using gh."
44+
echo " --no-upload: skip gs://etcd binary artifact uploads."
4545
echo ""
4646
echo "One can perform a (dry-run) test release from any (uncommitted) branch using:"
4747
echo " DRY_RUN=true REPOSITORY=\`pwd\` BRANCH='local-branch-name' ./scripts/release 3.5.0-foobar.2"
@@ -119,6 +119,21 @@ main() {
119119
exit 1
120120
fi
121121

122+
if [ "${NO_GH_RELEASE}" == 1 ]; then
123+
log_callout "Skipping gh verification, --no-gh-release is set"
124+
else
125+
# Check that gh is installed and logged in.
126+
log_callout "Check gh installation"
127+
if ! command -v gh >/dev/null; then
128+
log_error "Cannot find gh. Please follow the installation instructions at https://github.com/cli/cli#installation"
129+
exit 1
130+
fi
131+
if ! gh auth status &>/dev/null; then
132+
log_error "GitHub authentication failed for gh. Please run gh auth login."
133+
exit 1
134+
fi
135+
fi
136+
122137
# If the release tag does not already exist remotely, create it.
123138
log_callout "Create tag if not present"
124139
if [ "${remote_tag_exists}" -eq 0 ]; then
@@ -314,10 +329,70 @@ main() {
314329
exit 1
315330
fi
316331

317-
# TODO: signing process
318-
log_warning ""
319-
log_warning "WARNING: The release has not been signed and published to github. This must be done manually."
320-
log_warning ""
332+
if [ "${DRY_RUN}" == "true" ] || [ "${NO_GH_RELEASE}" == 1 ]; then
333+
log_warning ""
334+
log_warning "WARNING: Skipping creating GitHub release, --no-gh-release is set."
335+
log_warning "WARNING: If not running on DRY_MODE, please do the GitHub release manually."
336+
log_warning ""
337+
else
338+
local gh_repo
339+
local release_notes_temp_file
340+
local release_url
341+
local gh_release_args=()
342+
343+
# For the main branch (v3.6), we should mark the release as a prerelease.
344+
# The release-3.5 (v3.5) branch, should be marked as latest. And release-3.4 (v3.4)
345+
# should be left without any additional mark (therefore, it doesn't need a special argument).
346+
if [ "${BRANCH}" = "main" ]; then
347+
gh_release_args=(--prerelease)
348+
elif [ "${BRANCH}" = "release-3.5" ]; then
349+
gh_release_args=(--latest)
350+
fi
351+
352+
if [ "${REPOSITORY}" = "$(pwd)" ]; then
353+
gh_repo=$(git remote get-url origin)
354+
else
355+
gh_repo="${REPOSITORY}"
356+
fi
357+
358+
gh_repo=$(echo "${gh_repo}" | sed 's/^[^@]\+@//' | sed 's/https\?:\/\///' | sed 's/\.git$//' | tr ':' '/')
359+
log_callout "Creating GitHub release for ${RELEASE_VERSION} on ${gh_repo}"
360+
361+
release_notes_temp_file=$(mktemp)
362+
363+
local release_version=${RELEASE_VERSION#v} # Remove the v prefix from the release version (i.e., v3.6.1 -> 3.6.1)
364+
local release_version_major_minor=${release_version%.*} # Remove the patch from the version (i.e., 3.6)
365+
local release_version_major=${release_version_major_minor%.*} # Extract the major (i.e., 3)
366+
local release_version_minor=${release_version_major_minor/*./} # Extract the minor (i.e., 6)
367+
368+
# Disable sellcheck SC2016, the single quoted syntax for sed is intentional.
369+
# shellcheck disable=SC2016
370+
sed 's/${RELEASE_VERSION}/'"${RELEASE_VERSION}"'/g' ./scripts/release_notes.tpl.txt |
371+
sed 's/${RELEASE_VERSION_MAJOR_MINOR}/'"${release_version_major_minor}"'/g' |
372+
sed 's/${RELEASE_VERSION_MAJOR}/'"${release_version_major}"'/g' |
373+
sed 's/${RELEASE_VERSION_MINOR}/'"${release_version_minor}"'/g' > "${release_notes_temp_file}"
374+
375+
if ! gh --repo "${gh_repo}" release view "${RELEASE_VERSION}" &>/dev/null; then
376+
maybe_run gh release create "${RELEASE_VERSION}" \
377+
--repo "${gh_repo}" \
378+
--draft \
379+
--title "${RELEASE_VERSION}" \
380+
--notes-file "${release_notes_temp_file}" \
381+
"${gh_release_args[@]}"
382+
fi
383+
384+
# Upload files one by one, as gh doesn't support passing globs as input.
385+
maybe_run find ./release '(' -name '*.tar.gz' -o -name '*.zip' ')' -exec \
386+
gh --repo "${gh_repo}" release upload "${RELEASE_VERSION}" {} --clobber \;
387+
maybe_run gh --repo "${gh_repo}" release upload "${RELEASE_VERSION}" ./release/SHA256SUMS --clobber
388+
389+
release_url=$(gh --repo "${gh_repo}" release view "${RELEASE_VERSION}" --json url --jq '.url')
390+
391+
log_warning ""
392+
log_warning "WARNING: The GitHub release for ${RELEASE_VERSION} has been created as a draft, please go to ${release_url} and release it."
393+
log_warning ""
394+
fi
395+
321396
log_success "Success."
322397
exit 0
323398
}
@@ -326,6 +401,7 @@ POSITIONAL=()
326401
NO_UPLOAD=0
327402
NO_DOCKER_PUSH=0
328403
IN_PLACE=0
404+
NO_GH_RELEASE=0
329405

330406
while test $# -gt 0; do
331407
case "$1" in
@@ -346,6 +422,10 @@ while test $# -gt 0; do
346422
NO_DOCKER_PUSH=1
347423
shift
348424
;;
425+
--no-gh-release)
426+
NO_GH_RELEASE=1
427+
shift
428+
;;
349429
*)
350430
POSITIONAL+=("$1") # save it in an array for later
351431
shift # past argument

scripts/release_notes.tpl.txt

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
Please check out [CHANGELOG](https://github.com/etcd-io/etcd/blob/main/CHANGELOG/CHANGELOG-${RELEASE_VERSION_MAJOR_MINOR}.md) for a full list of changes. And make sure to read [upgrade guide](https://etcd.io/docs/v${RELEASE_VERSION_MAJOR_MINOR}/upgrades/upgrade_${RELEASE_VERSION_MAJOR}_${RELEASE_VERSION_MINOR}/) before upgrading etcd (there may be breaking changes).
2+
3+
For installation guides, please check out [play.etcd.io](http://play.etcd.io) and [operating etcd](https://etcd.io/docs/v${RELEASE_VERSION_MAJOR_MINOR}/op-guide/). Latest support status for common architectures and operating systems can be found at [supported platforms](https://etcd.io/docs/v${RELEASE_VERSION_MAJOR_MINOR}/op-guide/supported-platform/).
4+
5+
###### Linux
6+
7+
```sh
8+
ETCD_VER=${RELEASE_VERSION}
9+
10+
# choose either URL
11+
GOOGLE_URL=https://storage.googleapis.com/etcd
12+
GITHUB_URL=https://github.com/etcd-io/etcd/releases/download
13+
DOWNLOAD_URL=${GOOGLE_URL}
14+
15+
rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
16+
rm -rf /tmp/etcd-download-test && mkdir -p /tmp/etcd-download-test
17+
18+
curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
19+
tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /tmp/etcd-download-test --strip-components=1
20+
rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
21+
22+
/tmp/etcd-download-test/etcd --version
23+
/tmp/etcd-download-test/etcdctl version
24+
/tmp/etcd-download-test/etcdutl version
25+
26+
# start a local etcd server
27+
/tmp/etcd-download-test/etcd
28+
29+
# write,read to etcd
30+
/tmp/etcd-download-test/etcdctl --endpoints=localhost:2379 put foo bar
31+
/tmp/etcd-download-test/etcdctl --endpoints=localhost:2379 get foo
32+
```
33+
34+
###### macOS (Darwin)
35+
36+
```sh
37+
ETCD_VER=${RELEASE_VERSION}
38+
39+
# choose either URL
40+
GOOGLE_URL=https://storage.googleapis.com/etcd
41+
GITHUB_URL=https://github.com/etcd-io/etcd/releases/download
42+
DOWNLOAD_URL=${GOOGLE_URL}
43+
44+
rm -f /tmp/etcd-${ETCD_VER}-darwin-amd64.zip
45+
rm -rf /tmp/etcd-download-test && mkdir -p /tmp/etcd-download-test
46+
47+
curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-darwin-amd64.zip -o /tmp/etcd-${ETCD_VER}-darwin-amd64.zip
48+
unzip /tmp/etcd-${ETCD_VER}-darwin-amd64.zip -d /tmp && rm -f /tmp/etcd-${ETCD_VER}-darwin-amd64.zip
49+
mv /tmp/etcd-${ETCD_VER}-darwin-amd64/* /tmp/etcd-download-test && rm -rf mv /tmp/etcd-${ETCD_VER}-darwin-amd64
50+
51+
/tmp/etcd-download-test/etcd --version
52+
/tmp/etcd-download-test/etcdctl version
53+
/tmp/etcd-download-test/etcdutl version
54+
```
55+
56+
###### Docker
57+
58+
etcd uses [`gcr.io/etcd-development/etcd`](https://gcr.io/etcd-development/etcd) as a primary container registry, and [`quay.io/coreos/etcd`](https://quay.io/coreos/etcd) as secondary.
59+
60+
```sh
61+
ETCD_VER=${RELEASE_VERSION}
62+
63+
rm -rf /tmp/etcd-data.tmp && mkdir -p /tmp/etcd-data.tmp && \
64+
docker rmi gcr.io/etcd-development/etcd:${ETCD_VER} || true && \
65+
docker run \
66+
-p 2379:2379 \
67+
-p 2380:2380 \
68+
--mount type=bind,source=/tmp/etcd-data.tmp,destination=/etcd-data \
69+
--name etcd-gcr-${ETCD_VER} \
70+
gcr.io/etcd-development/etcd:${ETCD_VER} \
71+
/usr/local/bin/etcd \
72+
--name s1 \
73+
--data-dir /etcd-data \
74+
--listen-client-urls http://0.0.0.0:2379 \
75+
--advertise-client-urls http://0.0.0.0:2379 \
76+
--listen-peer-urls http://0.0.0.0:2380 \
77+
--initial-advertise-peer-urls http://0.0.0.0:2380 \
78+
--initial-cluster s1=http://0.0.0.0:2380 \
79+
--initial-cluster-token tkn \
80+
--initial-cluster-state new \
81+
--log-level info \
82+
--logger zap \
83+
--log-outputs stderr
84+
85+
docker exec etcd-gcr-${ETCD_VER}/usr/local/bin/etcd --version
86+
docker exec etcd-gcr-${ETCD_VER}/usr/local/bin/etcdctl version
87+
docker exec etcd-gcr-${ETCD_VER}/usr/local/bin/etcdutl version
88+
docker exec etcd-gcr-${ETCD_VER}/usr/local/bin/etcdctl endpoint health
89+
docker exec etcd-gcr-${ETCD_VER}/usr/local/bin/etcdctl put foo bar
90+
docker exec etcd-gcr-${ETCD_VER}/usr/local/bin/etcdctl get foo
91+
```

0 commit comments

Comments
 (0)