Skip to content

Commit

Permalink
build: update github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
matrei committed Dec 7, 2023
1 parent 43979e2 commit a287528
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 35 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/gradle-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,4 @@ jobs:
- uses: actions/setup-java@v4
with: { java-version: 11, distribution: adopt }
- uses: gradle/gradle-build-action@v2

- name: Run Tests
run: |
chmod +x gradlew
./gradlew check
with: { arguments: check }
31 changes: 18 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,22 @@ jobs:

- name: --- SET UP JDK ---
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'adopt'
with: { java-version: 11, distribution: adopt }

- name: --- GET THE RELEASE VERSION NUMBER FROM RELEASE TAG ---
id: version
uses: nowsprinting/check-version-format-action@v3
with:
prefix: 'v'
with: { prefix: v }

- name: --- GENERATE SECRING FILE ---
if: success()
env:
SECRING_FILE: ${{ secrets.SECRING_FILE }}
run: echo "$SECRING_FILE" | base64 -d > ${{ github.workspace }}/secring.gpg

- name: --- PUBLISH TO SONATYPE OSSRH ---
if: success()
uses: gradle/gradle-build-action@v2
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
Expand All @@ -43,11 +48,11 @@ jobs:
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
SECRING_FILE: ${{ secrets.SECRING_FILE }}
RELEASE_VERSION: ${{ steps.version.outputs.full_without_prefix }}
run: |
echo "$SECRING_FILE" | base64 -d > ${GITHUB_WORKSPACE}/secring.gpg
echo "Publishing Artifacts for $RELEASE_VERSION"
(set -x; ./gradlew --info -Prelease=true -Pversion="${RELEASE_VERSION}" -Psigning.secretKeyRingFile="${GITHUB_WORKSPACE}/secring.gpg" publishToSonatype closeAndReleaseSonatypeStagingRepository --no-daemon)
rm ${GITHUB_WORKSPACE}/secring.gpg
with:
arguments: -Prelease=true -Pversion=${RELEASE_VERSION} -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg publishToSonatype closeAndReleaseSonatypeStagingRepository

- name: --- DELETE SECRING FILE ---
run: rm ${{ github.workspace }}/secring.gpg

- name: --- BUMP PATCH VERSION BY ONE ---
uses: actions-ecosystem/action-bump-semver@v1
Expand All @@ -57,9 +62,9 @@ jobs:
level: patch

- name: --- UPDATE PROJECT WITH NEW SNAPSHOT VERSION ---
run: |
echo "Preparing next snapshot: ${{ steps.bump_semver.outputs.new_version }}"
./gradlew snapshotVersion -Pversion="${{ steps.bump_semver.outputs.new_version }}"
uses: gradle/gradle-build-action@v2
with:
arguments: snapshotVersion -Pversion=${{ steps.bump_semver.outputs.new_version }}

- name: --- COMMIT & PUSH THE NEW SNAPSHOT VERSION ---
uses: actions-js/push@156f2b10c3aa000c44dbe75ea7018f32ae999772 # v1.4
Expand Down
29 changes: 12 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository
import io.github.gradlenexus.publishplugin.NexusRepository

import java.time.Duration

plugins {

id 'eclipse'
Expand Down Expand Up @@ -139,27 +134,27 @@ afterEvaluate {
}
}
//do not generate extra load on Nexus with new staging repository if signing fails
tasks.withType(InitializeNexusStagingRepository).configureEach {
tasks.withType(io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository).configureEach {
shouldRunAfter tasks.withType(Sign)
}

if (project.hasProperty('release')) {
nexusPublishing {
String username = System.getenv('SONATYPE_USERNAME') ?: project.findProperty('sonatypeOssUsername') ?: ''
String password = System.getenv('SONATYPE_PASSWORD') ?: project.findProperty('sonatypeOssPassword') ?: ''
String stagingProfileId = System.getenv('SONATYPE_STAGING_PROFILE_ID') ?: project.findProperty('sonatypeOssStagingProfileId') ?: ''
String sonatypeUsername = System.getenv('SONATYPE_USERNAME') ?: project.findProperty('sonatypeOssUsername') ?: ''
String sonatypePassword = System.getenv('SONATYPE_PASSWORD') ?: project.findProperty('sonatypeOssPassword') ?: ''
String sonatypeStagingProfileId = System.getenv('SONATYPE_STAGING_PROFILE_ID') ?: project.findProperty('sonatypeOssStagingProfileId') ?: ''
repositories {
sonatype { NexusRepository repo ->
repo.nexusUrl.set uri('https://s01.oss.sonatype.org/service/local/')
repo.snapshotRepositoryUrl.set uri('https://s01.oss.sonatype.org/content/repositories/snapshots/')
repo.username.set username
repo.password.set password
repo.stagingProfileId.set = stagingProfileId
sonatype {
nexusUrl = uri('https://s01.oss.sonatype.org/service/local/')
snapshotRepositoryUrl = uri('https://s01.oss.sonatype.org/content/repositories/snapshots/')
username = sonatypeUsername
password = sonatypePassword
stagingProfileId = sonatypeStagingProfileId
}
}
transitionCheckOptions {
maxRetries.set 40
delayBetween.set Duration.ofMillis(2000)
maxRetries = 40
delayBetween = java.time.Duration.ofMillis(2000)
}
}
}
Expand Down

0 comments on commit a287528

Please sign in to comment.