-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Build: Save build artifact and publish release #2633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
a21b226
7fd5126
3c28ffd
73023f3
442f364
7ff0f07
65d34d9
9ee83f6
4e3a215
6327141
557e8ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,9 +20,11 @@ function bazel_release_binary_build() { | |
| # TODO(mattklein123): Replace this with caching and a different job which creates images. | ||
| echo "Copying release binary for image build..." | ||
| mkdir -p "${ENVOY_SRCDIR}"/build_release | ||
| mkdir -p /tmp/envoy-dist | ||
| cp -f "${ENVOY_DELIVERY_DIR}"/envoy "${ENVOY_SRCDIR}"/build_release | ||
| mkdir -p "${ENVOY_SRCDIR}"/build_release_stripped | ||
| strip "${ENVOY_DELIVERY_DIR}"/envoy -o "${ENVOY_SRCDIR}"/build_release_stripped/envoy | ||
| cp "${ENVOY_SRCDIR}"/build_release_stripped/envoy /tmp/envoy-dist/envoy | ||
| } | ||
|
|
||
| function bazel_debug_binary_build() { | ||
|
|
@@ -36,6 +38,20 @@ function bazel_debug_binary_build() { | |
| "${ENVOY_DELIVERY_DIR}"/envoy-debug | ||
| } | ||
|
|
||
| function publish_github_release() { | ||
| TAG=$(git describe --abbrev=0 --tags) | ||
|
|
||
| wget https://github.com/aktau/github-release/releases/download/v0.7.2/linux-amd64-github-release.tar.bz2 -O /tmp/ghrelease.tar.bz2 | ||
| tar -xvjpf /tmp/ghrelease.tar.bz2 -C /tmp | ||
| cp /tmp/bin/linux/amd64/github-release /usr/local/bin/ghrelease | ||
| chmod +x /usr/local/bin/ghrelease | ||
|
|
||
| if [[ -n "${TAG:-}" ]]; then | ||
| ghrelease release --tag "${TAG:-}" --name "${TAG:-}" | ||
| ghrelease upload --tag "${TAG:-}" --name "envoy-linux-amd64" --file "${ENVOY_SRCDIR}/build_release_stripped/envoy" | ||
| fi | ||
| } | ||
|
|
||
| if [[ "$1" == "bazel.release" ]]; then | ||
| # The release build step still runs during tag events. Avoid rebuilding for no reason. | ||
| # TODO(mattklein123): Consider moving this into its own "build". | ||
|
|
@@ -167,6 +183,41 @@ elif [[ "$1" == "check_format" ]]; then | |
| elif [[ "$1" == "docs" ]]; then | ||
| docs/publish.sh | ||
| exit 0 | ||
| elif [[ "$1" == "github_release" ]]; then | ||
| if [[ ! -f "${ENVOY_SRCDIR}/build_release_stripped/envoy" ]]; then | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you move this into a new script |
||
| echo "could not locate envoy binary at path: ${ENVOY_SRCDIR}/build_release_stripped/envoy" | ||
|
|
||
| # TODO(taion809): discuss whether or not failing to publish to github warrents failing the build itself | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think misconfiguration that is this bad, i.e. we're in a completely unexpected environment, should warrant failure via |
||
| exit 0 | ||
| fi | ||
|
|
||
| if [[ -z "${GITHUB_TOKEN:-}" ]]; then | ||
| echo "environment variable GITHUB_TOKEN unset; cannot continue with publishing." | ||
|
|
||
| # TODO(taion809): discuss whether or not failing to publish to github warrents failing the build itself | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [[ -z "${GITHUB_USER:-}" ]]; then | ||
| echo "environment variable GITHUB_USERNAME unset; cannot continue with publishing." | ||
|
|
||
| # TODO(taion809): discuss whether or not failing to publish to github warrents failing the build itself | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [[ -z "${GITHUB_REPO:-}" ]]; then | ||
| echo "environment variable GITHUB_USERNAME unset; cannot continue with publishing." | ||
|
|
||
| # TODO(taion809): discuss whether or not failing to publish to github warrents failing the build itself | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [[ -n "${CIRCLE_TAG:-}" ]]; then | ||
| echo "skipping tag events" | ||
| exit 0 | ||
| fi | ||
|
|
||
| publish_github_release | ||
| else | ||
| echo "Invalid do_ci.sh target, see ci/README.md for valid targets." | ||
| exit 1 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will be run on every repository event, resulting in a release created for every merge?
We've historically handled this by adding a check in the script to only publish/release for tag events. Here's an example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be fixed, great catch!