From 71b5a41c69267d43ce5b6f8e987e6ef06faaece7 Mon Sep 17 00:00:00 2001 From: James Bartlett Date: Mon, 8 May 2023 17:25:43 +0000 Subject: [PATCH] [releases] Create Github release for cloud releases. Signed-off-by: James Bartlett --- .github/workflows/cloud_release.yaml | 35 ++++++++++++++++++++++++++++ ci/cloud_build_release.sh | 8 ++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cloud_release.yaml b/.github/workflows/cloud_release.yaml index c53bb4a9d58..4fe77b16eb6 100644 --- a/.github/workflows/cloud_release.yaml +++ b/.github/workflows/cloud_release.yaml @@ -41,5 +41,40 @@ jobs: shell: bash run: | export TAG_NAME="${REF#*/tags/}" + export ARTIFACTS_DIR="$(pwd)/artifacts" + mkdir -p "${ARTIFACTS_DIR}" ./ci/save_version_info.sh ./ci/cloud_build_release.sh -p + - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 + with: + name: cloud-artifacts + path: artifacts/ + create-github-release: + if: ${{ contains(github.event.ref, '-') }} + name: Create Release on Github + runs-on: ubuntu-latest + needs: build-release + permissions: + contents: write + steps: + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 + with: + fetch-depth: 0 + - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 + - name: Create Release + env: + REF: ${{ github.event.ref }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OWNER: pixie-io + REPO: pixie + shell: bash + # yamllint disable rule:indentation + run: | + export TAG_NAME="${REF#*/tags/}" + # actions/checkout doesn't get the tag annotation properly. + git fetch origin tag "${TAG_NAME}" -f + export changelog="$(git tag -l --format='%(contents)' "${TAG_NAME}")" + gh release create "${TAG_NAME}" --title "Cloud ${TAG_NAME#release/cloud/}" \ + --notes $'Pixie Cloud Release:\n'"${changelog}" + gh release upload "${TAG_NAME}" cloud-artifacts/* + # yamllint enable rule:indentation diff --git a/ci/cloud_build_release.sh b/ci/cloud_build_release.sh index 1bb2b247ddc..042dce05a49 100755 --- a/ci/cloud_build_release.sh +++ b/ci/cloud_build_release.sh @@ -37,6 +37,8 @@ parse_args() { parse_args "$@" +artifacts_dir="${ARTIFACTS_DIR:?}" + repo_path=$(pwd) release_tag=${TAG_NAME##*/v} @@ -53,7 +55,7 @@ if [[ "$PUBLIC" == "true" ]]; then bazel run --config=stamp -c opt --action_env=GOOGLE_APPLICATION_CREDENTIALS --//k8s:image_version="${release_tag}" \ --//k8s:build_type=public //k8s/cloud:cloud_images_push - all_licenses_opts=("//tools/licenses:all_licenses" "--action_env=GOOGLE_APPLICATION_CREDENTIALS") + all_licenses_opts=("//tools/licenses:all_licenses" "--action_env=GOOGLE_APPLICATION_CREDENTIALS" "--remote_download_outputs=toplevel") all_licenses_path="$(bazel cquery "${all_licenses_opts[@]}" --output starlark --starlark:expr "target.files.to_list()[0].path" 2> /dev/null)" bazel build "${all_licenses_opts[@]}" @@ -85,6 +87,10 @@ if [[ "$PUBLIC" == "true" ]]; then gsutil cp "${repo_path}/pixie_cloud.tar.gz" "gs://pixie-dev-public/cloud/latest/pixie_cloud.tar.gz" fi + sha256sum "${repo_path}/pixie_cloud.tar.gz" | awk '{print $1}' > sha + cp "${repo_path}/pixie_cloud.tar.gz" "${artifacts_dir}/pixie_cloud.tar.gz" + cp sha "${artifacts_dir}/pixie_cloud.tar.gz.sha256" + exit 0 fi