Last active
February 10, 2021 14:21
-
-
Save davidB/0fe652acf9f6e560273541dd52774dbc to your computer and use it in GitHub Desktop.
a script to batch request sync from bintray/JCenter into maven central
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
#! /bin/bash | |
# | |
# for manual or api sync prerequirements are the same: | |
# - on oss sonatype: | |
# - having an account on https://issues.sonatype.org/ | |
# - being allowed to publish to the target groupId | |
# - check on that stagingProfiles includes the target groupId on https://oss.sonatype.org/#stagingProfiles (same user/password as on https://issues.sonatype.org/) that | |
# - on bintray | |
# - artifacts available on JCenter (request require manual approbation from bintray) | |
# - artifacts follow [requirements](http://central.sonatype.org/pages/requirements.html) | |
# | |
# | |
# manual sync: [Sync Artifacts from Bintray to Maven Central - IT Ops and Rel Eng Knowledge Base - LF Confluence](https://confluence.linuxfoundation.org/display/ITKB/Sync+Artifacts+from+Bintray+to+Maven+Central) | |
# api sync, you can use/adapt the following script (ref https://www.jfrog.com/confluence/display/BT/Bintray+REST+API) | |
# Rate-Limit: API queries are limited according to the following rules: Limits only apply to resources that do not belong to a user or to the organization the user is part of. The current limit per non-Premium user is 300 queries a day, and 1440 per month. | |
# | |
# usage: | |
# ```sh | |
# bash sonatypeUserToken=...sonatypePasswordToken=... bintrayUser=... bintrayApiKey=... ./bintray-sync.bash | |
# ``` | |
set -euo pipefail | |
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | |
subject=jmonkeyengine | |
repo=org.jmonkeyengine | |
# Create an account on then log in with the same account on | |
# | |
# Once Sonatype oss credentials have been set in subject "Accounts" tab, user can send this rest call without specifying username and password | |
# Sonatype OSS user token | |
sonatypeUserToken=${sonatypeUserToken:-davidb} | |
# Sonatype OSS user password | |
sonatypePasswordToken=${sonatypePasswordToken:-nopassword} | |
# Authentication | |
# The Bintray REST API requires an applicative API key. | |
# An API key can be obtained from the user profile page. | |
# Authentication is achieved using HTTP Basic Authentication with the user’s name as username and the API key as the password. | |
# Authenticated REST calls should only be used via HTTPs. | |
bintrayUser=${bintrayUser:-davidb} | |
bintrayApiKey=${bintrayApiKey:-nopassword} | |
cat >${DIR}/sync_body.json <<EOF | |
{ | |
"username": "${sonatypeUserToken}", | |
"password": "${sonatypePasswordToken}", | |
"close": "1" | |
} | |
EOF | |
versions=( | |
"3.3.2-stable" | |
) | |
# packages are sorted to publish dependencies first | |
# - got an issue with jme3-android, need to sync it manually (aka set close to 0 and use oss.sonatype.org to release) | |
# - lines inside array can be commented, is you want to sync only part of it | |
packages=( | |
"jme3-core" | |
"jme3-plugins" | |
"jme3-effects" | |
"jme3-networking" | |
"jme3-desktop" | |
"jme3-terrain" | |
"jme3-bullet" | |
"jme3-bullet-native" | |
"jme3-bullet-native-android" | |
"jme3-android-native" | |
"jme3-android" | |
"jme3-blender" | |
\ | |
"jme3-jogg" | |
"jme3-jogl" | |
"jme3-lwjgl" | |
"jme3-lwjgl3" | |
"jme3-niftygui" | |
"jme3-jbullet" | |
) | |
# To be synced to Maven Central your package needs to be included in the JCenter repository. | |
# else sync is `Forbidden!` | |
packages_not_sync=( | |
# not included into JCenter (request is not approved automatically) | |
# error when I try to request add to jcenter: `The version control scm:git:git://github.com/jMonkeyEngine/jmonkeyengine.git returns 404.` | |
"jme3-testdata" | |
"jme3-ios" | |
"jme3-vr" | |
# missing javadoc | |
"jme3-examples" | |
) | |
for version in "${versions[@]}"; do | |
for package in "${packages[@]}"; do | |
echo "request to sync ${repo}:${package}:${version}" | |
curl --user ${bintrayUser}:${bintrayApiKey} \ | |
-H "Content-Type: application/json" \ | |
-d @${DIR}/sync_body.json \ | |
-X POST "https://bintray.com/api/v1/maven_central_sync/${subject}/${repo}/${package}/versions/${version}" | |
echo "" | |
done | |
done | |
rm -f ${DIR}/sync_body.json | |
echo "update of https://repo1.maven.org/maven2/ need ~15 min" | |
echo "update of https://search.maven.org/ need ~2 hours" | |
echo "do not forgot to clean, to drop staging repository https://oss.sonatype.org/#stagingRepositories" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment