File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed
Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,36 @@ jobs:
135135 tag : ${{ github.ref }}
136136 overwrite : true
137137
138+ - name : Ensure app exists in Nextcloud appstore
139+ env :
140+ APPSTORE_TOKEN : ${{ secrets.APPSTORE_TOKEN }}
141+ APP_PRIVATE_KEY : ${{ secrets.APP_PRIVATE_KEY }}
142+ run : |
143+ APPSTORE_TOKEN="$(printf '%s' "$APPSTORE_TOKEN" | tr -d '\r\n')"
144+ KEY_FILE="$RUNNER_TEMP/${{ env.APP_NAME }}.key"
145+ CERT_FILE="$RUNNER_TEMP/${{ env.APP_NAME }}.crt"
146+ RESPONSE_FILE="$RUNNER_TEMP/appstore-register-response.json"
147+
148+ printf '%s' "$APP_PRIVATE_KEY" > "$KEY_FILE"
149+ curl -fsSL "https://raw.githubusercontent.com/nextcloud/app-certificate-requests/master/${{ env.APP_NAME }}/${{ env.APP_NAME }}.crt" -o "$CERT_FILE"
150+
151+ REGISTER_SIGNATURE="$(printf '%s' '${{ env.APP_NAME }}' | openssl dgst -sha512 -sign "$KEY_FILE" | openssl base64 -A)"
152+ CERT_CONTENT="$(cat "$CERT_FILE")"
153+ PAYLOAD="$(jq -nc --arg certificate "$CERT_CONTENT" --arg signature "$REGISTER_SIGNATURE" '{certificate:$certificate, signature:$signature}')"
154+
155+ HTTP_STATUS="$(curl -sS -o "$RESPONSE_FILE" -w '%{http_code}' -X POST https://apps.nextcloud.com/api/v1/apps \
156+ -H "Authorization: Token ${APPSTORE_TOKEN}" \
157+ -H 'Content-Type: application/json' \
158+ --data "$PAYLOAD")"
159+
160+ echo "App registration status: $HTTP_STATUS"
161+ cat "$RESPONSE_FILE"
162+
163+ if [ "$HTTP_STATUS" != "201" ] && [ "$HTTP_STATUS" != "204" ]; then
164+ echo "::error::App registration failed with HTTP $HTTP_STATUS"
165+ exit 1
166+ fi
167+
138168 - name : Upload app to Nextcloud appstore
139169 env :
140170 APPSTORE_TOKEN : ${{ secrets.APPSTORE_TOKEN }}
Original file line number Diff line number Diff line change @@ -229,6 +229,36 @@ jobs:
229229 tag : ${{ steps.version.outputs.tag }}
230230 overwrite : true
231231
232+ - name : Ensure app exists in Nextcloud appstore
233+ env :
234+ APPSTORE_TOKEN : ${{ secrets.APPSTORE_TOKEN }}
235+ APP_PRIVATE_KEY : ${{ secrets.APP_PRIVATE_KEY }}
236+ run : |
237+ APPSTORE_TOKEN="$(printf '%s' "$APPSTORE_TOKEN" | tr -d '\r\n')"
238+ KEY_FILE="$RUNNER_TEMP/${{ env.APP_NAME }}.key"
239+ CERT_FILE="$RUNNER_TEMP/${{ env.APP_NAME }}.crt"
240+ RESPONSE_FILE="$RUNNER_TEMP/appstore-register-response.json"
241+
242+ printf '%s' "$APP_PRIVATE_KEY" > "$KEY_FILE"
243+ curl -fsSL "https://raw.githubusercontent.com/nextcloud/app-certificate-requests/master/${{ env.APP_NAME }}/${{ env.APP_NAME }}.crt" -o "$CERT_FILE"
244+
245+ REGISTER_SIGNATURE="$(printf '%s' '${{ env.APP_NAME }}' | openssl dgst -sha512 -sign "$KEY_FILE" | openssl base64 -A)"
246+ CERT_CONTENT="$(cat "$CERT_FILE")"
247+ PAYLOAD="$(jq -nc --arg certificate "$CERT_CONTENT" --arg signature "$REGISTER_SIGNATURE" '{certificate:$certificate, signature:$signature}')"
248+
249+ HTTP_STATUS="$(curl -sS -o "$RESPONSE_FILE" -w '%{http_code}' -X POST https://apps.nextcloud.com/api/v1/apps \
250+ -H "Authorization: Token ${APPSTORE_TOKEN}" \
251+ -H 'Content-Type: application/json' \
252+ --data "$PAYLOAD")"
253+
254+ echo "App registration status: $HTTP_STATUS"
255+ cat "$RESPONSE_FILE"
256+
257+ if [ "$HTTP_STATUS" != "201" ] && [ "$HTTP_STATUS" != "204" ]; then
258+ echo "::error::App registration failed with HTTP $HTTP_STATUS"
259+ exit 1
260+ fi
261+
232262 - name : Upload app to Nextcloud appstore (nightly)
233263 env :
234264 APPSTORE_TOKEN : ${{ secrets.APPSTORE_TOKEN }}
You can’t perform that action at this time.
0 commit comments