-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update tags automatically * Allow username + password for NC appstore authentication (#3) * Add username pw auth and tests * Curl fail on non 200 * Fail script on error * Try fix function not found error * Source * Basics for testing * Add more tests * Update readme (username + password)
- Loading branch information
Showing
14 changed files
with
691 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Run tests | ||
|
||
on: | ||
pull_request: | ||
push: | ||
|
||
jobs: | ||
runtests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Install test environment | ||
run: sudo apt-get update && sudo apt-get -y install bats nodejs npm | ||
- name: Install node dependencies | ||
run: cd test && npm install | ||
- name: Run tests | ||
run: cd test && chmod +x run_tests.sh && ./run_tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test/node_modules | ||
test/test_app.tar.gz | ||
test/server_output.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
# $1 = private key file | ||
# $2 = app tar file | ||
function createsign { | ||
echo "`openssl dgst -sha512 -sign $1 $2 | openssl base64 -A`" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,37 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
# Used environment-variables: | ||
# APP_NAME | ||
# APPSTORE_TOKEN | ||
# APPSTORE_USERNAME | ||
# APPSTORE_PASSWORD | ||
# NIGHTLY | ||
# DOWNLOAD_URL | ||
# APP_PRIVATE_KEY_FILE | ||
|
||
script_dir="$(dirname "$0")" | ||
appstore_url=$APPSTORE_URL || "https://apps.nextcloud.com/api/v1/apps/releases" | ||
|
||
. "${script_dir}/functions.sh" | ||
|
||
echo "Downloading app tarball for signing" | ||
wget "$DOWNLOAD_URL" -O "${APP_NAME}.tar.gz" | ||
|
||
echo "Creating signature for app release" | ||
sign="`openssl dgst -sha512 -sign ${APP_PRIVATE_KEY_FILE} ${APP_NAME}.tar.gz | openssl base64 -A`" | ||
sign="`createsign ${APP_PRIVATE_KEY_FILE} ${APP_NAME}.tar.gz`" | ||
|
||
echo "Creating new app release in Nextcloud appstore (nightly=${NIGHTLY})" | ||
curl -X POST https://apps.nextcloud.com/api/v1/apps/releases -H "Authorization: Token ${APPSTORE_TOKEN}" -H "Content-Type: application/json" -d "{\"download\":\"${DOWNLOAD_URL}\", \"signature\": \"${sign}\", \"nightly\": ${NIGHTLY} }" | ||
|
||
if [ ! -z $APPSTORE_TOKEN ] | ||
then | ||
echo "Using token authentication" | ||
curl -s --fail --show-error -X POST $appstore_url -H "Authorization: Token ${APPSTORE_TOKEN}" -H "Content-Type: application/json" -d "{\"download\": \"${DOWNLOAD_URL}\", \"signature\": \"${sign}\", \"nightly\": ${NIGHTLY} }" | ||
elif [ ! -z $APPSTORE_USERNAME ] && [ ! -z $APPSTORE_PASSWORD ] | ||
then | ||
echo "Using username password authentication" | ||
curl -s --fail --show-error -X POST $appstore_url -u "${APPSTORE_USERNAME}:${APPSTORE_PASSWORD}" -H "Content-Type: application/json" -d "{\"download\": \"${DOWNLOAD_URL}\", \"signature\": \"${sign}\", \"nightly\": ${NIGHTLY} }" | ||
else | ||
echo "Authentication cannot be done. Please provide 'appstore_token' or 'appstore_username' and 'appstore_password' input variables." | ||
exit 1 | ||
fi |
Oops, something went wrong.