-
-
Save sstone/e3b7aa3284a6ae57e5bb65bd59406ffc to your computer and use it in GitHub Desktop.
Sonatype: create a staging repository and pass it as a Github Action output.
This file contains hidden or 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
#!/usr/bin/env bash | |
username= | |
password= | |
profileId= | |
description="Creating staging repository." | |
while [ "$1" != "" ]; do | |
case $1 in | |
-u | --username) | |
shift | |
username="$1" | |
;; | |
-p | --password) | |
shift | |
password="$1" | |
;; | |
-id | --profileId) | |
shift | |
profileId="$1" | |
;; | |
-d | --description) | |
shift | |
description="$1" | |
;; | |
*) | |
echo "Unknown command $1" | |
exit 1 | |
;; | |
esac | |
shift | |
done | |
if test -z "$username" || test -z "$password" || test -z "$profileId" | |
then | |
echo "Missing parameter(s) for sonatype 'username' | 'password' | 'profileId'." | |
exit 1 | |
fi | |
jsonOutput=$( | |
curl -s --request POST -u "$username:$password" \ | |
--url https://oss.sonatype.org/service/local/staging/profiles/"$profileId"/start \ | |
--header 'Accept: application/json' \ | |
--header 'Content-Type: application/json' \ | |
--data '{ "data": {"description" : "'"$description"'"} }' | |
) | |
stagedRepositoryId=$(echo "$jsonOutput" | jq -r '.data.stagedRepositoryId') | |
if [ -z "$stagedRepositoryId" ]; then | |
echo "Error while creating the staging repository." | |
exit 1 | |
else | |
echo "::set-output name=repository-id::$stagedRepositoryId" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment