mirror of
https://github.com/ovh/php-ovh.git
synced 2023-11-05 03:20:26 +01:00
Merge pull request #45 from ovh/jt-script
script: update release script
This commit is contained in:
commit
1753296cce
0
scripts/bump-version.sh
Normal file → Executable file
0
scripts/bump-version.sh
Normal file → Executable file
@ -10,49 +10,109 @@ VERSION="$1"
|
|||||||
USER="$2"
|
USER="$2"
|
||||||
TOKEN="$3"
|
TOKEN="$3"
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
echo "Usage: $0 <version> <githubUser> <githubToken>"
|
||||||
|
echo "Hint: "
|
||||||
|
echo " - Make sure there is outstanding changes in the current directory"
|
||||||
|
echo " - Make sure the requested version does not exist yet"
|
||||||
|
echo " - You may visit https://help.github.com/articles/creating-an-access-token-for-command-line-use/ to generate your Github Token"
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Validate input
|
||||||
|
#
|
||||||
|
|
||||||
if [ -z "$VERSION" ];
|
if [ -z "$VERSION" ];
|
||||||
then
|
then
|
||||||
echo "Missing version" >&2
|
echo "Missing version" >&2
|
||||||
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$USER" ];
|
if [ -z "$USER" ];
|
||||||
then
|
then
|
||||||
echo "Missing github user" >&2
|
echo "Missing github user" >&2
|
||||||
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$TOKEN" ];
|
if [ -z "$TOKEN" ];
|
||||||
then
|
then
|
||||||
echo "Missing github token" >&2
|
echo "Missing github token" >&2
|
||||||
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Validate repository
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ -n "$(git status --porcelain)" ]
|
||||||
|
then
|
||||||
|
echo "Working repository is not clean. Please commit or stage any pending changes." >&2
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
CURRENTTAG=$(git describe --tag --exact-match 2>/dev/null || echo "")
|
||||||
|
if [ "${CURRENTTAG}" != "${VERSION}" ]
|
||||||
|
then
|
||||||
|
if [ -n "${CURRENTTAG}" ]
|
||||||
|
then
|
||||||
|
echo "The current commit is already tagged with ${CURRENTTAG} which is not the requested release ${VERSION}" >&2
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if git rev-parse refs/tags/${VERSION} &>/dev/null
|
||||||
|
then
|
||||||
|
echo "The requested version ${VERSION} already exists" >&2
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Release
|
||||||
|
#
|
||||||
|
|
||||||
|
PROJECT_NAME=$(git remote -v | grep 'github.*push' | awk '{split($2, a, "/"); split(a[2], b, "."); print b[1]}')
|
||||||
|
echo "Releasing ${PROJECT_NAME} version ${VERSION}..."
|
||||||
|
|
||||||
|
git tag -m "Releasing ${PROJECT_NAME} version ${VERSION}" "${VERSION}"
|
||||||
|
git push --tags
|
||||||
|
git push
|
||||||
|
|
||||||
cd /tmp
|
cd /tmp
|
||||||
mkdir -p php-ovh-bin
|
mkdir -p ${PROJECT_NAME}-bin
|
||||||
cd php-ovh-bin
|
cd ${PROJECT_NAME}-bin
|
||||||
|
|
||||||
curl -sS https://getcomposer.org/installer | php
|
curl -sS https://getcomposer.org/installer | php
|
||||||
|
|
||||||
echo '{
|
# FIXME: this will require the release to already be uploaded on packagist.org
|
||||||
|
cat > composer.json << EOF
|
||||||
|
{
|
||||||
"name": "Example Application",
|
"name": "Example Application",
|
||||||
"description": "This is an example of OVH APIs wrapper usage",
|
"description": "This is an example of OVH APIs wrapper usage",
|
||||||
"require": {
|
"require": {
|
||||||
"ovh/ovh": "2.x"
|
"ovh/ovh": "${VERSION}"
|
||||||
}
|
}
|
||||||
}' > composer.json
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
php composer.phar install
|
php composer.phar install
|
||||||
|
|
||||||
echo '<?php
|
cat > script.php << EOF
|
||||||
|
<?php
|
||||||
require __DIR__ . "/vendor/autoload.php";
|
require __DIR__ . "/vendor/autoload.php";
|
||||||
use \Ovh\Api;
|
use \Ovh\Api;
|
||||||
|
|
||||||
// Informations about your application
|
// Informations about your application
|
||||||
|
// You may create new credentials on https://api.ovh.com/createToken/index.cgi
|
||||||
$applicationKey = "your_app_key";
|
$applicationKey = "your_app_key";
|
||||||
$applicationSecret = "your_app_secret";
|
$applicationSecret = "your_app_secret";
|
||||||
$consumer_key = "your_consumer_key";
|
$consumer_key = "your_consumer_key";
|
||||||
$endpoint = 'ovh-eu';
|
$endpoint = "ovh-eu";
|
||||||
|
|
||||||
// Get servers list
|
// Get servers list
|
||||||
$conn = new Api( $applicationKey,
|
$conn = new Api( $applicationKey,
|
||||||
@ -67,14 +127,17 @@ try {
|
|||||||
|
|
||||||
} catch ( Exception $ex ) {
|
} catch ( Exception $ex ) {
|
||||||
print_r( $ex->getMessage() );
|
print_r( $ex->getMessage() );
|
||||||
}' > script.php
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
zip -r php-ovh-$VERSION-with-dependencies.zip .
|
|
||||||
|
|
||||||
ID=$(curl https://api.github.com/repos/ovh/php-ovh/releases/tags/v$VERSION -u $USER:$TOKEN | jq -r '.id')
|
ID=$(curl https://api.github.com/repos/ovh/${PROJECT_NAME}/releases/tags/v${VERSION} -u "${USER}:${TOKEN}" | jq -r '.id')
|
||||||
|
|
||||||
curl -X POST -d @php-ovh-$VERSION-with-dependencies.zip -H "Content-Type: application/zip" https://uploads.github.com/repos/ovh/php-ovh/releases/$ID/assets?name=php-ovh-$VERSION-with-dependencies.zip -i -u $USER:$TOKEN
|
zip -r ${PROJECT_NAME}-${VERSION}-with-dependencies.zip .
|
||||||
rm php-ovh-$VERSION-with-dependencies.zip
|
curl -X POST -d @${PROJECT_NAME}-${VERSION}-with-dependencies.zip -H "Content-Type: application/zip" "https://uploads.github.com/repos/ovh/${PROJECT_NAME}/releases/${ID}/assets?name=${PROJECT_NAME}-${VERSION}-with-dependencies.zip" -i -u "${USER}:${TOKEN}"
|
||||||
|
rm ${PROJECT_NAME}-${VERSION}-with-dependencies.zip
|
||||||
|
|
||||||
|
tar -czf ${PROJECT_NAME}-${VERSION}-with-dependencies.tar.gz .
|
||||||
|
curl -X POST -d @${PROJECT_NAME}-${VERSION}-with-dependencies.tar.gz -H "Content-Type: application/gzip" "https://uploads.github.com/repos/ovh/${PROJECT_NAME}/releases/${ID}/assets?name=${PROJECT_NAME}-${VERSION}-with-dependencies.tar.gz" -i -u "${USER}:${TOKEN}"
|
||||||
|
rm -f ${PROJECT_NAME}-${VERSION}-with-dependencies.tar.gz
|
||||||
|
|
||||||
tar -czf php-ovh-$VERSION-with-dependencies.tar.gz .
|
|
||||||
curl -X POST -d @php-ovh-$VERSION-with-dependencies.tar.gz -H "Content-Type: application/zip" https://uploads.github.com/repos/ovh/php-ovh/releases/$ID/assets?name=php-ovh-$VERSION-with-dependencies.tar.gz -i -u $USER:$TOKEN
|
|
||||||
|
Loading…
Reference in New Issue
Block a user