Compare commits

..

No commits in common. "9aaa9acca93ad579afd95696c064c844939aeac2" and "30d493b87a9b21173718e0dc9cc858ab0777e25f" have entirely different histories.

View File

@ -1,8 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
getVersionFromLatestRelease() { getVersionFromLatestRelease() {
repo="${1-resoai/TileBoard}" version=`curl -s "https://api.github.com/repos/resoai/TileBoard/releases/latest" \
version=`curl -s "https://api.github.com/repos/$repo/releases/latest" \
| grep "tag_name" \ | grep "tag_name" \
| cut -d '"' -f 4 \ | cut -d '"' -f 4 \
| sed -e "s/v//"` | sed -e "s/v//"`
@ -11,30 +10,27 @@ getVersionFromLatestRelease() {
} }
getDownloadUrl() { getDownloadUrl() {
repo="${1-resoai/TileBoard}" url=`curl -s "https://api.github.com/repos/resoai/TileBoard/releases/latest" \
url=`curl -s "https://api.github.com/repos/$repo/releases/latest" \
| grep "browser_download_url" \ | grep "browser_download_url" \
| cut -d '"' -f 4` | cut -d '"' -f 4`
echo "$url" echo "$url"
} }
docker_tag_exists() { getLatestPublishedTag() {
repo="${1-fbrinker/tileboard}" latest_tag=`curl -s "https://hub.docker.com/v2/repositories/fbrinker/tileboard/tags?page_size=1" \
tag="${2-latest}" | jq -r ".results[0].name"`
curl --silent -f -lSL "https://hub.docker.com/v2/repositories/$repo/tags/$tag" > /dev/null 2>&1
echo "$latest_tag"
} }
source_repo="${1-resoai/TileBoard}" LATEST_RELEASE=`getVersionFromLatestRelease`
target_repo="${2-fbrinker/tileboard}" LATEST_TAG=`getLatestPublishedTag`
echo "Source repository: $source_repo."
echo "Target repository: $target_repo."
LATEST_RELEASE=`getVersionFromLatestRelease $source_repo` if [ "$LATEST_RELEASE" = "$LATEST_TAG" ]; then
echo "Latest release is: $LATEST_RELEASE." echo "Nothing to do. Versions already match."
echo "Release: $LATEST_RELEASE"
if docker_tag_exists $target_repo $LATEST_RELEASE; then echo "Tag: $LATEST_TAG"
echo "Nothing to do. Latest release tag already exists."
exit 78 # drone.io exit code to stop but success the pipeline exit 78 # drone.io exit code to stop but success the pipeline
fi fi
@ -46,7 +42,6 @@ PATCH=$LATEST_RELEASE
echo "latest,$MAJOR,$MINOR,$PATCH" > .tags echo "latest,$MAJOR,$MINOR,$PATCH" > .tags
RELEASE_URL=`getDownloadUrl` RELEASE_URL=`getDownloadUrl`
echo "URL of release is: $RELEASE_URL."
echo "Writing release URL into Dockerfile..." echo "Writing $RELEASE_URL into Dockerfile..."
sed -i "s|%RELEASE_URL%|$RELEASE_URL|g" ./Dockerfile sed -i "s|%RELEASE_URL%|$RELEASE_URL|g" ./Dockerfile