diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml new file mode 100644 index 0000000..d2abe92 --- /dev/null +++ b/.github/workflows/build-deploy.yml @@ -0,0 +1,110 @@ +# This workflow builds the API and releases it to Maven-Sonatype-Central repository + +name: Build and deploy Articular-ES + +# Runs this workflow [on-release] only +on: + # Triggers the workflow on push or pull request events but only for the "master" branch + release: + types: [published] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +jobs: + compile-assemble: + # runner images with architectures (variants) + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ 'ubuntu-latest' ] + name: Compile java and articular-es jar + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Checkout Job + uses: actions/checkout@v3 + + - name: Setup Temurin-OpenJDK-19 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '19' + + - name: Building articular-es + run: ./gradlew --console="verbose" -Pversion=${GITHUB_REF_NAME} :articular-es:build + + - name: Generate articular-es sources jar + run: ./gradlew -Pversion=$GITHUB_REF_NAME :articular-es:generateSourcesJar + + - name: Generate articular-es javadoc jar + run: ./gradlew -Pversion=$GITHUB_REF_NAME :articular-es:generateJavadocJar + + - name: Archive articular-es + uses: actions/upload-artifact@v3 + with: + name: articular-build + path: articular-es/build/libs + + deploy: + environment: + name: maven-central + url: https://repo.maven.apache.org/maven2/io/github/software-hardware-codesign/ + runs-on: ${{ matrix.os }} + needs: [compile-assemble] + strategy: + matrix: + os: [ 'ubuntu-latest' ] + name: Deploying to Maven-Central repository + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Checkout Job + uses: actions/checkout@v3 + + - name: Setup Temurin-OpenJDK-19 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '19' + + - name: Setup maven-3.9 + run: | + # remove shipped maven-3.8 that causes the plexus plugin incompatibility behavior + sudo apt remove maven + # installs maven-3.9 with the fixed plugins patch + chmod +rwx ./helper-scripts/project-impl/publishing/install-maven-latest.sh + ./helper-scripts/project-impl/publishing/install-maven-latest.sh + + - name: Use Predefined PGP Keybox + run: gpg --import ./helper-scripts/project-impl/publishing/avrsandbox.pub + + - name: Import secret-key + run: gpg --allow-secret-key-import --import --batch --yes --passphrase="avrsandbox" ./helper-scripts/project-impl/publishing/secret-key + + - name: Import owner-trust + run: gpg --import-ownertrust ./helper-scripts/project-impl/publishing/owner-trust.txt + + - name: Send public key 'avrsandbox' + # sends the public key to a maven compatible host + run: gpg --keyserver keyserver.ubuntu.com --send-keys 85A57D4975B6EE2B6D0EA46903DE10B9F12F0B20 + + - name: Download articular-es build + uses: actions/download-artifact@v3 + with: + name: articular-build + path: articular-es/build/libs/ + + - name: Deploying articular-es binaries + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} + run: | + chmod +rwx ./helper-scripts/project-impl/publishing/sonatype-publish-artifacts.sh + # publish artifacts using the tag version + ./helper-scripts/project-impl/publishing/sonatype-publish-artifacts.sh $GITHUB_REF_NAME \ No newline at end of file diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000..68700ee --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,94 @@ +# This is a basic workflow to help you get started with Actions + +name: Build and Test Articular-ES + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the "master" branch + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build-articular: + # runner images with architectures (variants) + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ 'ubuntu-latest' ] + name: Build jector + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Checkout Job + uses: actions/checkout@v3 + + - name: Setup Temurin-JDK-19 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '19' + + - name: Compiling articular-es + run: ./gradlew --console="verbose" :articular-es:build + + - name: Archive articular-es + uses: actions/upload-artifact@v3 + with: + name: articular-es-snapshot + path: articular-es/build/libs/ + +# test-doc-generation: +# # a linux runner image with the ndk installed and llvm ready to compile android native binaries +# runs-on: ${{ matrix.os }} +# strategy: +# matrix: +# os: [ 'ubuntu-latest' ] +# name: Generating documentation +# +# # Steps represent a sequence of tasks that will be executed as part of the job +# steps: +# - name: Checkout Job +# uses: actions/checkout@v3 +# +# - name: Setup Oracle-JDK-19 +# uses: actions/setup-java@v3 +# with: +# distribution: 'temurin' +# java-version: '19' +# +# - name: Generate javadoc for articular-es +# run: chmod +rwx ./gradlew && ./gradlew :articular-es:generateJavadocJar + + test: + # runner images with architectures (variants) + runs-on: ${{ matrix.os }} + needs: build-jector + strategy: + matrix: + os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ] + name: Testing jector on ${{ matrix.os }} for x86-64 + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Checkout Job + uses: actions/checkout@v3 + + - name: Setup Temurin-JDK-19 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '19' + + - name: Download articular-es-SNAPSHOT.jar library + uses: actions/download-artifact@v3 + with: + name: articular-es-snapshot + path: articular-es/build/libs/ + + - name: Run articular-es example + run: ./gradlew :articular-examples:run \ No newline at end of file diff --git a/articular-es/build.gradle b/articular-es/build.gradle index 3e6c039..caf50a7 100644 --- a/articular-es/build.gradle +++ b/articular-es/build.gradle @@ -1,16 +1,27 @@ -/* - * This file was generated by the Gradle 'init' task. - * - * This generated file contains a sample Java library project to get you started. - * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle - * User Manual available at https://docs.gradle.org/7.6/userguide/building_java_projects.html - */ - plugins { // Apply the java-library plugin for API and implementation separation. id 'java-library' } +tasks.register("generateJavadocJar", Jar) { + classifier = 'javadoc' + from javadoc +} + +tasks.register("generateSourcesJar", Jar) { + classifier = 'sources' + from sourceSets.main.allSource +} + +jar { // assemble jar options [java -jar] + manifest { + attributes 'Project': "Articular-es", + 'Version': "${version}", + 'Automatic-Module-Name': "${project.name.replace("-", ".")}", + 'Compiled-by': JavaVersion.current() + } +} + repositories { // Use Maven Central for resolving dependencies. mavenCentral() @@ -19,15 +30,9 @@ repositories { dependencies { // Use JUnit Jupiter for testing. testImplementation 'org.junit.jupiter:junit-jupiter:5.9.1' - - // This dependency is exported to consumers, that is to say found on their compile classpath. - api 'org.apache.commons:commons-math3:3.6.1' - - // This dependency is used internally, and not exposed to consumers on their own compile classpath. - implementation 'com.google.guava:guava:31.1-jre' } tasks.named('test') { // Use JUnit Platform for unit tests. useJUnitPlatform() -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..0e8f9e0 --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +version=SNAPSHOT \ No newline at end of file diff --git a/helper-scripts/abstract/abstract-checksum-generator.sh b/helper-scripts/abstract/abstract-checksum-generator.sh new file mode 100644 index 0000000..e9e843d --- /dev/null +++ b/helper-scripts/abstract/abstract-checksum-generator.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +function getMd5Checksum() { + local input=$1 + local output=$2 + + md5sum "$input" > "$output" + + return $? +} + +function getSha1Checksum() { + local input=$1 + local output=$2 + + sha1sum "$input" > "$output" + + return $? +} \ No newline at end of file diff --git a/helper-scripts/abstract/abstract-move-files.sh b/helper-scripts/abstract/abstract-move-files.sh new file mode 100644 index 0000000..6074651 --- /dev/null +++ b/helper-scripts/abstract/abstract-move-files.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +function move() { + local src=$1 + local dest=$2 + + mv -uv $src $dest + + return $? +} \ No newline at end of file diff --git a/helper-scripts/abstract/abstract-sonatype-publish.sh b/helper-scripts/abstract/abstract-sonatype-publish.sh new file mode 100644 index 0000000..b801806 --- /dev/null +++ b/helper-scripts/abstract/abstract-sonatype-publish.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +function generateGenericPom() { + local groupId=$1 + local artifactId=$2 + local version=$3 + local name=$4 + local description=$5 + local url=$6 + local license_name=$7 + local license_url=$8 + local developer_name=$9 + local developer_mail=${10} + local organization_name=${11} + local organization_url=${12} + local scm_conn=${13} + local output=${14} + + config=" \ + 4.0.0 \ + ${groupId} \ + ${artifactId} \ + ${version} \ + ${name} \ + jar \ + ${description} \ + ${url} \ + \ + \ + ${license_name} \ + ${license_url} \ + \ + \ + \ + \ + ${developer_name} \ + ${developer_mail} \ + ${organization_name} \ + ${organization_url} \ + \ + \ + \ + ${scm_conn} \ + ${scm_conn} \ + ${url} \ + \ + \ +" + echo $config > ${output} +} + +function publishBuild() { + local artifactId=$1 + local artifact=$2 + local version=$3 + local javadoc_jar=$4 + local sources_jar=$5 + local pomFile=$6 + + ${maven_bin} gpg:sign-and-deploy-file -s ${settings} -Durl=${sonatype_url} \ + -DartifactId=${artifactId} \ + -DrepositoryId=${repository} \ + -Dversion=${version} \ + -DpomFile=${pomFile} \ + -Dgpg.passphrase=${passphrase} \ + -Dfile=${artifact} \ + -Djavadoc=${javadoc_jar} \ + -Dsources=${sources_jar} + + return $? +} \ No newline at end of file diff --git a/helper-scripts/project-impl/publishing/avrsandbox.pub b/helper-scripts/project-impl/publishing/avrsandbox.pub new file mode 100644 index 0000000..55089da Binary files /dev/null and b/helper-scripts/project-impl/publishing/avrsandbox.pub differ diff --git a/helper-scripts/project-impl/publishing/install-maven-latest.sh b/helper-scripts/project-impl/publishing/install-maven-latest.sh new file mode 100755 index 0000000..c974d2e --- /dev/null +++ b/helper-scripts/project-impl/publishing/install-maven-latest.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +source "./helper-scripts/project-impl/variables.sh" + +function downloadMavenLatest() { + wget "https://dlcdn.apache.org/maven/maven-3/${maven_version}/binaries/apache-maven-${maven_version}-bin.tar.gz" + return $? +} + +function extractMavenLatest() { + tar xzvf "./apache-maven-${maven_version}-bin.tar.gz" + return $? +} + +downloadMavenLatest +extractMavenLatest diff --git a/helper-scripts/project-impl/publishing/maven-settings.xml b/helper-scripts/project-impl/publishing/maven-settings.xml new file mode 100644 index 0000000..3198330 --- /dev/null +++ b/helper-scripts/project-impl/publishing/maven-settings.xml @@ -0,0 +1,12 @@ + + + + ossrh + ${env.OSSRH_USERNAME} + ${env.OSSRH_TOKEN} + + + diff --git a/helper-scripts/project-impl/publishing/owner-trust.txt b/helper-scripts/project-impl/publishing/owner-trust.txt new file mode 100644 index 0000000..807d3c9 --- /dev/null +++ b/helper-scripts/project-impl/publishing/owner-trust.txt @@ -0,0 +1,3 @@ +# List of assigned trustvalues, created Thu 13 Jul 2023 12:01:36 AM EAT +# (Use "gpg --import-ownertrust" to restore them) +85A57D4975B6EE2B6D0EA46903DE10B9F12F0B20:6: diff --git a/helper-scripts/project-impl/publishing/secret-key b/helper-scripts/project-impl/publishing/secret-key new file mode 100644 index 0000000..9da68b5 Binary files /dev/null and b/helper-scripts/project-impl/publishing/secret-key differ diff --git a/helper-scripts/project-impl/publishing/sonatype-publish-artifacts.sh b/helper-scripts/project-impl/publishing/sonatype-publish-artifacts.sh new file mode 100755 index 0000000..2ec315d --- /dev/null +++ b/helper-scripts/project-impl/publishing/sonatype-publish-artifacts.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +source "./helper-scripts/abstract/abstract-sonatype-publish.sh" +source "./helper-scripts/project-impl/variables.sh" + +# obtain dependencies in the form 'groupId:artifact:version' +version=${1} + +lib_artifact="${lib_build_dir}/${lib_artifactId_release}-${version}.jar" +lib_sources_jar="${lib_build_dir}/${lib_artifactId_release}-${version}-sources.jar" +lib_javadoc_jar="${lib_build_dir}/${lib_artifactId_release}-${version}-javadoc.jar" + +ext_artifact="${ext_build_dir}/${ext_artifactId_release}-${version}.jar" +ext_sources_jar="${ext_build_dir}/${ext_artifactId_release}-${version}-sources.jar" +ext_javadoc_jar="${ext_build_dir}/${ext_artifactId_release}-${version}-javadoc.jar" + +generateGenericPom "${groupId}" \ + "${lib_artifactId_release}" \ + "${version}" \ + "The Articular-ES Framework" \ + "An entity component system (ECS) framework featuring strong articulations among components from different systems through controller interfaces." \ + "https://github.com/Software-Hardware-Codesign/Articular-ES" \ + "The AvrSandbox Project, Articular-ES Framework, BSD-3 Clause License" \ + "https://github.com/Software-Hardware-Codesign/Articular-ES/blob/master/LICENSE" \ + "Pavly Gerges (aka. pavl_g)" \ + "pepogerges33@gmail.com" \ + "The AvrSandbox" \ + "https://github.com/Software-Hardware-Codesign" \ + "scm:git:git://github.com/Software-Hardware-Codesign/Articular-ES.git" \ + "${lib_pomFile}" + +# publish 'android' and 'desktop' builds to maven sonatype +publishBuild "${lib_artifactId_release}" "${lib_artifact}" "${version}" "${lib_javadoc_jar}" "${lib_sources_jar}" "${lib_pomFile}" \ No newline at end of file diff --git a/helper-scripts/project-impl/variables.sh b/helper-scripts/project-impl/variables.sh new file mode 100644 index 0000000..5d11348 --- /dev/null +++ b/helper-scripts/project-impl/variables.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# Maven sonatype stuff +# --------------------- +sonatype_url="https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" +repository="ossrh" +groupId="io.github.software-hardware-codesign" +maven_version="3.9.3" +maven_bin="./apache-maven-$maven_version/bin/mvn" + +lib_pomFile="./helper-scripts/project-impl/publishing/articular.pom" + +passphrase="avrsandbox" + +lib_artifactId_release="articular-es" + +settings="./helper-scripts/project-impl/publishing/maven-settings.xml" +lib_build_dir="./articular-es/build/libs" +# --------------------- \ No newline at end of file