Skip to content

Commit

Permalink
Prevent AppStream validation error asv-release-time-missing
Browse files Browse the repository at this point in the history
* Avoid hard-coding and additional steps in the release workflow by simply
  considering the day of the last modification the release date
* See Martchus/syncthingtray#158
  • Loading branch information
Martchus committed Oct 11, 2022
1 parent da43158 commit d05677e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions cmake/modules/AppUtilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmake/templates/appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit d05677e

Please sign in to comment.