Skip to content

Instantly share code, notes, and snippets.

@hgomez
Last active March 24, 2017 08:58
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save hgomez/4447779 to your computer and use it in GitHub Desktop.
Save hgomez/4447779 to your computer and use it in GitHub Desktop.
Sample script to upload RPM package to bintray
#!/bin/sh
#
# You should define BINTRAY_ACCOUNT and BINTRAY_APIKEY here or from the outside
# BINTRAY_ACCOUNT is you Bintray account and BINTRAY_APIKEY, API Key generated under your Bintray profile
# Redefine following variables to match your own usage
RPMS_DIR=RPMS/noarch
BINTRAY_ACCOUNT=hgomez
BINTRAY_REPO=devops-incubator-rpm
BASE_DESC=https://github.com/hgomez/devops-incubator/tree/master/rpm-packaging
for RPM_FILE in $RPMS_DIR/*.rpm; do
RPM_NAME=`rpm --queryformat "%{NAME}" -qp $RPM_FILE`
RPM_VERSION=`rpm --queryformat "%{VERSION}" -qp $RPM_FILE`
RPM_RELEASE=`rpm --queryformat "%{RELEASE}" -qp $RPM_FILE`
RPM_ARCH=`rpm --queryformat "%{ARCH}" -qp $RPM_FILE`
echo "RPM_NAME=$RPM_NAME, RPM_VERSION=$RPM_VERSION, RPM_RELEASE=$RPM_RELEASE, RPM_ARCH=$RPM_ARCH"
echo "@@@@@@@@@@@@@@@@@@@@@@"
echo "@@@ create package @@@"
echo "@@@@@@@@@@@@@@@@@@@@@@"
curl -vvf -u$BINTRAY_USER:$BINTRAY_APIKEY -H "Content-Type: application/json" -X POST https://api.bintray.com/packages/$BINTRAY_ACCOUNT/$BINTRAY_REPO/ --data "{ \"name\": \"$RPM_NAME\", \"desc\": \"auto\", \"desc_url\": \"$BASE_DESC/$RPM_NAME\", \"labels\": \"\" }"
echo "@@@@@@@@@@@@@@@@@@@@@@"
echo "@@@ delete version @@@"
echo "@@@@@@@@@@@@@@@@@@@@@@"
curl -vvf -u$BINTRAY_USER:$BINTRAY_APIKEY -X DELETE https://api.bintray.com/packages/$BINTRAY_ACCOUNT/$BINTRAY_REPO/$RPM_NAME/versions/$RPM_VERSION-$RPM_RELEASE
echo "@@@@@@@@@@@@@@@@@@@@@@"
echo "@@@ create version @@@"
echo "@@@@@@@@@@@@@@@@@@@@@@"
curl -vvf -u$BINTRAY_USER:$BINTRAY_APIKEY -H "Content-Type: application/json" -X POST https://api.bintray.com/packages/$BINTRAY_ACCOUNT/$BINTRAY_REPO/$RPM_NAME/versions --data "{ \"name\": \"$RPM_VERSION-$RPM_RELEASE\", \"release_notes\": \"auto\", \"release_url\": \"$BASE_DESC/$RPM_NAME\", \"released\": \"\" }"
echo "@@@@@@@@@@@@@@@@@@@@@@"
echo "@@@ upload content @@@"
echo "@@@@@@@@@@@@@@@@@@@@@@"
# curl -vvf -T $RPM_FILE -u$BINTRAY_USER:$BINTRAY_APIKEY -H "X-Bintray-Package:$RPM_NAME" -H "X-Bintray-Version:$RPM_VERSION-$RPM_RELEASE" https://api.bintray.com/content/$BINTRAY_ACCOUNT/$BINTRAY_REPO/$RPM_NAME-$RPM_VERSION-$RPM_RELEASE.$RPM_ARCH.rpm
curl -vvf -T $RPM_FILE -u$BINTRAY_USER:$BINTRAY_APIKEY -H "X-Bintray-Package:$RPM_NAME" -H "X-Bintray-Version:$RPM_VERSION-$RPM_RELEASE" https://api.bintray.com/content/$BINTRAY_ACCOUNT/$BINTRAY_REPO/
echo "@@@@@@@@@@@@@@@@@@@@@@@"
echo "@@@ publish content @@@"
echo "@@@@@@@@@@@@@@@@@@@@@@@"
curl -vvf -u$BINTRAY_USER:$BINTRAY_APIKEY -H "Content-Type: application/json" -X POST https://api.bintray.com/content/$BINTRAY_ACCOUNT/$BINTRAY_REPO/$RPM_NAME/$RPM_VERSION-$RPM_RELEASE/publish --data "{ \"discard\": \"false\" }"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment