The purpose of this plugin is to remove the deploy.gradle and deploy.aar.gradle copied files from our internal libraries and instead have one plugin which can be updated and fixes can be in place more quickly
- add your github access to your global .bash_profile or gradle properties GITHUB_USERNAME, GITHUB_TOKEN
file: $HOME/.bash_profile
#..
export GITHUB_USERNAME="yourUserName"
export GITHUB_TOKEN="yourToken" # can be generated in GitHub / settings / developer settings / Personal Access Token / Generate new token. and check read packages
# see: https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token
#..
- in your top-level build.gradle add the following setup to access halcyon gradle plugins and add the publish plugin:
buildscript {
/* ... */
repositories {
/* ... */
maven { url "https://plugins.gradle.org/m2/" }
maven {
url "https://maven.pkg.github.com/halcyonmobile/halcyon-custom-gradle-publish-plugin"
credentials {
username = project.findProperty("GITHUB_USERNAME") ?: System.getenv("GITHUB_USERNAME")
password = project.findProperty("GITHUB_TOKEN") ?: System.getenv("GITHUB_TOKEN")
}
// https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token
}
}
dependencies {
/* ... */
classpath 'com.halcyonmobile.publish.custom:java-and-aar:<latest_version>'
}
}
- Create a new file deploy.gradle looking something like this:
project.ext.set("libraryGroupId","example-library-group-id") // the dependency will result in something like implementation "com.halcyonmobile.<example-library-group-id>:<example-library-artifact-id>:<0.1.0.2>"
project.ext.set("libraryVersion","0.1.0.2")
project.ext.set("githubPackagePath","halcyonmobile/halcyon-custom-gradle-publish-plugin") // this is the path of the github package, comes from "https://github.com/halcyonmobile/halcyon-custom-gradle-publish-plugin/"
- Add the new file to your top-leve build.gradle at the end
/*...*/
apply from: "./deploy.gradle"
- In your modules you want to publish add the following lines to the end of the build.gradle:
project.ext.set("libraryArtifactId", "example-library-artifact-id")
apply plugin: 'com.halcyonmobile.plugin.publish.custom.jar-library' // or aar-library if it's an android module
And that's it now you can publish via ./gradlew publishtoGitHub
Artfactory and Bintray are deprecated, kept only for reference: ./gradlew publishToArtifactory
, ./gradlew publishToBintray,
You can also get help with ./gradlew howToPublish
As mentioned above, you will need to add the credentials to the .bash_profile and in the top level gradle file.
Additionally you can generate a workflow for GitHub which automatically publishes a package, when you create a new release on the GitHub website:
- Configure the project as for releasing to GitHub
./gradlew generatePublishScriptForGitHubActions
- verify the file is generated under project/.github/workflows/release-package.yml and don't forget to add it to git.
Now whenever you create a Release on GitHub website this action will create a new package.
For help run ./gradlew howToIntegrateGitHubActions
This project uses it's previous version to publish itself to GitHub Packages, so the project's build.gradle and self-deploy.gradle is in itself an example.
Copyright (c) 2020 Halcyon Mobile.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.