Skip to content

Commit

Permalink
Simplify release id for assets (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
halamix2 authored Oct 8, 2024
1 parent 1996eae commit 49c19cd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
23 changes: 1 addition & 22 deletions .github/scripts/release-assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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
RELEASE_ID=${RELEASE_ID?"Define RELEASE_ID env"} # github token used to upload the template yaml

uploadFile() {
filePath=${1}
Expand All @@ -30,28 +31,6 @@ uploadFile() {
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"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ jobs:
env:
PULL_BASE_REF: ${{ github.event.inputs.name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_ID: ${{ steps.create-draft.outputs.release_id }}
run: ./.github/scripts/release-assets.sh

outputs:
Expand Down

0 comments on commit 49c19cd

Please sign in to comment.