From 71c7df921a30dd0334e16366a62e8b23f62dc9b1 Mon Sep 17 00:00:00 2001 From: ansgarz Date: Sun, 18 Jun 2023 12:40:00 +0200 Subject: [PATCH] add create-release-in-repo.sh --- release/create-release-in-repo.sh | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 release/create-release-in-repo.sh diff --git a/release/create-release-in-repo.sh b/release/create-release-in-repo.sh new file mode 100755 index 0000000..f75c729 --- /dev/null +++ b/release/create-release-in-repo.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Creates a release on a gitea server with assets (provs-desktop.jar, provs-server.jar, provs-syspec.jar) + +readonly release_url="https://repo.prod.meissa.de/api/v1/repos/meissa/provs/releases" + +if [[ -z "${RELEASE_TOKEN}" ]]; then + echo "Error: RELEASE_TOKEN not set."; exit 7 +else + token="${RELEASE_TOKEN}" +fi + +if [[ -z "${CI_COMMIT_TAG}" ]]; then + echo "Error: CI_COMMIT_TAG not set."; exit 7 +else + release_tag="${CI_COMMIT_TAG}" +fi + +result=$(curl -X 'POST' "${release_url}" -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"body\": \"Provides jar-files for release ${release_tag}\\nAttention: The \\\"Source Code\\\"-files below are not up-to-date!\", \"tag_name\": \"${release_tag}\" }" -H "Authorization: token ${token}") + +regex="\{\"id\":([0-9]+)," +if [[ $result =~ $regex ]]; then + release_id="${BASH_REMATCH[1]}" +else + echo "Error: release_id not found in: ${result}"; exit 7 +fi + +cd build/libs/ || { echo "Error: cd not possible"; exit 7; } + +find . -type f -exec sha256sum {} \; | sort > sha256sum.lst +find . -type f -exec sha512sum {} \; | sort > sha512sum.lst + +curl -X 'POST' "${release_url}/${release_id}/assets" -H 'accept: application/json' -H "Authorization: token ${token}" -H 'Content-Type: multipart/form-data' -F 'attachment=@provs-desktop.jar;type=application/x-java-archive' +curl -X 'POST' "${release_url}/${release_id}/assets" -H 'accept: application/json' -H "Authorization: token ${token}" -H 'Content-Type: multipart/form-data' -F 'attachment=@provs-server.jar;type=application/x-java-archive' +curl -X 'POST' "${release_url}/${release_id}/assets" -H 'accept: application/json' -H "Authorization: token ${token}" -H 'Content-Type: multipart/form-data' -F 'attachment=@provs-syspec.jar;type=application/x-java-archive' +curl -X 'POST' "${release_url}/${release_id}/assets" -H 'accept: application/json' -H "Authorization: token ${token}" -H 'Content-Type: multipart/form-data' -F 'attachment=@sha256sum.lst;type=text/plain' +curl -X 'POST' "${release_url}/${release_id}/assets" -H 'accept: application/json' -H "Authorization: token ${token}" -H 'Content-Type: multipart/form-data' -F 'attachment=@sha512sum.lst;type=text/plain'