summary refs log tree commit diff
path: root/.ci
diff options
context:
space:
mode:
authorJoseph Donofry <rubberduckie3554@gmail.com>2023-02-28 22:50:13 +0000
committerGitHub <noreply@github.com>2023-02-28 22:50:13 +0000
commit9bc50fa9080ffa561627b12824166d4a1f93554d (patch)
tree0a51b6921244cead8ca3c8f3af543aad72cc2c59 /.ci
parentFix bug that prevented storing member events in the same database as the rest (diff)
parentRemove test configurations (diff)
downloadnheko-9bc50fa9080ffa561627b12824166d4a1f93554d.tar.xz
Merge pull request #1382 from Nheko-Reborn/gitlab_artifact_updates
Create github release from tags and upload artifacts as assets
Diffstat (limited to '.ci')
-rwxr-xr-x.ci/macos/notarize.sh6
-rwxr-xr-x.ci/update-github-release.sh67
2 files changed, 70 insertions, 3 deletions
diff --git a/.ci/macos/notarize.sh b/.ci/macos/notarize.sh
index 2757d44c..345f4828 100755
--- a/.ci/macos/notarize.sh
+++ b/.ci/macos/notarize.sh
@@ -97,7 +97,7 @@ done
 VERSION=${CI_COMMIT_SHORT_SHA}
 
 if [ -n "$VERSION" ]; then
-    mv nheko.dmg "nheko-${VERSION}_${PLAT}.dmg"
-    mkdir artifacts
-    cp "nheko-${VERSION}_${PLAT}.dmg" artifacts/
+    mv nheko.dmg "nheko-${VERSION}-${PLAT}.dmg"
+    mkdir -p artifacts
+    cp "nheko-${VERSION}-${PLAT}.dmg" artifacts/
 fi
\ No newline at end of file
diff --git a/.ci/update-github-release.sh b/.ci/update-github-release.sh
new file mode 100755
index 00000000..234c1f41
--- /dev/null
+++ b/.ci/update-github-release.sh
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+if [ -z "$CI_COMMIT_TAG" ]; then
+    echo "CI_COMMIT_TAG is unset or empty; exiting"
+    exit 1
+fi
+
+echo "Checking if release exists for ${CI_COMMIT_TAG}"
+# check if we already have a release for the current tag or not
+http_code=$(curl \
+  -s \
+  -o /dev/null \
+  -I \
+  -w "%{http_code}" \
+  -H "Accept: application/vnd.github+json" \
+  -H "Authorization: Bearer ${GITHUB_AUTH_TOKEN}"\
+  -H "X-GitHub-Api-Version: 2022-11-28" \
+  "https://api.github.com/repos/Nheko-Reborn/nheko/releases/tags/$CI_COMMIT_TAG")
+
+if [ "$http_code" = "404" ]; then
+    echo "Release does not exist... getting notes from CHANGELOG.md:"
+    release_notes="$(perl -0777 -ne '/.*?(## .*?)\n(## |\Z)/s && print $1' CHANGELOG.md | jq -R -s '.')"
+    echo "$release_notes"
+
+    echo "Creating new release for ${CI_COMMIT_TAG}"
+    # Doing a 'fresh' release, not just updating the assets.
+    release_json="$(curl \
+        -X POST \
+        -H "Accept: application/vnd.github+json" \
+        -H "Authorization: Bearer ${GITHUB_AUTH_TOKEN}"\
+        -H "X-GitHub-Api-Version: 2022-11-28" \
+        https://api.github.com/repos/Nheko-Reborn/nheko/releases \
+        -d "{\"tag_name\":\"${CI_COMMIT_TAG}\",\"target_commitish\":\"master\",\"name\":\"${CI_COMMIT_TAG}\",\"body\":${release_notes},\"draft\":true,\"prerelease\":true,\"generate_release_notes\":false}")"
+elif [ "$http_code" = "200" ]; then
+    echo "Release already exists for ${CI_COMMIT_TAG}; Updating"
+    # Updating a release (probably because of cirrus-ci or so)
+    release_json=$(curl \
+        -s \
+        -H "Accept: application/vnd.github+json" \
+        -H "Authorization: Bearer ${GITHUB_AUTH_TOKEN}"\
+        -H "X-GitHub-Api-Version: 2022-11-28" \
+        "https://api.github.com/repos/Nheko-Reborn/nheko/releases/tags/$CI_COMMIT_TAG")
+fi
+
+echo "Getting upload URL..."
+upload_url="$(echo "$release_json" | jq -r '."upload_url"')"
+# get rid of the 'hypermedia' stuff at the end and use a 'real' URL
+echo "Upload URL (hypermedia): ${upload_url}"
+upload_url="$(echo "$upload_url" | sed 's/{?name,label\}/?name/g')"
+
+ls -la .
+echo "Uploading artifacts"
+for file in ./artifacts/*; do
+    name="${file##*/}"
+    echo "Uploading $file"
+    [ -e "$file" ] && curl \
+    -X POST \
+    -H "Accept: application/vnd.github+json" \
+    -H "Authorization: Bearer ${GITHUB_AUTH_TOKEN}"\
+    -H "X-GitHub-Api-Version: 2022-11-28" \
+    -H "Content-Type: application/octet-stream" \
+    "${upload_url}=$name" \
+    --data-binary "@$file"
+done
+
+
+# TODO: AppVeyor stuffs?
\ No newline at end of file