summary refs log tree commit diff
path: root/.ci
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2020-03-02 08:42:01 +0000
committerGitHub <noreply@github.com>2020-03-02 08:42:01 +0000
commit1a2b8b7a6b7aa57aafeb3e004c1a449443e511e3 (patch)
tree3f73b78f1169c868c2dfa8b99115706e821fcdfe /.ci
parentMerge pull request #130 from Nheko-Reborn/0.7.0-dev (diff)
downloadnheko-1a2b8b7a6b7aa57aafeb3e004c1a449443e511e3.tar.xz
Upload nightlies to #nheko-nightlies:neko.dev (#132)
* Upload nightlies to a matrix room

* Add branch to upload name

* Update README with new nightly location
Diffstat (limited to '.ci')
-rw-r--r--.ci/upload-nightly.ps121
-rwxr-xr-x.ci/upload-nightly.sh9
2 files changed, 30 insertions, 0 deletions
diff --git a/.ci/upload-nightly.ps1 b/.ci/upload-nightly.ps1
new file mode 100644
index 00000000..9c1c33c3
--- /dev/null
+++ b/.ci/upload-nightly.ps1
@@ -0,0 +1,21 @@
+$file = "nheko_win_64.zip"

+$fileName = "nheko-${env:APPVEYOR_REPO_BRANCH}-${env:APPVEYOR_REPO_COMMIT}-win64.zip"

+

+$response = Invoke-RestMethod -uri "https://matrix.neko.dev/_matrix/media/r0/upload?filename=$fileName" -Method Post -Infile "$file" -ContentType 'application/x-compressed' -Headers @{"Authorization"="Bearer ${env:MATRIX_ACCESS_TOKEN}"}

+

+$txId = [DateTimeOffset]::Now.ToUnixTimeSeconds()

+$fileSize = (Get-Item $file).Length

+$body = @{

+  "body" = "${fileName}"

+  "filename"= "${fileName}"

+  "info" = @{

+    "mimetype" = "application/x-compressed"

+    "size" = ${fileSize}

+  }

+  "msgtype" = "m.file"

+  "url" = ${response}.content_uri

+} | ConvertTo-Json

+$room = "!TshDrgpBNBDmfDeEGN:neko.dev"

+

+Invoke-RestMethod -uri "https://matrix.neko.dev/_matrix/client/r0/rooms/${room}/send/m.room.message/${txid}" -Method Put -Body "$body" -ContentType 'application/json' -Headers @{"Authorization"="Bearer ${env:MATRIX_ACCESS_TOKEN}"}

+

diff --git a/.ci/upload-nightly.sh b/.ci/upload-nightly.sh
new file mode 100755
index 00000000..4251655a
--- /dev/null
+++ b/.ci/upload-nightly.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+file=$(find artifacts/ -type f -exec basename {} \;)
+fileName="nheko-${TRAVIS_BRANCH}-${file#nheko-}"
+
+uri=$(curl -H "Authorization: Bearer ${MATRIX_ACCESS_TOKEN}" -H "Content-Type: application/x-compressed" -X POST --data-binary "@artifacts/${file}" "https://matrix.neko.dev/_matrix/media/r0/upload?filename=${fileName}"  --http1.1 | python -c "import sys, json; print(json.load(sys.stdin)['content_uri'])")
+echo "Uploaded to ${uri}"
+
+curl -H "Authorization: Bearer ${MATRIX_ACCESS_TOKEN}" -H "Content-Type: application/json" -X PUT -d "{ \"body\": \"${fileName}\", \"filename\": \"${fileName}\", \"info\": { \"mimetype\": \"application/x-compressed\", \"size\": $(wc -c < artifacts/${file}) }, \"msgtype\": \"m.file\", \"url\": \"${uri}\" }" "https://matrix.neko.dev/_matrix/client/r0/rooms/${ROOM}/send/m.room.message/$(date +%s)"