Skip to content

Commit

Permalink
bash variables uppercase and add other changelogs
Browse files Browse the repository at this point in the history
  • Loading branch information
neargle committed Jun 14, 2021
1 parent b269690 commit aca9cd6
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,34 @@ jobs:
cp bin/cdk_linux_386_thin bin/cdk_linux_386_thin_upx
upx bin/cdk_linux_386_thin_upx
date_string=`date -u +"%Y-%m-%d"`
sha256_text_body=`cd bin/ && shasum -a 256 * | tr -s ' ' '|'`
last_author=`git log --pretty="%an" | sed -n 1p`
DATE_STRING=`date -u +"%Y-%m-%d"`
SHA256_TEXT_BODY=`cd bin/ && shasum -a 256 * | tr -s ' ' '|'`
TAG_VERSION=`echo "$GITHUB_REF" | sed -e 's/refs\/tags\///'`
last_tag="$TAG_VERSION"
previous_tag=`git for-each-ref --sort='-authordate' --format="%(refname:short)" | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$" | sed -n 2p`
LAST_TAG="$TAG_VERSION"
PREVIOUS_TAG=`git for-each-ref --sort='-authordate' --format="%(refname:short)" | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$" | sed -n 2p`
exploit=`git log "${last_tag}...${previous_tag}" --pretty=format:%s -- "pkg/exploit/" | grep -viE ^merge`
evaluate=`git log "${last_tag}...${previous_tag}" --pretty=format:%s -- "pkg/evaluate/" | grep -viE ^merge`
tool=`git log "${last_tag}...${previous_tag}" --pretty=format:%s -- "pkg/tool/" | grep -viE ^merge`
exploit=`git log "${LAST_TAG}...${PREVIOUS_TAG}" --pretty=format:%s -- "pkg/exploit/" | grep -viE ^merge`
evaluate=`git log "${LAST_TAG}...${PREVIOUS_TAG}" --pretty=format:%s -- "pkg/evaluate/" | grep -viE ^merge`
tool=`git log "${LAST_TAG}...${PREVIOUS_TAG}" --pretty=format:%s -- "pkg/tool/" | grep -viE ^merge`
add_before=`echo "$exploit\n$evaluate\n$tool" | uniq`
all_commit_message=`git log "${last_tag}...${previous_tag}" --pretty=format:%s | grep -viE ^merge`
all_commit_message=`git log "${LAST_TAG}...${PREVIOUS_TAG}" --pretty=format:%s | grep -viE ^merge`
other=`diff -u <(echo "$add_before") <(echo "$all_commit_message") | grep -E "^\+[a-zA-Z]" | cut -c 2-`
exploit=`echo "$exploit" | awk '{print toupper(substr($0,1,1))""substr($0,2)}' | sed -e 's/^/* /'`
evaluate=`echo "$evaluate" | awk '{print toupper(substr($0,1,1))""substr($0,2)}' | sed -e 's/^/* /'`
tool=`echo "$tool" | awk '{print toupper(substr($0,1,1))""substr($0,2)}' | sed -e 's/^/* /'`
other=`echo "$other" | awk '{print toupper(substr($0,1,1))""substr($0,2)}' | sed -e 's/^/* /'`
[[ $exploit = *[^[:space:]]* ]] && exploit=$'### Exploits\n\n'"$exploit"
[[ $evaluate = *[^[:space:]]* ]] && evaluate=$'### About Evaluate\n\n'"${evaluate}"
[[ $tool = *[^[:space:]]* ]] && tool=$'### Tools\n\n'"${tool}"
[[ $other = *[^[:space:]]* ]] && other=$'### Others\n\n'"${other}"
release_body=$(cat <<- EOF
Release Date: $date_string
RELEASE_BODY=$(cat <<- EOF
Release Date: $DATE_STRING
## Changelog:
Expand All @@ -88,15 +89,17 @@ jobs:
$tool
$other
## Hash Table
|sha256|exectue file|
|SHA256|EXECTUE FILE|
|---|---|
|$sha256_text_body|
|$SHA256_TEXT_BODY|
EOF
)
title="CDK $TAG_VERSION"
TITLE="CDK $TAG_VERSION"
UPLOAD_URL=$(echo -n $UPLOAD_URL | sed s/\{.*//g)
for FILE in bin/*
Expand All @@ -110,11 +113,11 @@ jobs:
"${UPLOAD_URL}?name=$(basename ${FILE})";
done
release_body=`echo "$release_body" | jq -sR .`
RELEASE_BODY=`echo "$RELEASE_BODY" | jq -sR .`
curl \
-XPATCH \
-H "${API_HEADER}" \
-H "${AUTH_HEADER}" \
-H "Content-Type: application/json" \
-d "{\"name\": \"$title\",\"body\": ${release_body}}" \
-d "{\"name\": \"$TITLE\",\"body\": ${RELEASE_BODY}}" \
"${RELEASE_URL}";

0 comments on commit aca9cd6

Please sign in to comment.