Skip to content

Commit f823b13

Browse files
committed
updating pipeline
1 parent 99026e1 commit f823b13

File tree

2 files changed

+37
-25
lines changed

2 files changed

+37
-25
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,22 @@ on:
88
branches: [ main ]
99

1010
jobs:
11-
build:
12-
11+
publish:
1312
runs-on: ubuntu-latest
14-
13+
permissions:
14+
contents: read
15+
packages: write
1516
steps:
16-
- name: Checkout code
17-
uses: actions/checkout@v3
18-
with:
19-
fetch-depth: 0 # Fetch all history and tags
20-
21-
- name: Set up JDK 17
22-
uses: actions/setup-java@v3
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-java@v4
2319
with:
2420
java-version: '17'
2521
distribution: 'temurin'
22+
- name: Setup Gradle
23+
uses: gradle/actions/setup-gradle@v4
2624

27-
- name: Grant execute permission for gradlew
28-
run: chmod +x gradlew
29-
30-
- name: Build with Gradle
31-
run: ./gradlew build
32-
33-
- name: Publish to GitHub Packages
34-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
25+
- name: Publish package
26+
if: startsWith(github.ref, 'refs/tags/')
3527
run: ./gradlew publish
3628
env:
37-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
38-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build.gradle.kts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,24 @@ tasks.named<Javadoc>("javadoc") {
8989
exclude("samples/**")
9090
}
9191

92+
// Task to zip the local repository folder after publishing
93+
tasks.register<Zip>("zipRepo") {
94+
dependsOn("publish") // Ensure repo is published before zipping
95+
from("file://${project.layout.buildDirectory.get()}/repo")
96+
archiveFileName.set("bundle.zip")
97+
destinationDirectory.set(layout.buildDirectory)
98+
}
99+
100+
// Task to delete the repo directory before publishing
101+
tasks.register<Delete>("cleanRepo") {
102+
delete(layout.buildDirectory.dir("repo"))
103+
}
104+
105+
// Make sure the repo is cleaned before publishing
106+
tasks.named("publish") {
107+
dependsOn("cleanRepo")
108+
}
109+
92110
publishing {
93111
publications {
94112
create<MavenPublication>("mavenJava") {
@@ -108,11 +126,6 @@ publishing {
108126
url.set("https://opensource.org/licenses/MIT")
109127
}
110128
}
111-
developers {
112-
developer {
113-
email.set("[email protected]")
114-
}
115-
}
116129
scm {
117130
connection.set("scm:git:https://github.com/BackendStack21/realtime-pubsub-client-java.git")
118131
developerConnection.set("scm:git:ssh://[email protected]:BackendStack21/realtime-pubsub-client-java.git")
@@ -126,5 +139,13 @@ publishing {
126139
// local repository
127140
url = uri("file://${project.layout.buildDirectory.get()}/repo")
128141
}
142+
maven {
143+
name = "GitHubPackages"
144+
url = uri("https://maven.pkg.github.com/BackendStack21/realtime-pubsub-client-java")
145+
credentials {
146+
username = System.getenv("GITHUB_ACTOR")
147+
password = System.getenv("GITHUB_TOKEN")
148+
}
149+
}
129150
}
130151
}

0 commit comments

Comments
 (0)