The Gradle GitHub Release Plugin is a Gradle plugin that automates the process of creating GitHub releases for your projects. With this plugin, you can simplify the release management process and ensure that your project releases are well-documented on GitHub.
- Automatic creation of GitHub releases based on Gradle tasks.
- Customizable release notes and release assets.
- Integration with your GitHub repository.
- Configuration compatible with the com.github.breadmoirai.github-release plugin
Before using this plugin, you should have the following prerequisites:
- A Gradle-based project.
- A GitHub repository for your project.
To use the Gradle GitHub Release Plugin, add the following to your project's build.gradle file:
plugins {
id 'com.fizzpod.github-release' version 'VERSION'
}You can replace VERSION with the desired version of the plugin.
To configure the plugin, you can add the following block to your build.gradle file:
githubRelease {
token = 'YOUR_GITHUB_PERSONAL_ACCESS_TOKEN'
repo = 'YOUR_GITHUB_REPOSITORY'
tagName = 'v1.0.0'
releaseName = 'Release 1.0.0'
generateReleaseNotes = true
releaseAssets { ->
jar.outputs.files
}
}- token (required): Your GitHub personal access token with repo and write:packages scopes.
- authorization (optional): An alias to
token. Iftokenis specified then that overrides theauthorizationvalue - login (optional): Username of the for the login to use for authentication that requires a user
- github (optional): Closure to create the
org.kohsuke.github.api.GitHubobject used for the connection, if specified it overrides anytoken/authorization/loginvalues - repo (optional): Your GitHub repository in the format username/repository. Automatically detected from the remote URL.
- owner (optional): Github repository owner. Automatically detected from the remote URL.
- releaseName (required): The name of the release
- targetCommitish (optional): Branch name. Defaults to current branch.
- generateReleaseNotes (optional): Automatically generate release notes using the github API
- body (optional): The release note
- draft (optional): Draft github release. Defaults to
true. - prerelease (optional): Prerelease flag. Defaults to
false - releaseAssets (optional): A list of files to include as release assets.
- allowUploadToExisting (optional): Allows upload to an existing release. Defaults to
false - overwrite (optional): Overwrite existing release. Defaults to
false - dryRun (optional): Perform a dry run. Defaults to
false - apiEndpoint (optional): Override the default API endpoint. Default:
https://api.github.com
The plugin requires authentication to interact with the GitHub API. You can authenticate using a personal access token (PAT). Below are the details:
-
Personal Access Token (PAT):
You must provide a GitHub personal access token with the following scopes:repo: Grants full control of private repositories.write:packages: Allows writing to GitHub Packages.
To generate a personal access token:
- Go to your GitHub account settings.
- Navigate to Developer settings > Personal access tokens > Tokens (classic).
- Click Generate new token, select the required scopes, and copy the token.
Once generated, add the token to your
build.gradleconfiguration:githubRelease { token = 'YOUR_GITHUB_PERSONAL_ACCESS_TOKEN' } -
Environment Variable:
Alternatively, you can set the token as an environment variable:export GITHUB_TOKEN=your_personal_access_tokenThen, reference it in your
build.gradlefile:githubRelease { token = System.getenv('GITHUB_TOKEN') }
Once you've configured the plugin, you can create a GitHub release by running the following Gradle task:
./gradlew githubReleaseThis task will use the configuration provided in your build.gradle file to create a release on GitHub.
This project is licensed under the Apache 2 License - see the LICENSE file for details.