Skip to content

Commit

Permalink
Add support to build with github
Browse files Browse the repository at this point in the history
  • Loading branch information
yamelsenih committed Aug 19, 2024
1 parent baedb22 commit 6f427ff
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 98 deletions.
38 changes: 0 additions & 38 deletions .github/workflows/build_with_gradle.yml

This file was deleted.

44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This is a basic workflow to help you get started with Actions
# This file was contributed by Carlos Parada and Yamel Senih from ERP Consultores y Asociados, C.A

name: Continuous Integration with Gradle

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the develop branch
push:
branches:
- '*' # matches every branch that doesn't contain a '/'
- '*/*' # matches every branch containing a single '/'
- '**' # matches every branch
pull_request:
branches:
- '*' # matches every branch that doesn't contain a '/'
- '*/*' # matches every branch containing a single '/'
- '**' # matches every branch

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:

build-ci:
name: Build Project
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up Java JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-package: 'jdk'
java-version: 11
architecture: x64

- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 8.0.1
arguments: build
env:
ADEMPIERE_LIBRARY_VERSION: 'build'
69 changes: 69 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# This is a basic workflow to help you get started with Actions
# This file was contributed by Carlos Parada and Yamel Senih from ERP Consultores y Asociados, C.A

name: Publish With gradle to maven central

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the develop branch
release:
types:
- published

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:

publish-sonatype:
name: Publish Project (Sonatype)
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set up Java JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-package: 'jdk'
java-version: 11
architecture: x64

- name: Build with Gradle
uses: gradle/gradle-build-action@v3
with:
gradle-version: 8.0.2
arguments: publish
env:
ORG_GRADLE_PROJECT_deployVersion: ${{ github.event.release.tag_name }}
ORG_GRADLE_PROJECT_deployPublishUrl: ${{ secrets.DEPLOY_PUBLISH_SONATYPE_URL }}
ORG_GRADLE_PROJECT_deploySigningKey: ${{ secrets.PGP_SECRET }}
ORG_GRADLE_PROJECT_deploySigningPassword: ${{ secrets.PGP_PASSPHRASE }}
ORG_GRADLE_PROJECT_deployUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_deployPassword: ${{ secrets.OSSRH_TOKEN }}
publish-github:
name: Publish Project (Github)
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set up Java JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-package: 'jdk'
java-version: 11
architecture: x64

- name: Build with Gradle
uses: gradle/gradle-build-action@v3
with:
gradle-version: 8.0.2
arguments: publish
env:
ORG_GRADLE_PROJECT_deployVersion: ${{ github.event.release.tag_name }}
ORG_GRADLE_PROJECT_deployPublishUrl: ${{ secrets.DEPLOY_PUBLISH_GITHUB_URL }}
ORG_GRADLE_PROJECT_deploySigningKey: ${{ secrets.PGP_SECRET }}
ORG_GRADLE_PROJECT_deploySigningPassword: ${{ secrets.PGP_PASSPHRASE }}
ORG_GRADLE_PROJECT_deployUsername: "${{ github.actor }}"
ORG_GRADLE_PROJECT_deployPassword: "${{ secrets.DEPLOY_TOKEN }}"
38 changes: 0 additions & 38 deletions .github/workflows/publish_with_gradle.yml

This file was deleted.

68 changes: 46 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
}

sourceCompatibility = 1.11
def baseVersion = '3.9.4'
def baseGroupId = 'io.github.adempiere'

repositories {
mavenLocal()
mavenCentral()
}

//Solution by the second link
allprojects {
tasks.withType(Javadoc).all { enabled = false }
}

sourceCompatibility = 1.11
def baseVersion = '3.9.4'
def baseGroupId = 'io.github.adempiere'
def customGroupId = System.getenv("ADEMPIERE_LIBRARY_GROUP")
targetCompatibility = 1.11

dependencies {
implementation fileTree(
api fileTree(
dir: 'lib',
include: [
'*.jar'
]
)
// ADempiere Core
implementation "${baseGroupId}:base:${baseVersion}"
api "${baseGroupId}:base:${baseVersion}"
}

sourceSets {
Expand All @@ -41,32 +44,36 @@ java {
withSourcesJar()
}


def entityType = 'WHH'
version = System.getenv("ADEMPIERE_LIBRARY_VERSION")
group = "io.github.adempiere"
version = findProperty("deployVersion") ?: "local-1.0.0"

jar {
manifest {
attributes("Implementation-Title": "A Test of Project",
attributes("Implementation-Title": "Withholding Engine",
"Implementation-Version": version,
"EntityType": entityType)
}
}

publishing {
repositories {
mavenLocal()

maven {
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
url = findProperty("deployPublishUrl") ?: System.properties['deploy.publish_url']
credentials {
username = findProperty("sonatypeUsername")
password = findProperty("sonatypePassword")
username = findProperty("deployUsername") ?: System.properties['deploy.user']
password = findProperty("deployPassword") ?: System.properties['deploy.token']
}
}
}
publications {
mavenJava(MavenPublication) {
groupId customGroupId
artifactId 'withholding-engine'
version
groupId = group
artifactId 'withholding-engine'
version = version
from components.java
pom {
name = 'Withholding Engine'
Expand All @@ -86,18 +93,35 @@ publishing {
}
}
scm {
connection = 'scm:git:git://github.com/adempiere/Withholding-Engine.git'
developerConnection = 'scm:git:ssh://github.com/adempiere/Withholding-Engine.git'
url = 'http://github.com/adempiere/Withholding-Engine'
connection = 'scm:git:git://github.com/adempiere/adempiere-s3-connector.git'
developerConnection = 'scm:git:ssh://github.com/adempiere/adempiere-s3-connector.git'
url = 'http://github.com/adempiere/adempiere-s3-connector'
}
}
}
}
}


task cleanBuildPublishLocal(type: GradleBuild) {
tasks = ['clean', 'build', 'publishToMavenLocal']
}


signing {
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
def isReleaseVersion = !version.toString().startsWith("local") && !version.toString().endsWith("-SNAPSHOT")

sign configurations.archives

setRequired {
// signing is required if this is a release version and the artifacts are to be published
// do not use hasTask() as this require realization of the tasks that maybe are not necessary
(isReleaseVersion || version.toString().equals("build")) && gradle.taskGraph.allTasks.any {
it.equals(PublishToMavenRepository)
}
}
def signingKey = findProperty("deploySigningKey")
def signingPassword = findProperty("deploySigningPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}

0 comments on commit 6f427ff

Please sign in to comment.