Skip to content

Instantly share code, notes, and snippets.

@dhei
Last active February 10, 2022 07:50
Show Gist options
  • Save dhei/38cbc9b79f5f442d0d2f11106a76662d to your computer and use it in GitHub Desktop.
Save dhei/38cbc9b79f5f442d0d2f11106a76662d to your computer and use it in GitHub Desktop.
Use environment variables and local.properties to store Bintray publishing secrets

TL;DR

Store bintray secrets in local.properties, so that they can be used later in publish.gradle for publishing to bintray.

Steps

  1. export bintray secrets as environment variables:
  • $BINTRAY_USER
  • $BINTRAY_KEY
  • $BINTRAY_USER_ORG
  • $BINTRAY_REPO
  1. put bintray secrets into local.properties:
./store-bintray-secrets-in-local-properties.sh
  1. publish your package to bintray:

from terminal:

sudo ./gradlew install
sudo ./gradlew bintrayUpload

from Bitrise using gradle-runner plugin:

inputs:
        - gradle_file: ./build.gradle
        - gradle_task: bintrayUpload
        - gradlew_path: ./gradlew
        - mapping_file_exclude_filter: ''

PS: see Gradle Bintray Plugin for how to publish to bintray

allprojects {
bintray {
user = bintrayUser
key = bintrayKey
configurations = ['archives']
publish = true
pkg {
repo = bintrayRepo
name = "your-package-name"
userOrg = bintrayUserOrg
vcsUrl = gitUrl
websiteUrl = siteUrl
licenses = "your-license"
}
}
}
ext {
siteUrl = '... ...'
gitUrl = '... ...'
groupId = '... ...'
sdkDescription = '... ...'
Properties properties = new Properties()
File file = rootProject.file('local.properties')
if (file.exists()) {
properties.load(file.newDataInputStream())
}
bintrayUser = properties.getProperty("bintray.user")
bintrayKey = properties.getProperty("bintray.key")
bintrayUserOrg = properties.getProperty("bintray.user.org")
bintrayRepo = properties.getProperty("bintray.repo")
licenseName = 'The MIT License (MIT)'
licenseSite = 'https://opensource.org/licenses/MIT'
licenseCode = 'MIT'
developerId = '... ...'
developerName = '... ...'
developerEmail = '... ...'
}
set -e
echo "bintray.user=$BINTRAY_USER" > local.properties
echo "bintray.key=$BINTRAY_KEY" >> local.properties
echo "bintray.user.org=$BINTRAY_USER_ORG" >> local.properties
echo "bintray.repo=$BINTRAY_REPO" >> local.properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment