Skip to content

Commit

Permalink
Articular-ES: testing and deployment scripting
Browse files Browse the repository at this point in the history
  • Loading branch information
pavly-gerges committed Feb 10, 2024
1 parent 9a2da6b commit e8f7213
Show file tree
Hide file tree
Showing 14 changed files with 408 additions and 15 deletions.
110 changes: 110 additions & 0 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
@@ -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
94 changes: 94 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -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
35 changes: 20 additions & 15 deletions articular-es/build.gradle
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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()
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=SNAPSHOT
19 changes: 19 additions & 0 deletions helper-scripts/abstract/abstract-checksum-generator.sh
Original file line number Diff line number Diff line change
@@ -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 $?
}
10 changes: 10 additions & 0 deletions helper-scripts/abstract/abstract-move-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

function move() {
local src=$1
local dest=$2

mv -uv $src $dest

return $?
}
71 changes: 71 additions & 0 deletions helper-scripts/abstract/abstract-sonatype-publish.sh
Original file line number Diff line number Diff line change
@@ -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="<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\"> \
<modelVersion>4.0.0</modelVersion> \
<groupId>${groupId}</groupId> \
<artifactId>${artifactId}</artifactId> \
<version>${version}</version> \
<name>${name}</name> \
<packaging>jar</packaging> \
<description>${description}</description> \
<url>${url}</url> \
<licenses> \
<license> \
<name>${license_name}</name> \
<url>${license_url}</url> \
</license> \
</licenses> \
<developers> \
<developer> \
<name>${developer_name}</name> \
<email>${developer_mail}</email> \
<organization>${organization_name}</organization> \
<organizationUrl>${organization_url}</organizationUrl> \
</developer> \
</developers> \
<scm> \
<connection>${scm_conn}</connection> \
<developerConnection>${scm_conn}</developerConnection> \
<url>${url}</url> \
</scm> \
</project> \
"
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 $?
}
Binary file not shown.
16 changes: 16 additions & 0 deletions helper-scripts/project-impl/publishing/install-maven-latest.sh
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit e8f7213

Please sign in to comment.