Prevent AppStream validation error `asv-release-time-missing`

* Avoid hard-coding and additional steps in the release workflow by simply
  considering the day of the last modification the release date
* See https://github.com/Martchus/syncthingtray/issues/158
This commit is contained in:
Martchus 2022-10-11 21:00:16 +02:00
parent da431580d4
commit d05677e3b5
2 changed files with 17 additions and 1 deletions

View File

@ -63,6 +63,22 @@ function (add_appstream_file)
string(REGEX REPLACE "\n([^$])" "\n \\1" META_APP_APPDATA_BODY "${META_APP_APPDATA_BODY}")
endif ()
# make the day of the last modification the release date
set(META_RELEASE_DATE_${META_PROJECT_VARNAME_UPPER} "" CACHE STRING "release date of ${META_PROJECT_NAME}")
if (META_RELEASE_DATE_${META_PROJECT_VARNAME_UPPER} STREQUAL "")
execute_process(
COMMAND
sh -c "date --iso-8601 --reference=\"$(find . -type f -not -path '*.git/*' -printf '%T@ %P\n' | sort -n | awk '{print $2}' | tail -n1)\""
WORKING_DIRECTORY
"${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE META_RELEASE_DATE
)
string(STRIP "${META_RELEASE_DATE}" META_RELEASE_DATE)
set(META_RELEASE_DATE_${META_PROJECT_VARNAME_UPPER} "${META_RELEASE_DATE}" CACHE STRING "release date of ${META_PROJECT_NAME}" FORCE)
else ()
set(META_RELEASE_DATE "${META_RELEASE_DATE_${META_PROJECT_VARNAME_UPPER}}")
endif ()
# create appstream desktop file from template
set(APPSTREAM_FILE "${CMAKE_CURRENT_BINARY_DIR}/resources/${META_ID}.appdata.xml")
configure_file("${APP_APPSTREAM_TEMPLATE_FILE}" "${APPSTREAM_FILE}" @ONLY)

View File

@ -14,6 +14,6 @@
<binary>@META_TARGET_NAME@</binary>
</provides>
<releases>
<release version="@META_APP_VERSION@"/>
<release version="@META_APP_VERSION@" date="@META_RELEASE_DATE@"/>
</releases>
</component>