Skip to content

Commit

Permalink
[workflows] separated workflows for push and prerelease/release
Browse files Browse the repository at this point in the history
  • Loading branch information
FrogDevelopper committed Aug 15, 2024
1 parent b7e1800 commit a0cee2c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 22 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and test code source

env:
CI: true

on:
push:
branches: [ "**" ]

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
checks: write
pull-requests: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/[email protected]

- name: Compile & Test
run: ./gradlew test

- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: '**/test-results/**/*.xml'
23 changes: 4 additions & 19 deletions .github/workflows/ci_cd.yml → .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
name: Java CI with Gradle
name: Publish artifacts into Maven Central

env:
CI: true

on:
push:
branches: [ "**" ]
release:
types: [ created ]
types: [ prereleased, released ]

jobs:
build:
publish:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
checks: write
pull-requests: write

steps:
- name: Checkout
Expand All @@ -32,23 +27,13 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/[email protected]

- name: Compile & Test
run: ./gradlew test

- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: '**/test-results/**/*.xml'

- name: Generate package
if: startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/tags/')
run: ./gradlew publish

- name: Deploy released package in MavenCentral
if: startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/tags/')
run: ./gradlew jreleaserDeploy
env:
DRY_RUN: ${{ github.event.release.prerelease }}
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVENCENTRAL_PASSWORD }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GNUPG_PASSPHRASE }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ plugins {
id("org.jreleaser")
}

val releaseRegex = """^\d+\.\d+\.\d+$""".toRegex()

jreleaser {
gitRootSearch = true
dependsOnAssemble = true
dryrun = provider { !releaseRegex.matches(version.toString()) }
dryrun = providers.environmentVariable("DRY_RUN")
.map(String::toBoolean)
.orElse(true)

project {
copyright.set("FrogDevelopment")
Expand Down Expand Up @@ -52,4 +52,5 @@ tasks {
jreleaserSign {
childProjects.forEach { child -> dependsOn(child.value.tasks.named("publish")) }
}

}

0 comments on commit a0cee2c

Please sign in to comment.