summaryrefslogtreecommitdiff
path: root/tools/create-release.sh
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-31 17:00:58 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-31 17:00:58 +0200
commitd087d778ffb62e2713cb848540bcc819470365bd (patch)
treed69692a274dd1c7d0672e6bb7155a0fc106f9d49 /tools/create-release.sh
parentc8bd2513ecba169cff44c09c8058c36987357b18 (diff)
parent3759ce55ba79b8d3b9d8ed247a252273ee7dade3 (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'tools/create-release.sh')
-rwxr-xr-xtools/create-release.sh61
1 files changed, 61 insertions, 0 deletions
diff --git a/tools/create-release.sh b/tools/create-release.sh
new file mode 100755
index 0000000..40904d7
--- /dev/null
+++ b/tools/create-release.sh
@@ -0,0 +1,61 @@
+#!/bin/sh -eux
+# tools/create-release.sh -- via GitLab CI and API
+# Copyright (C) 2019 Olaf Meeuwissen
+#
+# License: GPL-3.0+
+
+GROUP=sane-project
+PROJECT=backends
+PROJECT_ID=$GROUP%2F$PROJECT
+
+API_ENDPOINT=https://gitlab.com/api/v4
+
+# Uploads a file and returns a project relative URL to it.
+upload () {
+ curl --silent --fail \
+ --header "PRIVATE-TOKEN: $PRIVATE_TOKEN" \
+ --form "file=@$1" \
+ --request POST \
+ $API_ENDPOINT/projects/$PROJECT_ID/uploads \
+ | jq --raw-output .url \
+ | sed "s|^|https://gitlab.com/$GROUP/$PROJECT|"
+}
+
+cat << EOF > release.json
+{
+ "name": "SANE Backends $CI_COMMIT_TAG",
+ "tag_name": "$CI_COMMIT_TAG",
+ "description": "$(sed '1,3d; / /{s/.*//; q}' NEWS \
+ | git stripspace \
+ | sed 's/"/\\"/g; s/$/\\n/g' \
+ | tr -d '\n')",
+ "assets": {
+ "links": [
+EOF
+
+for check in sha256 sha512; do
+ ${check}sum sane-backends-$CI_COMMIT_TAG.tar.gz \
+ > sane-backends-$CI_COMMIT_TAG.$check.txt
+ cat << EOF >> release.json
+ {
+ "name": "sane-backends-$CI_COMMIT_TAG.$check.txt",
+ "url": "$(upload sane-backends-$CI_COMMIT_TAG.$check.txt)"
+ },
+EOF
+done
+
+cat << EOF >> release.json
+ {
+ "name": "sane-backends-$CI_COMMIT_TAG.tar.gz",
+ "url": "$(upload sane-backends-$CI_COMMIT_TAG.tar.gz)"
+ }
+ ]
+ }
+}
+EOF
+
+curl --silent --fail --write-out "%{http_code}\n"\
+ --header "PRIVATE-TOKEN: $PRIVATE_TOKEN" \
+ --header "Content-Type: application/json" \
+ --data @release.json \
+ --request POST $API_ENDPOINT/projects/$PROJECT_ID/releases