File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,8 @@ name: Java CI with Maven
22
33on :
44 push :
5- branches : [ master ]
5+ branches : [ '*' ]
6+ tags : [ '*' ]
67 pull_request :
78 branches : [ master ]
89 workflow_dispatch :
2425 - name : Setup Gradle
2526 uses : gradle/actions/setup-gradle@v5
2627 - name : Build
27- run : ./gradlew --no-configuration-cache --no-parallel mavenCentralDeploy
28+ run : ./gradlew --no-configuration-cache --no-parallel githubActions
2829 env :
2930 SIGNING_KEY : ${{ secrets.SIGNING_KEY }}
3031 ORG_GRADLE_PROJECT_mavenCentralSnapshotsUsername : ${{ secrets.SONATYPE_USERNAME }}
Original file line number Diff line number Diff line change @@ -114,3 +114,21 @@ val mavenCentralDeploy by tasks.registering(DefaultTask::class) {
114114 }
115115 }
116116}
117+
118+ val githubActions by tasks.registering(DefaultTask ::class ) {
119+ group = " publishing"
120+ val deployRefPattern = """ ^refs/(?:tags/javacan-\d+.\d+.\d+|heads/master)$""" .toRegex()
121+ val ref = System .getenv(" GITHUB_REF" )?.ifBlank { null }?.trim()
122+
123+ if (ref != null && deployRefPattern.matches(ref)) {
124+ logger.lifecycle(" Job in $ref will deploy!" )
125+ dependsOn(mavenCentralDeploy)
126+ } else {
127+ logger.lifecycle(" Job will only build!" )
128+ for (project in allprojects) {
129+ project.tasks.findByName(" assemble" )?.let {
130+ dependsOn(it)
131+ }
132+ }
133+ }
134+ }
You can’t perform that action at this time.
0 commit comments