-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
171 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script publishes a draft release | ||
|
||
# standard bash error handling | ||
set -o nounset # treat unset variables as an error and exit immediately. | ||
set -o errexit # exit immediately when a command fails. | ||
set -E # needs to be set if we want the ERR trap | ||
set -o pipefail # prevents errors in a pipeline from being masked | ||
|
||
RELEASE_ID=$1 | ||
|
||
REPOSITORY=${REPOSITORY:-kyma-project/warden} | ||
GITHUB_URL=https://api.github.com/repos/${REPOSITORY} | ||
GITHUB_AUTH_HEADER="Authorization: Bearer ${GITHUB_TOKEN}" | ||
|
||
CURL_RESPONSE=$(curl -L \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "${GITHUB_AUTH_HEADER}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
${GITHUB_URL}/releases/${RELEASE_ID} \ | ||
-d '{"draft":false}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/env bash | ||
|
||
# standard bash error handling | ||
set -o nounset # treat unset variables as an error and exit immediately. | ||
set -o errexit # exit immediately when a command fails. | ||
set -E # needs to be set if we want the ERR trap | ||
set -o pipefail # prevents errors in a pipeline from being masked | ||
|
||
# Expected variables: | ||
PULL_BASE_REF=${PULL_BASE_REF?"Define PULL_BASE_REF env"} # name of the tag | ||
GITHUB_TOKEN=${GITHUB_TOKEN?"Define GITHUB_TOKEN env"} # github token used to upload the template yaml | ||
|
||
uploadFile() { | ||
filePath=${1} | ||
ghAsset=${2} | ||
|
||
echo "Uploading ${filePath} as ${ghAsset}" | ||
response=$(curl -s -o output.txt -w "%{http_code}" \ | ||
--request POST --data-binary @"$filePath" \ | ||
-H "Authorization: token $GITHUB_TOKEN" \ | ||
-H "Content-Type: text/yaml" \ | ||
$ghAsset) | ||
if [[ "$response" != "201" ]]; then | ||
echo "Unable to upload the asset ($filePath): " | ||
echo "HTTP Status: $response" | ||
cat output.txt | ||
exit 1 | ||
else | ||
echo "$filePath uploaded" | ||
fi | ||
} | ||
|
||
echo "Fetching releases" | ||
CURL_RESPONSE=$(curl -w "%{http_code}" -sL \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer $GITHUB_TOKEN"\ | ||
https://api.github.com/repos/kyma-project/warden/releases) | ||
JSON_RESPONSE=$(sed '$ d' <<< "${CURL_RESPONSE}") | ||
HTTP_CODE=$(tail -n1 <<< "${CURL_RESPONSE}") | ||
if [[ "${HTTP_CODE}" != "200" ]]; then | ||
echo "${CURL_RESPONSE}" | ||
exit 1 | ||
fi | ||
|
||
echo "Finding release id for: ${PULL_BASE_REF}" | ||
RELEASE_ID=$(jq <<< ${JSON_RESPONSE} --arg tag "${PULL_BASE_REF}" '.[] | select(.tag_name == $ARGS.named.tag) | .id') | ||
|
||
echo "Got '${RELEASE_ID}' release id" | ||
if [ -z "${RELEASE_ID}" ] | ||
then | ||
echo "No release with tag = ${PULL_BASE_REF}" | ||
exit 1 | ||
fi | ||
|
||
echo "Updating github release with assets" | ||
UPLOAD_URL="https://uploads.github.com/repos/kyma-project/warden/releases/${RELEASE_ID}/assets" | ||
|
||
|
||
|
||
( cd charts ; tar czf "warden-${RELEASE_ID}.tgz" warden) | ||
|
||
uploadFile "warden-${RELEASE_ID}.tgz" "${UPLOAD_URL}?name=warden-chart.tgz" | ||
|
||
|
||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
### Verify post-submit prow jobs status | ||
# | ||
# Optional input args: | ||
# - REF_NAME - branch/tag/commit | ||
# Return status: | ||
# - return 0 - if status is "success" | ||
# - return 1 - if status is "failure" or after timeout (~25min) | ||
|
||
# wait until Prow trigger pipelines | ||
sleep 10 | ||
|
||
echo "Checking status of tag build jobs for warden" | ||
|
||
REF_NAME="${1:-"main"}" | ||
STATUS_URL="https://api.github.com/repos/kyma-project/warden/commits/${REF_NAME}/status" | ||
|
||
function verify_github_jobs_status () { | ||
local number=1 | ||
while [[ $number -le 100 ]] ; do | ||
echo ">--> checking warden build job status #$number" | ||
local STATUS=`curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" ${STATUS_URL} | jq -r .state ` | ||
echo "jobs status: ${STATUS:='UNKNOWN'}" | ||
[[ "$STATUS" == "success" ]] && return 0 | ||
[[ "$STATUS" == "failure" ]] && return 1 | ||
sleep 15 | ||
((number = number + 1)) | ||
done | ||
|
||
exit 1 | ||
} | ||
|
||
verify_github_jobs_status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters