Skip to content

Commit

Permalink
fix examples auth for github package;
Browse files Browse the repository at this point in the history
fix jitpack build;
update readme with github package use instruction
  • Loading branch information
xvik committed Dec 9, 2024
1 parent e5f1aba commit 33660ce
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/examples-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ jobs:
run:
working-directory: examples
name: Java ${{ matrix.java }}
env:
USERNAME: ${{ GITHUB_ACTOR }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:
matrix:
java: [11, 17]
Expand Down
48 changes: 42 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,45 @@ Gradle | Version
#### Snapshots

<details>
<summary>Snapshots may be used through JitPack</summary>
<summary>Snapshots may be used through JitPack or GitHub packages</summary>

* Go to [JitPack project page](https://jitpack.io/#ru.vyarus/gradle-animalsniffer-plugin)
* Select `Commits` section and click `Get it` on commit you want to use
or use `master-SNAPSHOT` to use the most recent snapshot
##### GitHub package

WARNING: Accessing GitHub package requires [GitHub authorization](https://docs.github.com/en/enterprise-cloud@latest/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry#authenticating-to-github-packages)!

* Add to `settings.gradle` (top most!) (exact commit hash might be used as version) :

```groovy
pluginManagement {
repositories {
gradlePluginPortal()
maven {
url = 'https://maven.pkg.github.com/xvik/gradle-animalsniffer-plugin'
credentials {
username = settings.ext.find('gpr.user') ?: System.getenv("USERNAME")
password = settings.ext.find('gpr.key') ?: System.getenv("TOKEN")
}
}
}
}
```
* In global gradle file `~/.gradle/gradle.properties` add
```
gpr.user=<your github user name>
gpr.key=<your github password or classic token>
```
(or credentials must be declared in environment: USERNAME/TOKEN (more usable for CI))
Read [personal access tokens creation guide](https://docs.github.com/en/enterprise-cloud@latest/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic)
Note that token needs only "package/read" permission
* Use plugin snapshot (see [the latest published package version](https://github.com/xvik/gradle-animalsniffer-plugin/packages/2339003)):

```groovy
plugins {
id 'ru.vyarus.animalsniffer' version '2.0.0-SNAPSHOT'
}
```

##### JitPack

* Add to `settings.gradle` (top most!) (exact commit hash might be used as version) :

Expand All @@ -146,14 +180,16 @@ Gradle | Version
maven { url 'https://jitpack.io' }
}
}
```
```
Note: this would use the latest snapshot. To use exact commit version, go to
[JitPack project page](https://jitpack.io/#ru.vyarus/gradle-animalsniffer-plugin)
* Use plugin without declaring version:

```groovy
plugins {
id 'ru.vyarus.animalsniffer'
}
```
```

</details>

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ if (System.getenv("SNAPSHOT")) {
}

// skip signing for jitpack (snapshots)
tasks.withType(Sign) { onlyIf { !System.getenv('JITPACK') || !System.getenv('SNAPSHOT') }}
tasks.withType(Sign) { onlyIf { !(System.getenv('JITPACK') || System.getenv('SNAPSHOT')) }}

// Required signing properties for release: signing.keyId, signing.password and signing.secretKeyRingFile
// (https://docs.gradle.org/current/userguide/signing_plugin.html#sec:signatory_credentials)
Expand Down
9 changes: 8 additions & 1 deletion examples/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ pluginManagement {
mavenLocal()
gradlePluginPortal()
google()
maven { url 'https://maven.pkg.github.com/xvik/gradle-animalsniffer-plugin' }
// for github package (used on CI)
maven {
url = 'https://maven.pkg.github.com/xvik/gradle-animalsniffer-plugin'
credentials {
username = settings.ext.find('gpr.user') ?: System.getenv("USERNAME")
password = settings.ext.find('gpr.key') ?: System.getenv("TOKEN")
}
}
}
}

Expand Down

0 comments on commit 33660ce

Please sign in to comment.