-
Notifications
You must be signed in to change notification settings - Fork 5
Token Setup
Intisy edited this page Apr 24, 2026
·
1 revision
The plugin uses a GitHub Personal Access Token (PAT) to authenticate with the GitHub API. A token is required to:
- Publish a release (create release, upload assets)
- Download from private repositories
-
Update dependencies (
updateGithubDependenciestask) - Clone private resource repositories
Public repository downloads work without a token.
- Go to GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click Generate new token (classic)
- Give it a descriptive name (e.g.
github-gradle) - Select scopes:
-
repo— full access to public and private repositories (required for publishing and private downloads) -
read:packages— only needed if you use GitHub Packages alongside this plugin
-
- Click Generate token and copy it immediately (it is shown only once)
Fine-grained tokens also work if you grant Contents: Read and write on the target repository.
github {
accessToken = "ghp_YOUR_TOKEN_HERE"
}Add to ~/.gradle/gradle.properties (user home, not the project):
githubToken=ghp_YOUR_TOKEN_HEREThen reference it in build.gradle:
github {
accessToken = project.findProperty("githubToken") ?: ""
}github {
accessToken = file("${System.getProperty('user.home')}/.github_token")
}The plugin reads the token from the file at build time.
github {
accessToken = System.getenv("GITHUB_TOKEN") ?: ""
}This is the recommended approach for CI/CD pipelines (GitHub Actions, etc.).
In a GitHub Actions workflow the token is available automatically:
- name: Publish release
run: gradle publishGithub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}// build.gradle
github {
accessToken = System.getenv("GITHUB_TOKEN") ?: ""
}secrets.GITHUB_TOKEN has repo scope for the current repository, which is sufficient for publishing.
- Never commit a raw token to source control
- Use
~/.gradle/gradle.propertiesfor local development - Use repository secrets for CI/CD
- Rotate tokens that may have been exposed
Getting started
Using the plugin
Reference