Skip to content

Commit 71e9724

Browse files
Configure publishing to Sonatype and Homebrew
1 parent 7360b58 commit 71e9724

13 files changed

Lines changed: 125 additions & 47 deletions

File tree

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
3+
updates:
4+
- package-ecosystem: "gradle"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
9+
- package-ecosystem: "github-actions"
10+
directory: "/"
11+
schedule:
12+
interval: "weekly"

.github/workflows/ci.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
release:
7+
types: [ published ]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
unit-tests:
15+
runs-on: [ self-hosted, ubuntu-latest ]
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-java@v5
20+
with:
21+
java-version: 21
22+
distribution: temurin
23+
24+
- uses: allegro-actions/setup-gradle@v1
25+
with:
26+
cache-read-only: false
27+
28+
- run: ./gradlew test
29+
30+
- name: Junit report
31+
uses: mikepenz/action-junit-report@v4
32+
if: success() || failure()
33+
with:
34+
report_paths: '**/test-results/*/*.xml'
35+
36+
publish-to-homebrew:
37+
runs-on: [self-hosted, ubuntu-latest, 16gb]
38+
# if: github.event_name == 'release'
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- uses: actions/setup-java@v5
43+
with:
44+
java-version: 21
45+
distribution: temurin
46+
47+
- uses: gradle/actions/setup-gradle@v5
48+
with:
49+
cache-read-only: false
50+
51+
- run: ./gradlew check
52+
53+
- id: publish
54+
run: ./gradlew publish
55+
env:
56+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
57+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
58+
JRELEASER_GITHUB_TOKEN: dummy
59+
60+
- id: generate-token
61+
uses: actions/create-github-app-token@v1
62+
with:
63+
app-id: ${{ secrets.ALLEGRO_HOMEBREW_APP_ID }}
64+
private-key: ${{ secrets.ALLEGRO_HOMEBREW_PRIVATE_KEY }}
65+
owner: allegro-internal
66+
repositories: homebrew-tap
67+
68+
- name: Checkout Homebrew repository
69+
uses: actions/checkout@v4
70+
with:
71+
repository: allegro-internal/homebrew-tap
72+
path: homebrew-tap
73+
token: ${{ steps.generate-token.outputs.token }}
74+
75+
- name: Replace file in Homebrew repository
76+
run: |
77+
ls -lah allegro-rewrite-runner/build/jreleaser/assemble/allegro-rewrite/jlink
78+
cp allegro-rewrite-runner/build/jreleaser/package/allegro-rewrite/brew/Formula/allegro-rewrite.rb homebrew-tap/Formula/allegro-rewrite.rb
79+
git add homebrew-tap/Formula/allegro-rewrite.rb
80+
81+
- name: Commit changes in Homebrew repository
82+
uses: dsanders11/github-app-commit-action@v2
83+
with:
84+
owner: allegro
85+
repo: homebrew-tap
86+
message: 'Release allwrite ${{ steps.publish.outputs.published-version }}'
87+
token: ${{ steps.generate-token.outputs.token }}
88+
working-directory: ./homebrew-tap

build-logic/src/main/kotlin/pl/allegro/tech/allwrite/buildlogic/ExtractJdkTask.kt renamed to build-logic/src/main/kotlin/ExtractJdkTask.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
package pl.allegro.tech.allwrite.buildlogic
2-
31
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream
42
import org.gradle.api.DefaultTask
53
import org.gradle.api.file.Directory
@@ -22,7 +20,7 @@ import java.util.zip.GZIPInputStream
2220
import java.util.zip.ZipInputStream
2321

2422
@CacheableTask
25-
abstract class ExtractJdkTask : DefaultTask() {
23+
internal abstract class ExtractJdkTask : DefaultTask() {
2624

2725
@get:InputFile
2826
@get:PathSensitive(PathSensitivity.RELATIVE)

build-logic/src/main/kotlin/pl/allegro/tech/allwrite/buildlogic/FetchJdkTask.kt renamed to build-logic/src/main/kotlin/FetchJdkTask.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
package pl.allegro.tech.allwrite.buildlogic
2-
31
import io.ktor.client.*
42
import io.ktor.client.engine.cio.*
53
import io.ktor.client.plugins.*
@@ -12,15 +10,15 @@ import org.gradle.api.provider.Property
1210
import org.gradle.api.provider.Provider
1311
import org.gradle.api.tasks.CacheableTask
1412
import org.gradle.api.tasks.Input
15-
import org.gradle.api.tasks.Internal
1613
import org.gradle.api.tasks.OutputFile
1714
import org.gradle.api.tasks.TaskAction
1815
import java.nio.file.Files
1916
import java.nio.file.Path
2017
import kotlin.io.path.exists
18+
import kotlin.text.format
2119

2220
@CacheableTask
23-
abstract class FetchJdkTask : DefaultTask() {
21+
internal abstract class FetchJdkTask : DefaultTask() {
2422

2523
@Input
2624
val target: Property<JdkDistribution> = project.objects.property(JdkDistribution::class.java)

build-logic/src/main/kotlin/pl/allegro/tech/allwrite/buildlogic/JdkDistribution.kt renamed to build-logic/src/main/kotlin/JdkDistribution.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
package pl.allegro.tech.allwrite.buildlogic
2-
3-
enum class JdkDistribution(
1+
internal enum class JdkDistribution(
42
/**
53
* Name used to make up the Temurin JDK release asset filename
64
*/

build-logic/src/main/kotlin/pl/allegro/tech/allwrite/buildlogic/RecipeClasspath.kt renamed to build-logic/src/main/kotlin/RecipeClasspath.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
package pl.allegro.tech.allwrite.buildlogic
2-
31
import org.gradle.api.Project
42
import org.gradle.kotlin.dsl.dependencies
53
import javax.inject.Inject

build-logic/src/main/kotlin/pl/allegro/tech/allwrite/buildlogic/VerifyJdkTask.kt renamed to build-logic/src/main/kotlin/VerifyJdkTask.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
package pl.allegro.tech.allwrite.buildlogic
2-
31
import org.gradle.api.DefaultTask
42
import org.gradle.api.provider.Provider
53
import org.gradle.api.tasks.CacheableTask
@@ -12,7 +10,7 @@ import java.nio.file.Files
1210
import java.nio.file.Path
1311

1412
@CacheableTask
15-
abstract class VerifyJdkTask : DefaultTask() {
13+
internal abstract class VerifyJdkTask : DefaultTask() {
1614

1715
@get:InputFile
1816
@get:PathSensitive(PathSensitivity.RELATIVE)

build-logic/src/main/kotlin/conventions/jdk-provisioning.gradle.kts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package conventions
22

3-
import pl.allegro.tech.allwrite.buildlogic.ExtractJdkTask
4-
import pl.allegro.tech.allwrite.buildlogic.FetchJdkTask
5-
import pl.allegro.tech.allwrite.buildlogic.JdkDistribution
6-
import pl.allegro.tech.allwrite.buildlogic.VerifyJdkTask
3+
import ExtractJdkTask
4+
import FetchJdkTask
5+
import VerifyJdkTask
76
import java.nio.file.Path
87

98
val provisionJdksTask = tasks.register("provisionJdks")

build-logic/src/main/kotlin/conventions/jreleaser.gradle.kts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
package conventions
44

5+
import ExtractJdkTask
56
import libs
67
import org.gradle.internal.jvm.Jvm
7-
import org.gradle.kotlin.dsl.invoke
8-
import org.jreleaser.gradle.plugin.internal.applyJReleaserConfigs
98
import org.jreleaser.model.Active
10-
import pl.allegro.tech.allwrite.buildlogic.ExtractJdkTask
119
import java.net.URI
1210

1311
/**
@@ -101,15 +99,6 @@ jreleaser {
10199
}
102100
}
103101

104-
/**
105-
* JReleaserPlugin reads the above configuration in afterEvaluate {} but it's too early since setup-gradle
106-
* adds publishing repositories in projectsEvaluated {}. In order to make it working, we need to re-apply
107-
* the configs later in configuration phase.
108-
*/
109-
gradle.projectsEvaluated {
110-
applyJReleaserConfigs()
111-
}
112-
113102
tasks {
114103
jreleaserAssemble.configure {
115104
dependsOn(jar, installDist, tasks["provisionJdks"])

build-logic/src/main/kotlin/conventions/recipe-classpaths.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
package conventions
44

5-
import pl.allegro.tech.allwrite.buildlogic.RecipeClasspath
6-
75
plugins {
86
java
97
}

0 commit comments

Comments
 (0)