Skip to content

Commit 438207a

Browse files
committed
Added latest released version to the inventory.json.
1 parent 2e4f6f3 commit 438207a

2 files changed

Lines changed: 28 additions & 5 deletions

File tree

.github/workflows/NightlyRelease.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ jobs:
304304
if [[ -n "${downloadedArtifacts[$artifact]}" ]]; then
305305
printf " %s\n" "downloading '${artifact}' ... ${ANSI_LIGHT_YELLOW}[SKIPPED]${ANSI_NOCOLOR}"
306306
else
307-
echo " downloading '${artifact}' ... "
307+
printf " downloading '${artifact}' ...\n"
308308
printf " %s" "gh run download $GITHUB_RUN_ID --dir \"${artifact}\" --name \"${artifact}\" "
309309
gh run download $GITHUB_RUN_ID --dir "${artifact}" --name "${artifact}"
310310
if [[ $? -eq 0 ]]; then

.github/workflows/PublishReleaseNotes.yml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ jobs:
249249
printf " %s\n" "MergedAt: ${PR_MERGED_AT} ($(date -d"${PR_MERGED_AT}" '+%d.%m.%Y - %H:%M:%S'))"
250250
fi
251251
252-
echo "${PR_BODY}" > __PULLREQUEST__.md
252+
printf "%s\n" "${PR_BODY}" > __PULLREQUEST__.md
253253
fi
254254
255255
# Check if a release description file should be used and exists.
@@ -353,7 +353,7 @@ jobs:
353353
NOTES="${NOTES//%%datetime%%/$(date '+%Y-%m-%d %H:%M:%S %Z')}"
354354
355355
# Write final release notes to file
356-
echo "${NOTES}" > __NOTES__.md
356+
printf "%s\n" "${NOTES}" > __NOTES__.md
357357
358358
# Display partial contents for debugging
359359
if [[ -s __DESCRIPTION__.md ]]; then
@@ -498,6 +498,25 @@ jobs:
498498
if [[ "${{ inputs.inventory-json }}" != "" ]]; then
499499
VERSION="1.0"
500500
501+
# Use GitHub API to ask for latest version
502+
printf "Get latest released version via GitHub API ...\n"
503+
printf " gh release list --json tagName,isLatest --jq '.[] | select(.isLatest == true) | .tagName' "
504+
latestVersion=$(gh release list --json tagName,isLatest --jq '.[] | select(.isLatest == true) | .tagName')
505+
if [[ $? -eq 0 ]]; then
506+
if [[ -n "${latestVersion}" ]]; then
507+
printf "${ANSI_LIGHT_RED}[UNKNOWN]${ANSI_NOCOLOR}\n"
508+
latestVersion="unknown"
509+
else
510+
printf "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}\n"
511+
fi
512+
else
513+
printf "${ANSI_LIGHT_RED}[ERROR]${ANSI_NOCOLOR}\n"
514+
printf " ${ANSI_LIGHT_RED}Couldn't get latest released version '%s'.${ANSI_NOCOLOR}\n" "${latestVersion}"
515+
printf "::error title=%s::%s\n" "GitHub Release API" "Couldn't get latest released version '${latestVersion}'."
516+
517+
latestVersion="error"
518+
fi
519+
501520
# Split categories by ',' into a Bash array.
502521
# See https://stackoverflow.com/a/45201229/3719459
503522
if [[ "${{ inputs.inventory-categories }}" != "" ]]; then
@@ -517,11 +536,15 @@ jobs:
517536
--arg hash "${{ github.sha }}" \
518537
--arg repo "${{ github.server_url }}/${{ github.repository }}" \
519538
--arg release "${{ github.server_url }}/${{ github.repository }}/releases/download/${{ inputs.tag }}" \
539+
--argjson jsonLatest "$(jq -c -n \
540+
--arg version "${latestVersion}" \
541+
'{"version": $version}' \
542+
)" \
520543
--argjson categories "$(jq -c -n \
521544
'$ARGS.positional' \
522545
--args "${inventoryCategories[@]}" \
523546
)" \
524-
'{"tag": $tag, "version": $version, "git-hash": $hash, "repository-url": $repo, "release-url": $release, "categories": $categories}' \
547+
'{"tag": $tag, "version": $version, "git-hash": $hash, "repository-url": $repo, "release-url": $release, "categories": $categories, "latest": $jsonLatest}' \
525548
)" \
526549
'{"version": 1.0, "timestamp": $date, "meta": $jsonMeta, "files": {}}'
527550
)
@@ -577,7 +600,7 @@ jobs:
577600
if [[ -n "${downloadedArtifacts[$artifact]}" ]]; then
578601
printf " downloading artifact '%s' ... ${ANSI_LIGHT_YELLOW}[SKIPPED]${ANSI_NOCOLOR}\n" "${artifact}"
579602
else
580-
echo " downloading '${artifact}' ... "
603+
printf " downloading '${artifact}' ...\n"
581604
printf " gh run download $GITHUB_RUN_ID --dir \"%s\" --name \"%s\" " "${artifact}" "${artifact}"
582605
gh run download $GITHUB_RUN_ID --dir "${artifact}" --name "${artifact}"
583606
if [[ $? -eq 0 ]]; then

0 commit comments

Comments
 (0)