hugo-theme-readable

Fork of https://github.com/cjtheham/hugo-theme-readable
git clone https://git.eamoncaddigan.net/hugo-theme-readable.git
Log | Files | Refs | README | LICENSE

update-readable-css.sh (1757B)


      1 #!/bin/bash
      2 set -o errexit
      3 set -o pipefail
      4 set -o nounset
      5 
      6 # Query the codeberg.org API (see
      7 # https://codeberg.org/api/swagger#/repository/repoListReleases) and use jq to
      8 # get the tag name of the latest release (i.e. the first element of the array
      9 # in the JSON output). Finally, use sed to remove the double quotes around the
     10 # value.
     11 TAG_VERSION=$(curl -s \
     12     -H 'accept: application/json' \
     13     https://codeberg.org/api/v1/repos/Freedom-to-Write/readable.css/releases \
     14     | jq '.[0].tag_name' \
     15     | sed 's/"//g')
     16 
     17 echo "Latest tag: ${TAG_VERSION}"
     18 
     19 # Get the current version.
     20 # The '-o' option will only output the match grep found.
     21 # We look for readable.min.css and a set of three numbers seperated by dots,
     22 # i.e. a semantic version. readable.min.css is used to make sure that we match
     23 # the right numbers in the file.
     24 # We use sed to get rid of the readable.min.css prefix.
     25 CURRENT_VERSION=$(grep -o \
     26     'readable.min.css?v=v[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+' \
     27     layouts/partials/head.html \
     28     | sed 's/readable.min.css?v=//')
     29 echo "Current version: ${CURRENT_VERSION}"
     30 
     31 if [[ $TAG_VERSION == $CURRENT_VERSION ]]
     32 then
     33     echo "Nothing to do. The current version is already up to date."
     34 else
     35     curl -s "https://codeberg.org/Freedom-to-Write/readable.css/raw/tag/${TAG_VERSION}/readable.css" > static/css/readable.css
     36     curl -s "https://codeberg.org/Freedom-to-Write/readable.css/raw/tag/${TAG_VERSION}/readable.min.css" > static/css/readable.min.css
     37     sed -i "s/readable.min.css?v=${CURRENT_VERSION}/readable.min.css?v=${TAG_VERSION}/" layouts/partials/head.html
     38 fi
     39 
     40 # Add the latest tag version to the workflow environment, so we can access
     41 # it in later steps.
     42 echo "READABLE_CSS_TAG=${TAG_VERSION}" >> "$GITHUB_ENV"