Skip to content

Add support for environment variables for upload tokens #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@ To set a property, set `<name>_<property>` in `mod.properties` where `<name>` is

## Secrets

### Using a Secrets File
ModUtils will look for a file named `secrets.properties` (the location can be changed with the environment variable `SECRET_PROPERTIES`) and load those properties into a global object named `secrets`. The keys for mod uploading are expected as `curse_auth` or `modrinth_auth` in that secret object.

### Using Environment Variables
If the corresponding keys are not found in the `secrets` file, ModUtils will check for the following environment variables:
- `CURSEFORGE_UPLOAD_TOKEN` for CurseForge uploads.
- `MODRINTH_UPLOAD_TOKEN` for Modrinth uploads.

## Mod properties

The properties defined in `mod.properties` will be placed in a global object named `mod`. Also some other properties will be added to this. All `mod` properties can be found below. (Non-bold properties may be absent). A property can be accessed with `mod.<name>` where `<name>` is the property name. To check, whether a property is present, use `'<name>' in mod`.
Expand Down
2 changes: 2 additions & 0 deletions scripts/mod/upload_curse.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ String curseChangelog = mod.gitChangelog()
task curseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) {
if ('curse_auth' in secrets) {
apiToken = secrets.curse_auth.toString()
} else if (System.getenv('CURSEFORGE_UPLOAD_TOKEN')) {
apiToken = System.getenv('CURSEFORGE_UPLOAD_TOKEN')
} else {
apiToken = ''
}
Expand Down
2 changes: 2 additions & 0 deletions scripts/mod/upload_modrinth.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ String modrinthChangelog = mod.gitChangelog()
modrinth {
if ('modrinth_auth' in secrets) {
token = secrets.modrinth_auth.toString()
} else if (System.getenv('MODRINTH_UPLOAD_TOKEN')) {
apiToken = System.getenv('MODRINTH_UPLOAD_TOKEN')
} else {
token = ''
}
Expand Down