2021-03-20 17:28:40 +00:00
#!/usr/bin/env bash
getVersionFromLatestRelease( ) {
version = ` curl -s "https://api.github.com/repos/resoai/TileBoard/releases/latest" \
| grep "tag_name" \
| cut -d '"' -f 4 \
| sed -e "s/v//" `
echo " $version "
}
2021-04-22 20:27:46 +00:00
getDownloadUrl( ) {
2021-04-21 21:39:23 +00:00
url = ` curl -s "https://api.github.com/repos/resoai/TileBoard/releases/latest" \
2021-03-20 17:28:40 +00:00
| grep "browser_download_url" \
| cut -d '"' -f 4`
2021-04-22 20:27:46 +00:00
echo " $url "
2021-03-20 17:28:40 +00:00
}
2021-04-21 21:39:23 +00:00
getLatestPublishedTag( ) {
latest_tag = ` curl -s "https://hub.docker.com/v2/repositories/fbrinker/tileboard/tags?page_size=1" \
| jq -r ".results[0].name" `
2021-03-20 17:28:40 +00:00
2021-04-21 21:39:23 +00:00
echo " $latest_tag "
}
LATEST_RELEASE = ` getVersionFromLatestRelease`
LATEST_TAG = ` getLatestPublishedTag`
if [ " $LATEST_RELEASE " = " $LATEST_TAG " ] ; then
echo "Nothing to do. Versions already match."
echo " Release: $LATEST_RELEASE "
echo " Tag: $LATEST_TAG "
2021-04-22 20:28:49 +00:00
exit 78 # drone.io exit code to stop but success the pipeline
2021-04-21 21:39:23 +00:00
fi
SEMVER = ( ${ LATEST_RELEASE //./ } )
2021-03-20 17:28:40 +00:00
MAJOR = ${ SEMVER [0] }
MINOR = ${ SEMVER [0] } .${ SEMVER [1] }
2021-04-21 21:39:23 +00:00
PATCH = $LATEST_RELEASE
2021-03-20 17:28:40 +00:00
2021-03-20 17:41:30 +00:00
echo " latest, $MAJOR , $MINOR , $PATCH " > .tags
2021-03-20 17:28:40 +00:00
2021-04-22 20:27:46 +00:00
RELEASE_URL = ` getDownloadUrl`
2021-03-20 17:28:40 +00:00
2021-04-22 20:27:46 +00:00
echo " Writing $RELEASE_URL into Dockerfile... "
sed -i " s|%RELEASE_URL%| $RELEASE_URL |g " ./Dockerfile