|
1 | 1 | # Publishing |
2 | 2 |
|
| 3 | +## Snapshots |
| 4 | + |
| 5 | +See [`gradle-publish-snapshot.yml`](.github/workflows/gradle-publish-snapshot.yml) for publishing snapshot version |
| 6 | +instructions. Workflow requires manual trigger for snapshot build so it's not published regularly. |
| 7 | + |
| 8 | +Artifacts are published to Snapshot Repository, using following Gradle task. |
| 9 | + |
| 10 | +```bash |
| 11 | +./gradlew -Pversion=<version> publishAggregationToCentralPortalSnapshots |
| 12 | +``` |
| 13 | + |
| 14 | +### Accessing SNAPSHOT versions |
| 15 | + |
| 16 | +1. Maven: |
| 17 | + ```xml |
| 18 | + <repositories> |
| 19 | + <repository> |
| 20 | + <id>maven-central</id> |
| 21 | + <url>https://repo.maven.apache.org/maven2/</url> |
| 22 | + </repository> |
| 23 | + |
| 24 | + <!-- add snapshot repository (for unpublished or nightly builds) --> |
| 25 | + <repository> |
| 26 | + <id>sonatype-snapshots</id> |
| 27 | + <url>https://central.sonatype.com/repository/maven-snapshots/</url> |
| 28 | + <releases> |
| 29 | + <enabled>false</enabled> |
| 30 | + </releases> |
| 31 | + <snapshots> |
| 32 | + <enabled>true</enabled> |
| 33 | + <!-- always check for new snapshots --> |
| 34 | + <updatePolicy>always</updatePolicy> |
| 35 | + </snapshots> |
| 36 | + </repository> |
| 37 | + </repositories> |
| 38 | + |
| 39 | + <dependencies> |
| 40 | + <dependency> |
| 41 | + <groupId>io.github.malczuuu.problem4j</groupId> |
| 42 | + <artifactId>problem4j-core</artifactId> |
| 43 | + <version>1.2.0-SNAPSHOT</version> |
| 44 | + </dependency> |
| 45 | + </dependencies> |
| 46 | + ``` |
| 47 | +2. Gradle (Kotlin DSL): |
| 48 | + ```kotlin |
| 49 | + repositories { |
| 50 | + mavenCentral() |
| 51 | + |
| 52 | + // add snapshot repository (for unpublished or nightly builds) |
| 53 | + maven { |
| 54 | + url = uri("https://central.sonatype.com/repository/maven-snapshots/") |
| 55 | + content { |
| 56 | + // only include snapshots from this group to avoid conflicts |
| 57 | + includeGroup("io.github.malczuuu.problem4j") |
| 58 | + } |
| 59 | + mavenContent { |
| 60 | + snapshotsOnly() |
| 61 | + } |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + // always refresh "changing" dependencies (e.g., SNAPSHOT versions) |
| 66 | + configurations.all { |
| 67 | + resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS) |
| 68 | + } |
| 69 | + |
| 70 | + dependencies { |
| 71 | + // choose the one appropriate for your project setup |
| 72 | + |
| 73 | + implementation("io.github.malczuuu.problem4j:problem4j-core:1.2.0-SNAPSHOT") { |
| 74 | + // ensures Gradle re-checks for new snapshot versions |
| 75 | + isChanging = true |
| 76 | + } |
| 77 | + } |
| 78 | + ``` |
| 79 | + |
| 80 | +## Releases |
| 81 | + |
3 | 82 | Keep Git tags with `vX.Y.Z-suffix` format. GitHub Actions job will only trigger on such tags and will remove `v` prefix. |
4 | 83 |
|
5 | | -See [`gradle-release.yml`](.github/workflows/gradle-release.yml) for whole publishing procedure. |
| 84 | +See [`gradle-publish-release.yml`](.github/workflows/gradle-publish-release.yml) for whole publishing procedure. |
6 | 85 |
|
7 | 86 | Set the following environment variables in your CI/CD (GitHub Actions, etc.): |
8 | 87 |
|
9 | 88 | ```txt |
10 | | -# generated tokens on Sonatype account, do not use real username/password |
| 89 | +# generated on Sonatype account |
11 | 90 | PUBLISHING_USERNAME=<username> |
12 | 91 | PUBLISHING_PASSWORD=<password> |
13 | 92 |
|
|
0 commit comments