Allow releases from different branches
This commit is contained in:
parent
1ab550f6f2
commit
f4b17b3033
50
.github/scripts/on-release.sh
vendored
50
.github/scripts/on-release.sh
vendored
@ -255,17 +255,30 @@ releasesJson=`curl -sH "Authorization: token $GITHUB_TOKEN" "https://api.github.
|
|||||||
if [ $? -ne 0 ]; then echo "ERROR: Get Releases Failed! ($?)"; exit 1; fi
|
if [ $? -ne 0 ]; then echo "ERROR: Get Releases Failed! ($?)"; exit 1; fi
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
prev_release=$(echo "$releasesJson" | jq -e -r '. | map(select(.draft == false and .prerelease == false)) | sort_by(.created_at | - fromdateiso8601) | .[0].tag_name')
|
prev_release=$(echo "$releasesJson" | jq -e -r ". | map(select(.draft == false and .prerelease == false)) | sort_by(.published_at | - fromdateiso8601) | .[0].tag_name")
|
||||||
prev_any_release=$(echo "$releasesJson" | jq -e -r '. | map(select(.draft == false)) | sort_by(.created_at | - fromdateiso8601) | .[0].tag_name')
|
prev_any_release=$(echo "$releasesJson" | jq -e -r ". | map(select(.draft == false)) | sort_by(.published_at | - fromdateiso8601) | .[0].tag_name")
|
||||||
|
prev_branch_release=$(echo "$releasesJson" | jq -e -r ". | map(select(.draft == false and .prerelease == false and .target_commitish == \"$RELEASE_BRANCH\")) | sort_by(.published_at | - fromdateiso8601) | .[0].tag_name")
|
||||||
|
prev_branch_any_release=$(echo "$releasesJson" | jq -e -r ". | map(select(.draft == false and .target_commitish == \"$RELEASE_BRANCH\")) | sort_by(.published_at | - fromdateiso8601) | .[0].tag_name")
|
||||||
shopt -s nocasematch
|
shopt -s nocasematch
|
||||||
if [ "$prev_any_release" == "$RELEASE_TAG" ]; then
|
if [ "$prev_release" == "$RELEASE_TAG" ]; then
|
||||||
prev_release=$(echo "$releasesJson" | jq -e -r '. | map(select(.draft == false and .prerelease == false)) | sort_by(.created_at | - fromdateiso8601) | .[1].tag_name')
|
prev_release=$(echo "$releasesJson" | jq -e -r ". | map(select(.draft == false and .prerelease == false)) | sort_by(.published_at | - fromdateiso8601) | .[1].tag_name")
|
||||||
prev_any_release=$(echo "$releasesJson" | jq -e -r '. | map(select(.draft == false)) | sort_by(.created_at | - fromdateiso8601) | .[1].tag_name')
|
fi
|
||||||
|
if [ "$prev_any_release" == "$RELEASE_TAG" ]; then
|
||||||
|
prev_any_release=$(echo "$releasesJson" | jq -e -r ". | map(select(.draft == false)) | sort_by(.published_at | - fromdateiso8601) | .[1].tag_name")
|
||||||
|
fi
|
||||||
|
if [ "$prev_branch_release" == "$RELEASE_TAG" ]; then
|
||||||
|
prev_branch_release=$(echo "$releasesJson" | jq -e -r ". | map(select(.draft == false and .prerelease == false and .target_commitish == \"$RELEASE_BRANCH\")) | sort_by(.published_at | - fromdateiso8601) | .[1].tag_name")
|
||||||
|
fi
|
||||||
|
if [ "$prev_branch_any_release" == "$RELEASE_TAG" ]; then
|
||||||
|
prev_branch_any_release=$(echo "$releasesJson" | jq -e -r ". | map(select(.draft == false and .target_commitish == \"$RELEASE_BRANCH\")) | sort_by(.published_at | - fromdateiso8601) | .[1].tag_name")
|
||||||
fi
|
fi
|
||||||
COMMITS_SINCE_RELEASE="$prev_any_release"
|
|
||||||
shopt -u nocasematch
|
shopt -u nocasematch
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
echo "Previous Release: $prev_release"
|
||||||
|
echo "Previous (any)release: $prev_any_release"
|
||||||
|
echo
|
||||||
|
|
||||||
# Merge package JSONs with previous releases
|
# Merge package JSONs with previous releases
|
||||||
if [ ! -z "$prev_any_release" ] && [ "$prev_any_release" != "null" ]; then
|
if [ ! -z "$prev_any_release" ] && [ "$prev_any_release" != "null" ]; then
|
||||||
echo "Merging with JSON from $prev_any_release ..."
|
echo "Merging with JSON from $prev_any_release ..."
|
||||||
@ -273,17 +286,12 @@ if [ ! -z "$prev_any_release" ] && [ "$prev_any_release" != "null" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$RELEASE_PRE" == "false" ]; then
|
if [ "$RELEASE_PRE" == "false" ]; then
|
||||||
COMMITS_SINCE_RELEASE="$prev_release"
|
|
||||||
if [ ! -z "$prev_release" ] && [ "$prev_release" != "null" ]; then
|
if [ ! -z "$prev_release" ] && [ "$prev_release" != "null" ]; then
|
||||||
echo "Merging with JSON from $prev_release ..."
|
echo "Merging with JSON from $prev_release ..."
|
||||||
merge_package_json "$prev_release/$PACKAGE_JSON_REL" "$OUTPUT_DIR/$PACKAGE_JSON_REL"
|
merge_package_json "$prev_release/$PACKAGE_JSON_REL" "$OUTPUT_DIR/$PACKAGE_JSON_REL"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Previous Release: $prev_release"
|
|
||||||
echo "Previous (any)release: $prev_any_release"
|
|
||||||
echo
|
|
||||||
|
|
||||||
# Upload package JSONs
|
# Upload package JSONs
|
||||||
echo "Uploading $PACKAGE_JSON_DEV ..."
|
echo "Uploading $PACKAGE_JSON_DEV ..."
|
||||||
echo "Download URL: "`git_safe_upload_asset "$OUTPUT_DIR/$PACKAGE_JSON_DEV"`
|
echo "Download URL: "`git_safe_upload_asset "$OUTPUT_DIR/$PACKAGE_JSON_DEV"`
|
||||||
@ -328,10 +336,25 @@ if [ $arrLen > 3 ] && [ "${msgArray[0]:0:3}" == "tag" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Append Commit Messages
|
# Append Commit Messages
|
||||||
|
echo
|
||||||
|
echo "Previous Branch Release: $prev_branch_release"
|
||||||
|
echo "Previous Branch (any)release: $prev_branch_any_release"
|
||||||
|
echo
|
||||||
|
commitFile="$OUTPUT_DIR/commits.txt"
|
||||||
|
COMMITS_SINCE_RELEASE="$prev_branch_any_release"
|
||||||
|
if [ "$RELEASE_PRE" == "false" ]; then
|
||||||
|
COMMITS_SINCE_RELEASE="$prev_branch_release"
|
||||||
|
fi
|
||||||
if [ ! -z "$COMMITS_SINCE_RELEASE" ] && [ "$COMMITS_SINCE_RELEASE" != "null" ]; then
|
if [ ! -z "$COMMITS_SINCE_RELEASE" ] && [ "$COMMITS_SINCE_RELEASE" != "null" ]; then
|
||||||
echo "Getting commits since $COMMITS_SINCE_RELEASE ..."
|
echo "Getting commits since $COMMITS_SINCE_RELEASE ..."
|
||||||
commitFile=$OUTPUT_DIR/commits.txt
|
git -C "$GITHUB_WORKSPACE" log --oneline -n 500 "$COMMITS_SINCE_RELEASE..HEAD" > "$commitFile"
|
||||||
git -C "$GITHUB_WORKSPACE" log --oneline "$COMMITS_SINCE_RELEASE..HEAD" > "$OUTPUT_DIR/commits.txt"
|
elif [ "$RELEASE_BRANCH" != "master" ]; then
|
||||||
|
echo "Getting all commits on branch '$RELEASE_BRANCH' ..."
|
||||||
|
git -C "$GITHUB_WORKSPACE" log --oneline -n 500 --cherry-pick --left-only --no-merges HEAD...origin/master > "$commitFile"
|
||||||
|
else
|
||||||
|
echo "Getting all commits on master ..."
|
||||||
|
git -C "$GITHUB_WORKSPACE" log --oneline -n 500 --no-merges > "$commitFile"
|
||||||
|
fi
|
||||||
releaseNotes+=$'\r\n##### Commits\r\n'
|
releaseNotes+=$'\r\n##### Commits\r\n'
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for next in `cat $commitFile`
|
for next in `cat $commitFile`
|
||||||
@ -342,7 +365,6 @@ if [ ! -z "$COMMITS_SINCE_RELEASE" ] && [ "$COMMITS_SINCE_RELEASE" != "null" ];
|
|||||||
releaseNotes+=$'\r\n'
|
releaseNotes+=$'\r\n'
|
||||||
done
|
done
|
||||||
rm -f $commitFile
|
rm -f $commitFile
|
||||||
fi
|
|
||||||
|
|
||||||
# Prepend the original release body
|
# Prepend the original release body
|
||||||
if [ "${RELEASE_BODY: -1}" == $'\r' ]; then
|
if [ "${RELEASE_BODY: -1}" == $'\r' ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user